Spaces:
Running
on
Zero
Running
on
Zero
File size: 18,940 Bytes
1cfe513 9e9b867 1c47184 9e9b867 1c47184 9e9b867 58e272a 50ef49c 0223744 58e272a 2317674 0223744 9e9b867 0cdbe8f 9e9b867 9a66aa0 9e9b867 58e272a 9e9b867 50ef49c 9e9b867 0223744 58e272a 50ef49c 58e272a 50ef49c 58e272a 0223744 50ef49c 58e272a 9e9b867 0223744 6360699 b03b509 a7a5221 ba10abd b03b509 c9a0841 b03b509 c9a0841 fd896d4 b03b509 c9a0841 fd896d4 b03b509 c9a0841 b03b509 0b0ac38 6e53936 c9a0841 0b0ac38 6e53936 0b0ac38 fd896d4 b03b509 7f1dbfb c9a0841 7f1dbfb c9a0841 7f1dbfb c9a0841 7f1dbfb c9a0841 0b0ac38 7f1dbfb fd896d4 6d46b35 7f1dbfb 0b0ac38 b03b509 6d46b35 9e9b867 b03b509 c9a0841 b03b509 7f1dbfb b03b509 7f1dbfb 6d46b35 7f1dbfb 0b0ac38 7f1dbfb 6d46b35 7f1dbfb b03b509 0b0ac38 b03b509 0b0ac38 b03b509 0b0ac38 b03b509 1fb62e7 b03b509 3cfd908 b03b509 1fb62e7 0223744 6d46b35 0223744 ba10abd 0223744 ba10abd 0223744 2317674 6d46b35 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
import torch
import gradio as gr
import spaces
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
import os
from threading import Thread
import random
from datasets import load_dataset
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
import pandas as pd
from typing import List, Tuple
import json
from datetime import datetime
# GPU ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ
torch.cuda.empty_cache()
# ํ๊ฒฝ ๋ณ์ ์ค์
HF_TOKEN = os.environ.get("HF_TOKEN", None)
MODEL_ID = "CohereForAI/c4ai-command-r7b-12-2024"
MODELS = os.environ.get("MODELS")
MODEL_NAME = MODEL_ID.split("/")[-1]
# ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ก๋
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
# ์ํคํผ๋์ ๋ฐ์ดํฐ์
๋ก๋
wiki_dataset = load_dataset("lcw99/wikipedia-korean-20240501-1million-qna")
print("Wikipedia dataset loaded:", wiki_dataset)
# TF-IDF ๋ฒกํฐ๋ผ์ด์ ์ด๊ธฐํ ๋ฐ ํ์ต
print("TF-IDF ๋ฒกํฐํ ์์...")
questions = wiki_dataset['train']['question'][:10000] # ์ฒ์ 10000๊ฐ๋ง ์ฌ์ฉ
vectorizer = TfidfVectorizer(max_features=1000)
question_vectors = vectorizer.fit_transform(questions)
print("TF-IDF ๋ฒกํฐํ ์๋ฃ")
class ChatHistory:
def __init__(self):
self.history = []
self.history_file = "/tmp/chat_history.json"
self.load_history()
def add_conversation(self, user_msg: str, assistant_msg: str):
conversation = {
"timestamp": datetime.now().isoformat(),
"messages": [
{"role": "user", "content": user_msg},
{"role": "assistant", "content": assistant_msg}
]
}
self.history.append(conversation)
self.save_history()
def format_for_display(self):
formatted = []
for conv in self.history:
formatted.append([
conv["messages"][0]["content"],
conv["messages"][1]["content"]
])
return formatted
def get_messages_for_api(self):
messages = []
for conv in self.history:
messages.extend([
{"role": "user", "content": conv["messages"][0]["content"]},
{"role": "assistant", "content": conv["messages"][1]["content"]}
])
return messages
def clear_history(self):
self.history = []
self.save_history()
def save_history(self):
try:
with open(self.history_file, 'w', encoding='utf-8') as f:
json.dump(self.history, f, ensure_ascii=False, indent=2)
except Exception as e:
print(f"ํ์คํ ๋ฆฌ ์ ์ฅ ์คํจ: {e}")
def load_history(self):
try:
if os.path.exists(self.history_file):
with open(self.history_file, 'r', encoding='utf-8') as f:
self.history = json.load(f)
except Exception as e:
print(f"ํ์คํ ๋ฆฌ ๋ก๋ ์คํจ: {e}")
self.history = []
# ์ ์ญ ChatHistory ์ธ์คํด์ค ์์ฑ
chat_history = ChatHistory()
def find_relevant_context(query, top_k=3):
# ์ฟผ๋ฆฌ ๋ฒกํฐํ
query_vector = vectorizer.transform([query])
# ์ฝ์ฌ์ธ ์ ์ฌ๋ ๊ณ์ฐ
similarities = (query_vector * question_vectors.T).toarray()[0]
# ๊ฐ์ฅ ์ ์ฌํ ์ง๋ฌธ๋ค์ ์ธ๋ฑ์ค
top_indices = np.argsort(similarities)[-top_k:][::-1]
# ๊ด๋ จ ์ปจํ
์คํธ ์ถ์ถ
relevant_contexts = []
for idx in top_indices:
if similarities[idx] > 0:
relevant_contexts.append({
'question': questions[idx],
'answer': wiki_dataset['train']['answer'][idx],
'similarity': similarities[idx]
})
return relevant_contexts
def analyze_file_content(content, file_type):
"""Analyze file content and return structural summary"""
if file_type in ['parquet', 'csv']:
try:
lines = content.split('\n')
header = lines[0]
columns = header.count('|') - 1
rows = len(lines) - 3
return f"๐ ๋ฐ์ดํฐ์
๊ตฌ์กฐ: {columns}๊ฐ ์ปฌ๋ผ, {rows}๊ฐ ๋ฐ์ดํฐ"
except:
return "โ ๋ฐ์ดํฐ์
๊ตฌ์กฐ ๋ถ์ ์คํจ"
lines = content.split('\n')
total_lines = len(lines)
non_empty_lines = len([line for line in lines if line.strip()])
if any(keyword in content.lower() for keyword in ['def ', 'class ', 'import ', 'function']):
functions = len([line for line in lines if 'def ' in line])
classes = len([line for line in lines if 'class ' in line])
imports = len([line for line in lines if 'import ' in line or 'from ' in line])
return f"๐ป ์ฝ๋ ๊ตฌ์กฐ: {total_lines}์ค (ํจ์: {functions}, ํด๋์ค: {classes}, ์ํฌํธ: {imports})"
paragraphs = content.count('\n\n') + 1
words = len(content.split())
return f"๐ ๋ฌธ์ ๊ตฌ์กฐ: {total_lines}์ค, {paragraphs}๋จ๋ฝ, ์ฝ {words}๋จ์ด"
def read_uploaded_file(file):
if file is None:
return "", ""
try:
file_ext = os.path.splitext(file.name)[1].lower()
if file_ext == '.parquet':
df = pd.read_parquet(file.name, engine='pyarrow')
content = df.head(10).to_markdown(index=False)
return content, "parquet"
elif file_ext == '.csv':
encodings = ['utf-8', 'cp949', 'euc-kr', 'latin1']
for encoding in encodings:
try:
df = pd.read_csv(file.name, encoding=encoding)
content = f"๐ ๋ฐ์ดํฐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ:\n{df.head(10).to_markdown(index=False)}\n\n"
content += f"\n๐ ๋ฐ์ดํฐ ์ ๋ณด:\n"
content += f"- ์ ์ฒด ํ ์: {len(df)}\n"
content += f"- ์ ์ฒด ์ด ์: {len(df.columns)}\n"
content += f"- ์ปฌ๋ผ ๋ชฉ๋ก: {', '.join(df.columns)}\n"
content += f"\n๐ ์ปฌ๋ผ ๋ฐ์ดํฐ ํ์
:\n"
for col, dtype in df.dtypes.items():
content += f"- {col}: {dtype}\n"
null_counts = df.isnull().sum()
if null_counts.any():
content += f"\nโ ๏ธ ๊ฒฐ์ธก์น:\n"
for col, null_count in null_counts[null_counts > 0].items():
content += f"- {col}: {null_count}๊ฐ ๋๋ฝ\n"
return content, "csv"
except UnicodeDecodeError:
continue
raise UnicodeDecodeError(f"โ ์ง์๋๋ ์ธ์ฝ๋ฉ์ผ๋ก ํ์ผ์ ์ฝ์ ์ ์์ต๋๋ค ({', '.join(encodings)})")
else:
encodings = ['utf-8', 'cp949', 'euc-kr', 'latin1']
for encoding in encodings:
try:
with open(file.name, 'r', encoding=encoding) as f:
content = f.read()
return content, "text"
except UnicodeDecodeError:
continue
raise UnicodeDecodeError(f"โ ์ง์๋๋ ์ธ์ฝ๋ฉ์ผ๋ก ํ์ผ์ ์ฝ์ ์ ์์ต๋๋ค ({', '.join(encodings)})")
except Exception as e:
return f"โ ํ์ผ ์ฝ๊ธฐ ์ค๋ฅ: {str(e)}", "error"
@spaces.GPU
def stream_chat(message: str, history: list, uploaded_file, temperature: float, max_new_tokens: int, top_p: float, top_k: int, penalty: float):
try:
print(f'message is - {message}')
print(f'history is - {history}')
# ํ์ผ ์
๋ก๋ ์ฒ๋ฆฌ
file_context = ""
if uploaded_file:
content, file_type = read_uploaded_file(uploaded_file)
if content:
file_context = f"\n\n์
๋ก๋๋ ํ์ผ ๋ด์ฉ:\n```\n{content}\n```"
# ๊ด๋ จ ์ปจํ
์คํธ ์ฐพ๊ธฐ
relevant_contexts = find_relevant_context(message)
wiki_context = "\n\n๊ด๋ จ ์ํคํผ๋์ ์ ๋ณด:\n"
for ctx in relevant_contexts:
wiki_context += f"Q: {ctx['question']}\nA: {ctx['answer']}\n์ ์ฌ๋: {ctx['similarity']:.3f}\n\n"
# ๋ํ ํ์คํ ๋ฆฌ ๊ตฌ์ฑ
conversation = []
for prompt, answer in history:
conversation.extend([
{"role": "user", "content": prompt},
{"role": "assistant", "content": answer}
])
# ์ต์ข
ํ๋กฌํํธ ๊ตฌ์ฑ
final_message = file_context + wiki_context + "\nํ์ฌ ์ง๋ฌธ: " + message
conversation.append({"role": "user", "content": final_message})
input_ids = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(input_ids, return_tensors="pt").to(0)
streamer = TextIteratorStreamer(tokenizer, timeout=10., skip_prompt=True, skip_special_tokens=True)
generate_kwargs = dict(
inputs,
streamer=streamer,
top_k=top_k,
top_p=top_p,
repetition_penalty=penalty,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=temperature,
eos_token_id=[255001],
)
thread = Thread(target=model.generate, kwargs=generate_kwargs)
thread.start()
buffer = ""
for new_text in streamer:
buffer += new_text
yield "", history + [[message, buffer]]
except Exception as e:
error_message = f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
yield "", history + [[message, error_message]]
CSS = """
/* 3D ์คํ์ผ CSS */
:root {
--primary-color: #2196f3;
--secondary-color: #1976d2;
--background-color: #f0f2f5;
--card-background: #ffffff;
--text-color: #333333;
--shadow-color: rgba(0, 0, 0, 0.1);
}
body {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.container {
transform-style: preserve-3d;
perspective: 1000px;
}
.chatbot {
background: var(--card-background);
border-radius: 20px;
box-shadow:
0 10px 20px var(--shadow-color),
0 6px 6px var(--shadow-color);
transform: translateZ(0);
transition: transform 0.3s ease;
backdrop-filter: blur(10px);
}
.chatbot:hover {
transform: translateZ(10px);
}
/* ๋ฉ์์ง ์
๋ ฅ ์์ญ */
.input-area {
background: var(--card-background);
border-radius: 15px;
padding: 15px;
margin-top: 20px;
box-shadow:
0 5px 15px var(--shadow-color),
0 3px 3px var(--shadow-color);
transform: translateZ(0);
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 10px;
}
.input-area:hover {
transform: translateZ(5px);
}
/* ๋ฒํผ ์คํ์ผ */
.custom-button {
background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
color: white;
border: none;
border-radius: 10px;
padding: 10px 20px;
font-weight: 600;
cursor: pointer;
transform: translateZ(0);
transition: all 0.3s ease;
box-shadow:
0 4px 6px var(--shadow-color),
0 1px 3px var(--shadow-color);
}
.custom-button:hover {
transform: translateZ(5px) translateY(-2px);
box-shadow:
0 7px 14px var(--shadow-color),
0 3px 6px var(--shadow-color);
}
/* ํ์ผ ์
๋ก๋ ๋ฒํผ */
.file-upload-icon {
background: linear-gradient(145deg, #64b5f6, #42a5f5);
color: white;
border-radius: 8px;
font-size: 2em;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
height: 70px;
width: 70px;
transition: all 0.3s ease;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.file-upload-icon:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
/* ํ์ผ ์
๋ก๋ ๋ฒํผ ๋ด๋ถ ์์ ์คํ์ผ๋ง */
.file-upload-icon > .wrap {
display: flex !important;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.file-upload-icon > .wrap > p {
display: none !important;
}
.file-upload-icon > .wrap::before {
content: "๐";
font-size: 2em;
display: block;
}
/* ๋ฉ์์ง ์คํ์ผ */
.message {
background: var(--card-background);
border-radius: 15px;
padding: 15px;
margin: 10px 0;
box-shadow:
0 4px 6px var(--shadow-color),
0 1px 3px var(--shadow-color);
transform: translateZ(0);
transition: all 0.3s ease;
}
.message:hover {
transform: translateZ(5px);
}
.chat-container {
height: 600px !important;
margin-bottom: 10px;
}
.input-container {
height: 70px !important;
display: flex;
align-items: center;
gap: 10px;
margin-top: 5px;
}
.input-textbox {
height: 70px !important;
border-radius: 8px !important;
font-size: 1.1em !important;
padding: 10px 15px !important;
display: flex !important;
align-items: flex-start !important; /* ํ
์คํธ ์
๋ ฅ ์์น๋ฅผ ์๋ก ์กฐ์ */
}
.input-textbox textarea {
padding-top: 5px !important; /* ํ
์คํธ ์๋จ ์ฌ๋ฐฑ ์กฐ์ */
}
.send-button {
height: 70px !important;
min-width: 70px !important;
font-size: 1.1em !important;
}
/* ์ค์ ํจ๋ ๊ธฐ๋ณธ ์คํ์ผ */
.settings-panel {
padding: 20px;
margin-top: 20px;
}
"""
# UI ๊ตฌ์ฑ
with gr.Blocks(css=CSS) as demo:
with gr.Column():
chatbot = gr.Chatbot(
value=[],
height=600,
label="GiniGEN AI Assistant",
elem_classes="chat-container"
)
with gr.Row(elem_classes="input-container"):
with gr.Column(scale=1, min_width=70):
file_upload = gr.File(
type="filepath",
elem_classes="file-upload-icon",
scale=1,
container=True,
interactive=True,
show_label=False
)
with gr.Column(scale=4):
msg = gr.Textbox(
show_label=False,
placeholder="๋ฉ์์ง๋ฅผ ์
๋ ฅํ์ธ์... ๐ญ",
container=False,
elem_classes="input-textbox",
scale=1
)
with gr.Column(scale=1, min_width=70):
send = gr.Button(
"์ ์ก",
elem_classes="send-button custom-button",
scale=1
)
with gr.Accordion("๐ฎ ๊ณ ๊ธ ์ค์ ", open=False):
with gr.Row():
with gr.Column(scale=1):
temperature = gr.Slider(
minimum=0, maximum=1, step=0.1, value=0.8,
label="์ฐฝ์์ฑ ์์ค ๐จ"
)
max_new_tokens = gr.Slider(
minimum=128, maximum=8000, step=1, value=4000,
label="์ต๋ ํ ํฐ ์ ๐"
)
with gr.Column(scale=1):
top_p = gr.Slider(
minimum=0.0, maximum=1.0, step=0.1, value=0.8,
label="๋ค์์ฑ ์กฐ์ ๐ฏ"
)
top_k = gr.Slider(
minimum=1, maximum=20, step=1, value=20,
label="์ ํ ๋ฒ์ ๐"
)
penalty = gr.Slider(
minimum=0.0, maximum=2.0, step=0.1, value=1.0,
label="๋ฐ๋ณต ์ต์ ๐"
)
gr.Examples(
examples=[
["๋ค์ ์ฝ๋์ ๋ฌธ์ ์ ์ ์ฐพ์๋ด๊ณ ๊ฐ์ ๋ ๋ฒ์ ์ ์ ์ํด์ฃผ์ธ์:\ndef fibonacci(n):\n if n <= 1: return n\n return fibonacci(n-1) + fibonacci(n-2)"],
["์์์ญํ์ ์๋ขฐ๋ฉ๊ฑฐ ๋ฐฉ์ ์๊ณผ ํ์ด์ ๋ฒ ๋ฅดํฌ์ ๋ถํ์ ์ฑ ์๋ฆฌ์ ๊ด๊ณ๋ฅผ ์ฝ๊ฒ ์ค๋ช
ํด์ฃผ์ธ์."],
["๋ค์ ์์ด ๋ฌธ์ฅ์ ํ๊ตญ์ด๋ก ๋ฒ์ญํ๊ณ , ์ดํ์ ๋ฌธ๋ฒ์ ํน์ง์ ์ค๋ช
ํด์ฃผ์ธ์: 'The implementation of artificial intelligence in healthcare has revolutionized patient care, yet it raises ethical concerns regarding privacy and decision-making autonomy.'"],
["์ฃผ์ด์ง ๋ฐ์ดํฐ๋ฅผ ๋ถ์ํ๊ณ ์ธ์ฌ์ดํธ๋ฅผ ๋์ถํด์ฃผ์ธ์:\n์ฐ๋๋ณ ๋งค์ถ์ก(์ต์)\n2019: 1200\n2020: 980\n2021: 1450\n2022: 2100\n2023: 1890"],
["๋ค์ ์๋๋ฆฌ์ค์ ๋ํ SWOT ๋ถ์์ ํด์ฃผ์ธ์: '์ ํต์ ์ธ ์คํ๋ผ์ธ ์์ ์ด ์จ๋ผ์ธ ํ๋ซํผ์ผ๋ก์ ์ ํ์ ๊ณ ๋ ค์ค์
๋๋ค. ๋
์๋ค์ ๋์งํธ ์ฝํ
์ธ ์๋น๊ฐ ์ฆ๊ฐํ๋ ์ํฉ์์ ๊ฒฝ์๋ ฅ์ ์ ์งํ๋ฉด์ ๊ธฐ์กด ๊ณ ๊ฐ์ธต๋ ์งํค๊ณ ์ถ์ต๋๋ค.'"],
["์ด ์ฒ ํ์ ์ง๋ฌธ์ ๋ํด ๋ค์ํ ๊ด์ ์์ ๋
ผ๋ฆฌ์ ์ผ๋ก ๋ถ์ํด์ฃผ์ธ์: '์ธ๊ณต์ง๋ฅ์ด ์์์ ๊ฐ์ง ์ ์๋๊ฐ? ์์์ ์ ์๋ ๋ฌด์์ด๋ฉฐ, ๊ธฐ๊ณ๊ฐ ๊ทธ๊ฒ์ ๊ฐ์ง ์ ์๋ ์กฐ๊ฑด์ ๋ฌด์์ธ๊ฐ?'"],
["๋ค์ ์ํ ๋ฌธ์ ๋ฅผ ๋จ๊ณ๋ณ๋ก ์์ธํ ํ์ดํด์ฃผ์ธ์: 'ํ ์์ ๋์ด๊ฐ ๊ทธ ์์ ๋ด์ ํ๋ ์ ์ฌ๊ฐํ ๋์ด์ 2๋ฐฐ์ผ ๋, ์์ ๋ฐ์ง๋ฆ๊ณผ ์ ์ฌ๊ฐํ์ ํ ๋ณ์ ๊ธธ์ด์ ๊ด๊ณ๋ฅผ ๊ตฌํ์์ค.'"],
["๋ค์ SQL ์ฟผ๋ฆฌ๋ฅผ ์ต์ ํํ๊ณ ๊ฐ์ ์ ์ ์ค๋ช
ํด์ฃผ์ธ์:\nSELECT * FROM orders o\nLEFT JOIN customers c ON o.customer_id = c.id\nWHERE YEAR(o.order_date) = 2023\nAND c.country = 'Korea'\nORDER BY o.order_date DESC;"],
["ํ๋ ๋ฌผ๋ฆฌํ์ ๊ฐ์ฅ ํฐ ๋ฏธ์คํฐ๋ฆฌ์ธ '์ํ ๋ฌผ์ง'๊ณผ '์ํ ์๋์ง'์ ๋ํด ์ค๋ช
ํ๊ณ , ์ด๋ค์ด ์ฐ์ฃผ์ ๊ตฌ์กฐ์ ์งํ์ ๋ฏธ์น๋ ์ํฅ์ ๋ถ์ํด์ฃผ์ธ์."],
["๋ค์ ๋ง์ผํ
์บ ํ์ธ์ ROI๋ฅผ ๋ถ์ํ๊ณ ๊ฐ์ ๋ฐฉ์์ ์ ์ํด์ฃผ์ธ์:\n์ด ๋น์ฉ: 5000๋ง์\n๋๋ฌ์ ์: 100๋ง๋ช
\nํด๋ฆญ๋ฅ : 2.3%\n์ ํ์จ: 0.8%\nํ๊ท ๊ตฌ๋งค์ก: 35,000์"],
],
inputs=msg
)
# ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
msg.submit(
stream_chat,
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
outputs=[msg, chatbot]
)
send.click(
stream_chat,
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
outputs=[msg, chatbot]
)
def init_msg():
return "ํ์ผ ๋ถ์์ ์์ํฉ๋๋ค..."
file_upload.change(
init_msg,
outputs=msg
).then(
stream_chat,
inputs=[msg, chatbot, file_upload, temperature, max_new_tokens, top_p, top_k, penalty],
outputs=[msg, chatbot]
)
if __name__ == "__main__":
demo.launch() |