Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,94 +4,24 @@ import openai
|
|
| 4 |
import anthropic
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
# 제거할 모델들을 MODELS 사전에서 제외
|
| 8 |
-
MODELS = {
|
| 9 |
-
"Zephyr 7B Beta": "HuggingFaceH4/zephyr-7b-beta",
|
| 10 |
-
"Meta Llama 3.1 8B": "meta-llama/Meta-Llama-3.1-8B-Instruct",
|
| 11 |
-
"Meta-Llama 3.1 70B-Instruct": "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
| 12 |
-
"Microsoft": "microsoft/Phi-3-mini-4k-instruct",
|
| 13 |
-
"Mixtral 8x7B": "mistralai/Mistral-7B-Instruct-v0.3",
|
| 14 |
-
"Mixtral Nous-Hermes": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
|
| 15 |
-
"Aya-23-35B": "CohereForAI/aya-23-35B",
|
| 16 |
-
"DeepSeek-V3": "deepseek/deepseek-chat"
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
# Cohere Command R+ 모델 ID 정의
|
| 20 |
COHERE_MODEL = "CohereForAI/c4ai-command-r-plus-08-2024"
|
| 21 |
|
| 22 |
-
def get_client(model_name
|
| 23 |
"""
|
| 24 |
모델 이름에 맞춰 InferenceClient 생성.
|
| 25 |
-
|
| 26 |
"""
|
|
|
|
| 27 |
if not hf_token:
|
| 28 |
-
raise ValueError("HuggingFace API 토큰이 필요합니다.")
|
| 29 |
|
| 30 |
-
if model_name
|
| 31 |
-
model_id = MODELS[model_name]
|
| 32 |
-
elif model_name == "Cohere Command R+":
|
| 33 |
model_id = COHERE_MODEL
|
| 34 |
else:
|
| 35 |
raise ValueError("유효하지 않은 모델 이름입니다.")
|
| 36 |
return InferenceClient(model_id, token=hf_token)
|
| 37 |
|
| 38 |
-
def respond(
|
| 39 |
-
message,
|
| 40 |
-
chat_history,
|
| 41 |
-
model_name,
|
| 42 |
-
max_tokens,
|
| 43 |
-
temperature,
|
| 44 |
-
top_p,
|
| 45 |
-
system_message,
|
| 46 |
-
hf_token, # HF 토큰을 추가로 받음
|
| 47 |
-
):
|
| 48 |
-
try:
|
| 49 |
-
client = get_client(model_name, hf_token)
|
| 50 |
-
except ValueError as e:
|
| 51 |
-
chat_history.append((message, str(e)))
|
| 52 |
-
return chat_history
|
| 53 |
-
|
| 54 |
-
messages = [{"role": "system", "content": system_message}]
|
| 55 |
-
for human, assistant in chat_history:
|
| 56 |
-
messages.append({"role": "user", "content": human})
|
| 57 |
-
messages.append({"role": "assistant", "content": assistant})
|
| 58 |
-
messages.append({"role": "user", "content": message})
|
| 59 |
-
|
| 60 |
-
try:
|
| 61 |
-
if model_name == "Cohere Command R+":
|
| 62 |
-
# Cohere Command R+ 모델을 위한 비스트리밍 처리
|
| 63 |
-
response = client.chat_completion(
|
| 64 |
-
messages,
|
| 65 |
-
max_tokens=max_tokens,
|
| 66 |
-
temperature=temperature,
|
| 67 |
-
top_p=top_p,
|
| 68 |
-
)
|
| 69 |
-
assistant_message = response.choices[0].message.content
|
| 70 |
-
chat_history.append((message, assistant_message))
|
| 71 |
-
return chat_history
|
| 72 |
-
else:
|
| 73 |
-
# 다른 모델들을 위한 스트리밍 처리
|
| 74 |
-
stream = client.chat_completion(
|
| 75 |
-
messages,
|
| 76 |
-
max_tokens=max_tokens,
|
| 77 |
-
temperature=temperature,
|
| 78 |
-
top_p=top_p,
|
| 79 |
-
stream=True,
|
| 80 |
-
)
|
| 81 |
-
partial_message = ""
|
| 82 |
-
for response in stream:
|
| 83 |
-
if response.choices[0].delta.content is not None:
|
| 84 |
-
partial_message += response.choices[0].delta.content
|
| 85 |
-
if len(chat_history) > 0 and chat_history[-1][0] == message:
|
| 86 |
-
chat_history[-1] = (message, partial_message)
|
| 87 |
-
else:
|
| 88 |
-
chat_history.append((message, partial_message))
|
| 89 |
-
yield chat_history
|
| 90 |
-
except Exception as e:
|
| 91 |
-
error_message = f"오류가 발생했습니다: {str(e)}"
|
| 92 |
-
chat_history.append((message, error_message))
|
| 93 |
-
yield chat_history
|
| 94 |
-
|
| 95 |
def cohere_respond(
|
| 96 |
message,
|
| 97 |
chat_history,
|
|
@@ -99,11 +29,14 @@ def cohere_respond(
|
|
| 99 |
max_tokens,
|
| 100 |
temperature,
|
| 101 |
top_p,
|
| 102 |
-
hf_token, # HF 토큰 추가
|
| 103 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
model_name = "Cohere Command R+"
|
| 105 |
try:
|
| 106 |
-
client = get_client(model_name
|
| 107 |
except ValueError as e:
|
| 108 |
chat_history.append((message, str(e)))
|
| 109 |
return chat_history
|
|
@@ -118,7 +51,6 @@ def cohere_respond(
|
|
| 118 |
messages.append({"role": "user", "content": message})
|
| 119 |
|
| 120 |
try:
|
| 121 |
-
# Cohere Command R+ 모델을 위한 비스트리밍 처리
|
| 122 |
response_full = client.chat_completion(
|
| 123 |
messages,
|
| 124 |
max_tokens=max_tokens,
|
|
@@ -140,16 +72,17 @@ def chatgpt_respond(
|
|
| 140 |
max_tokens,
|
| 141 |
temperature,
|
| 142 |
top_p,
|
| 143 |
-
openai_token, # openai 토큰 추가
|
| 144 |
):
|
| 145 |
"""
|
| 146 |
-
|
|
|
|
| 147 |
"""
|
|
|
|
| 148 |
if not openai_token:
|
| 149 |
-
chat_history.append((message, "OpenAI API 토큰이 필요합니다."))
|
| 150 |
return chat_history
|
| 151 |
|
| 152 |
-
openai.api_key = openai_token #
|
| 153 |
|
| 154 |
messages = [{"role": "system", "content": system_message}]
|
| 155 |
for human, assistant in chat_history:
|
|
@@ -180,19 +113,19 @@ def claude_respond(
|
|
| 180 |
max_tokens,
|
| 181 |
temperature,
|
| 182 |
top_p,
|
| 183 |
-
claude_token, # Claude 토큰 추가
|
| 184 |
):
|
| 185 |
"""
|
| 186 |
-
Claude
|
|
|
|
| 187 |
"""
|
|
|
|
| 188 |
if not claude_token:
|
| 189 |
-
chat_history.append((message, "Claude API 토큰이 필요합니다."))
|
| 190 |
return chat_history
|
| 191 |
|
| 192 |
try:
|
| 193 |
client = anthropic.Anthropic(api_key=claude_token)
|
| 194 |
|
| 195 |
-
# 메시지 생성
|
| 196 |
response = client.messages.create(
|
| 197 |
model="claude-3-haiku-20240307",
|
| 198 |
max_tokens=max_tokens,
|
|
@@ -221,13 +154,14 @@ def deepseek_respond(
|
|
| 221 |
max_tokens,
|
| 222 |
temperature,
|
| 223 |
top_p,
|
| 224 |
-
deepseek_token, # DeepSeek 토큰 추가
|
| 225 |
):
|
| 226 |
"""
|
| 227 |
-
DeepSeek
|
|
|
|
| 228 |
"""
|
|
|
|
| 229 |
if not deepseek_token:
|
| 230 |
-
chat_history.append((message, "DeepSeek API 토큰이 필요합니다."))
|
| 231 |
return chat_history
|
| 232 |
|
| 233 |
openai.api_key = deepseek_token
|
|
@@ -258,75 +192,18 @@ def deepseek_respond(
|
|
| 258 |
def clear_conversation():
|
| 259 |
return []
|
| 260 |
|
|
|
|
|
|
|
|
|
|
| 261 |
with gr.Blocks() as demo:
|
| 262 |
gr.Markdown("# Prompting AI Chatbot")
|
| 263 |
gr.Markdown("언어모델별 프롬프트 테스트 챗봇입니다.")
|
| 264 |
|
| 265 |
-
#
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
label="HuggingFace 토큰",
|
| 269 |
-
type="password",
|
| 270 |
-
placeholder="HuggingFace API 토큰을 입력하세요..."
|
| 271 |
-
)
|
| 272 |
-
openai_token_box = gr.Textbox(
|
| 273 |
-
label="OpenAI 토큰",
|
| 274 |
-
type="password",
|
| 275 |
-
placeholder="OpenAI API 토큰을 입력하세요..."
|
| 276 |
-
)
|
| 277 |
-
claude_token_box = gr.Textbox(
|
| 278 |
-
label="Claude 토큰",
|
| 279 |
-
type="password",
|
| 280 |
-
placeholder="Claude API 토큰을 입력하세요..."
|
| 281 |
-
)
|
| 282 |
-
deepseek_token_box = gr.Textbox(
|
| 283 |
-
label="DeepSeek 토큰",
|
| 284 |
-
type="password",
|
| 285 |
-
placeholder="DeepSeek API 토큰을 입력하세요..."
|
| 286 |
-
)
|
| 287 |
|
| 288 |
-
|
| 289 |
-
with gr.Row():
|
| 290 |
-
with gr.Column(scale=1):
|
| 291 |
-
model_name = gr.Radio(
|
| 292 |
-
choices=list(MODELS.keys()),
|
| 293 |
-
label="Language Model",
|
| 294 |
-
value="Zephyr 7B Beta"
|
| 295 |
-
)
|
| 296 |
-
max_tokens = gr.Slider(minimum=100, maximum=8000, value=2000, step=100, label="Max Tokens")
|
| 297 |
-
temperature = gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.05, label="Temperature")
|
| 298 |
-
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p")
|
| 299 |
-
system_message = gr.Textbox(
|
| 300 |
-
value="""반드시 한글로 답변할 것.
|
| 301 |
-
너는 최고의 비서이다.
|
| 302 |
-
내가 요구하는것들을 최대한 자세하고 정확하게 답변하라.
|
| 303 |
-
""",
|
| 304 |
-
label="System Message",
|
| 305 |
-
lines=3
|
| 306 |
-
)
|
| 307 |
-
|
| 308 |
-
with gr.Column(scale=2):
|
| 309 |
-
chatbot = gr.Chatbot()
|
| 310 |
-
msg = gr.Textbox(label="메세지를 입력하세요")
|
| 311 |
-
with gr.Row():
|
| 312 |
-
submit_button = gr.Button("전송")
|
| 313 |
-
clear_button = gr.Button("대화 내역 지우기")
|
| 314 |
-
|
| 315 |
-
# respond 함수에 hf_token 인자를 전달하도록 수정
|
| 316 |
-
inputs_for_normal = [
|
| 317 |
-
msg,
|
| 318 |
-
chatbot,
|
| 319 |
-
model_name,
|
| 320 |
-
max_tokens,
|
| 321 |
-
temperature,
|
| 322 |
-
top_p,
|
| 323 |
-
system_message,
|
| 324 |
-
hf_token_box
|
| 325 |
-
]
|
| 326 |
-
msg.submit(respond, inputs_for_normal, chatbot)
|
| 327 |
-
submit_button.click(respond, inputs_for_normal, chatbot)
|
| 328 |
-
clear_button.click(clear_conversation, outputs=chatbot, queue=False)
|
| 329 |
-
|
| 330 |
with gr.Tab("Cohere Command R+"):
|
| 331 |
with gr.Row():
|
| 332 |
cohere_system_message = gr.Textbox(
|
|
@@ -353,20 +230,19 @@ with gr.Blocks() as demo:
|
|
| 353 |
cohere_submit_button = gr.Button("전송")
|
| 354 |
cohere_clear_button = gr.Button("대화 내역 지우기")
|
| 355 |
|
| 356 |
-
# cohere_respond 함수에 hf_token 인자를 전달하도록 수정
|
| 357 |
inputs_for_cohere = [
|
| 358 |
cohere_msg,
|
| 359 |
cohere_chatbot,
|
| 360 |
cohere_system_message,
|
| 361 |
cohere_max_tokens,
|
| 362 |
cohere_temperature,
|
| 363 |
-
cohere_top_p
|
| 364 |
-
hf_token_box
|
| 365 |
]
|
| 366 |
cohere_msg.submit(cohere_respond, inputs_for_cohere, cohere_chatbot)
|
| 367 |
cohere_submit_button.click(cohere_respond, inputs_for_cohere, cohere_chatbot)
|
| 368 |
cohere_clear_button.click(clear_conversation, outputs=cohere_chatbot, queue=False)
|
| 369 |
-
|
|
|
|
| 370 |
with gr.Tab("ChatGPT"):
|
| 371 |
with gr.Row():
|
| 372 |
chatgpt_system_message = gr.Textbox(
|
|
@@ -393,20 +269,19 @@ with gr.Blocks() as demo:
|
|
| 393 |
chatgpt_submit_button = gr.Button("전송")
|
| 394 |
chatgpt_clear_button = gr.Button("대화 내역 지우기")
|
| 395 |
|
| 396 |
-
# chatgpt_respond 함수에 openai_token 인자를 전달하도록 수정
|
| 397 |
inputs_for_chatgpt = [
|
| 398 |
-
chatgpt_msg,
|
| 399 |
-
chatgpt_chatbot,
|
| 400 |
-
chatgpt_system_message,
|
| 401 |
-
chatgpt_max_tokens,
|
| 402 |
-
chatgpt_temperature,
|
| 403 |
-
chatgpt_top_p
|
| 404 |
-
openai_token_box
|
| 405 |
]
|
| 406 |
chatgpt_msg.submit(chatgpt_respond, inputs_for_chatgpt, chatgpt_chatbot)
|
| 407 |
chatgpt_submit_button.click(chatgpt_respond, inputs_for_chatgpt, chatgpt_chatbot)
|
| 408 |
chatgpt_clear_button.click(clear_conversation, outputs=chatgpt_chatbot, queue=False)
|
| 409 |
|
|
|
|
| 410 |
with gr.Tab("Claude"):
|
| 411 |
with gr.Row():
|
| 412 |
claude_system_message = gr.Textbox(
|
|
@@ -433,20 +308,19 @@ with gr.Blocks() as demo:
|
|
| 433 |
claude_submit_button = gr.Button("전송")
|
| 434 |
claude_clear_button = gr.Button("대화 내역 지우기")
|
| 435 |
|
| 436 |
-
# claude_respond 함수에 claude_token 인자를 전달하도록 수정
|
| 437 |
inputs_for_claude = [
|
| 438 |
claude_msg,
|
| 439 |
claude_chatbot,
|
| 440 |
claude_system_message,
|
| 441 |
claude_max_tokens,
|
| 442 |
claude_temperature,
|
| 443 |
-
claude_top_p
|
| 444 |
-
claude_token_box
|
| 445 |
]
|
| 446 |
claude_msg.submit(claude_respond, inputs_for_claude, claude_chatbot)
|
| 447 |
claude_submit_button.click(claude_respond, inputs_for_claude, claude_chatbot)
|
| 448 |
claude_clear_button.click(clear_conversation, outputs=claude_chatbot, queue=False)
|
| 449 |
|
|
|
|
| 450 |
with gr.Tab("DeepSeek"):
|
| 451 |
with gr.Row():
|
| 452 |
deepseek_system_message = gr.Textbox(
|
|
@@ -473,19 +347,17 @@ with gr.Blocks() as demo:
|
|
| 473 |
deepseek_submit_button = gr.Button("전송")
|
| 474 |
deepseek_clear_button = gr.Button("대화 내역 지우기")
|
| 475 |
|
| 476 |
-
# deepseek_respond 함수에 deepseek_token 인자를 전달하도록 수정
|
| 477 |
inputs_for_deepseek = [
|
| 478 |
-
deepseek_msg,
|
| 479 |
-
deepseek_chatbot,
|
| 480 |
-
deepseek_system_message,
|
| 481 |
-
deepseek_max_tokens,
|
| 482 |
-
deepseek_temperature,
|
| 483 |
-
deepseek_top_p
|
| 484 |
-
deepseek_token_box
|
| 485 |
]
|
| 486 |
deepseek_msg.submit(deepseek_respond, inputs_for_deepseek, deepseek_chatbot)
|
| 487 |
deepseek_submit_button.click(deepseek_respond, inputs_for_deepseek, deepseek_chatbot)
|
| 488 |
deepseek_clear_button.click(clear_conversation, outputs=deepseek_chatbot, queue=False)
|
| 489 |
|
| 490 |
if __name__ == "__main__":
|
| 491 |
-
demo.launch()
|
|
|
|
| 4 |
import anthropic
|
| 5 |
import os
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Cohere Command R+ 모델 ID 정의
|
| 8 |
COHERE_MODEL = "CohereForAI/c4ai-command-r-plus-08-2024"
|
| 9 |
|
| 10 |
+
def get_client(model_name: str):
|
| 11 |
"""
|
| 12 |
모델 이름에 맞춰 InferenceClient 생성.
|
| 13 |
+
HuggingFace 토큰은 os.environ.get("HF_TOKEN")을 통해 환경변수로 가져온다.
|
| 14 |
"""
|
| 15 |
+
hf_token = os.environ.get("HF_TOKEN")
|
| 16 |
if not hf_token:
|
| 17 |
+
raise ValueError("HuggingFace API 토큰이 필요합니다. (환경변수 HF_TOKEN 미설정)")
|
| 18 |
|
| 19 |
+
if model_name == "Cohere Command R+":
|
|
|
|
|
|
|
| 20 |
model_id = COHERE_MODEL
|
| 21 |
else:
|
| 22 |
raise ValueError("유효하지 않은 모델 이름입니다.")
|
| 23 |
return InferenceClient(model_id, token=hf_token)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def cohere_respond(
|
| 26 |
message,
|
| 27 |
chat_history,
|
|
|
|
| 29 |
max_tokens,
|
| 30 |
temperature,
|
| 31 |
top_p,
|
|
|
|
| 32 |
):
|
| 33 |
+
"""
|
| 34 |
+
Cohere Command R+ 모델 응답 함수.
|
| 35 |
+
HF 토큰은 함수 내부에서 os.environ을 통해 불러온다.
|
| 36 |
+
"""
|
| 37 |
model_name = "Cohere Command R+"
|
| 38 |
try:
|
| 39 |
+
client = get_client(model_name)
|
| 40 |
except ValueError as e:
|
| 41 |
chat_history.append((message, str(e)))
|
| 42 |
return chat_history
|
|
|
|
| 51 |
messages.append({"role": "user", "content": message})
|
| 52 |
|
| 53 |
try:
|
|
|
|
| 54 |
response_full = client.chat_completion(
|
| 55 |
messages,
|
| 56 |
max_tokens=max_tokens,
|
|
|
|
| 72 |
max_tokens,
|
| 73 |
temperature,
|
| 74 |
top_p,
|
|
|
|
| 75 |
):
|
| 76 |
"""
|
| 77 |
+
ChatGPT 모델 응답 함수.
|
| 78 |
+
OpenAI 토큰은 함수 내부에서 os.environ을 통해 불러온다.
|
| 79 |
"""
|
| 80 |
+
openai_token = os.environ.get("OPENAI_TOKEN")
|
| 81 |
if not openai_token:
|
| 82 |
+
chat_history.append((message, "OpenAI API 토큰이 필요합니다. (환경변수 OPENAI_TOKEN 미설정)"))
|
| 83 |
return chat_history
|
| 84 |
|
| 85 |
+
openai.api_key = openai_token # 환경변수에서 받은 토큰 사용
|
| 86 |
|
| 87 |
messages = [{"role": "system", "content": system_message}]
|
| 88 |
for human, assistant in chat_history:
|
|
|
|
| 113 |
max_tokens,
|
| 114 |
temperature,
|
| 115 |
top_p,
|
|
|
|
| 116 |
):
|
| 117 |
"""
|
| 118 |
+
Claude 모델 응답 함수.
|
| 119 |
+
Claude 토큰은 함수 내부에서 os.environ을 통해 불러온다.
|
| 120 |
"""
|
| 121 |
+
claude_token = os.environ.get("CLAUDE_TOKEN")
|
| 122 |
if not claude_token:
|
| 123 |
+
chat_history.append((message, "Claude API 토큰이 필요합니다. (환경변수 CLAUDE_TOKEN 미설정)"))
|
| 124 |
return chat_history
|
| 125 |
|
| 126 |
try:
|
| 127 |
client = anthropic.Anthropic(api_key=claude_token)
|
| 128 |
|
|
|
|
| 129 |
response = client.messages.create(
|
| 130 |
model="claude-3-haiku-20240307",
|
| 131 |
max_tokens=max_tokens,
|
|
|
|
| 154 |
max_tokens,
|
| 155 |
temperature,
|
| 156 |
top_p,
|
|
|
|
| 157 |
):
|
| 158 |
"""
|
| 159 |
+
DeepSeek 모델 응답 함수.
|
| 160 |
+
DeepSeek 토큰은 함수 내부에서 os.environ을 통해 불러온다.
|
| 161 |
"""
|
| 162 |
+
deepseek_token = os.environ.get("DEEPSEEK_TOKEN")
|
| 163 |
if not deepseek_token:
|
| 164 |
+
chat_history.append((message, "DeepSeek API 토큰이 필요합니다. (환경변수 DEEPSEEK_TOKEN 미설정)"))
|
| 165 |
return chat_history
|
| 166 |
|
| 167 |
openai.api_key = deepseek_token
|
|
|
|
| 192 |
def clear_conversation():
|
| 193 |
return []
|
| 194 |
|
| 195 |
+
# --------------------------------------------
|
| 196 |
+
# Gradio 앱 시작
|
| 197 |
+
# --------------------------------------------
|
| 198 |
with gr.Blocks() as demo:
|
| 199 |
gr.Markdown("# Prompting AI Chatbot")
|
| 200 |
gr.Markdown("언어모델별 프롬프트 테스트 챗봇입니다.")
|
| 201 |
|
| 202 |
+
# --------------------------------------------------
|
| 203 |
+
# 일반 모델 관련 UI/기능 제거 (요청 사항에 따라 삭제)
|
| 204 |
+
# --------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
# Cohere Command R+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
with gr.Tab("Cohere Command R+"):
|
| 208 |
with gr.Row():
|
| 209 |
cohere_system_message = gr.Textbox(
|
|
|
|
| 230 |
cohere_submit_button = gr.Button("전송")
|
| 231 |
cohere_clear_button = gr.Button("대화 내역 지우기")
|
| 232 |
|
|
|
|
| 233 |
inputs_for_cohere = [
|
| 234 |
cohere_msg,
|
| 235 |
cohere_chatbot,
|
| 236 |
cohere_system_message,
|
| 237 |
cohere_max_tokens,
|
| 238 |
cohere_temperature,
|
| 239 |
+
cohere_top_p
|
|
|
|
| 240 |
]
|
| 241 |
cohere_msg.submit(cohere_respond, inputs_for_cohere, cohere_chatbot)
|
| 242 |
cohere_submit_button.click(cohere_respond, inputs_for_cohere, cohere_chatbot)
|
| 243 |
cohere_clear_button.click(clear_conversation, outputs=cohere_chatbot, queue=False)
|
| 244 |
+
|
| 245 |
+
# ChatGPT
|
| 246 |
with gr.Tab("ChatGPT"):
|
| 247 |
with gr.Row():
|
| 248 |
chatgpt_system_message = gr.Textbox(
|
|
|
|
| 269 |
chatgpt_submit_button = gr.Button("전송")
|
| 270 |
chatgpt_clear_button = gr.Button("대화 내역 지우기")
|
| 271 |
|
|
|
|
| 272 |
inputs_for_chatgpt = [
|
| 273 |
+
chatgpt_msg,
|
| 274 |
+
chatgpt_chatbot,
|
| 275 |
+
chatgpt_system_message,
|
| 276 |
+
chatgpt_max_tokens,
|
| 277 |
+
chatgpt_temperature,
|
| 278 |
+
chatgpt_top_p
|
|
|
|
| 279 |
]
|
| 280 |
chatgpt_msg.submit(chatgpt_respond, inputs_for_chatgpt, chatgpt_chatbot)
|
| 281 |
chatgpt_submit_button.click(chatgpt_respond, inputs_for_chatgpt, chatgpt_chatbot)
|
| 282 |
chatgpt_clear_button.click(clear_conversation, outputs=chatgpt_chatbot, queue=False)
|
| 283 |
|
| 284 |
+
# Claude
|
| 285 |
with gr.Tab("Claude"):
|
| 286 |
with gr.Row():
|
| 287 |
claude_system_message = gr.Textbox(
|
|
|
|
| 308 |
claude_submit_button = gr.Button("전송")
|
| 309 |
claude_clear_button = gr.Button("대화 내역 지우기")
|
| 310 |
|
|
|
|
| 311 |
inputs_for_claude = [
|
| 312 |
claude_msg,
|
| 313 |
claude_chatbot,
|
| 314 |
claude_system_message,
|
| 315 |
claude_max_tokens,
|
| 316 |
claude_temperature,
|
| 317 |
+
claude_top_p
|
|
|
|
| 318 |
]
|
| 319 |
claude_msg.submit(claude_respond, inputs_for_claude, claude_chatbot)
|
| 320 |
claude_submit_button.click(claude_respond, inputs_for_claude, claude_chatbot)
|
| 321 |
claude_clear_button.click(clear_conversation, outputs=claude_chatbot, queue=False)
|
| 322 |
|
| 323 |
+
# DeepSeek
|
| 324 |
with gr.Tab("DeepSeek"):
|
| 325 |
with gr.Row():
|
| 326 |
deepseek_system_message = gr.Textbox(
|
|
|
|
| 347 |
deepseek_submit_button = gr.Button("전송")
|
| 348 |
deepseek_clear_button = gr.Button("대화 내역 지우기")
|
| 349 |
|
|
|
|
| 350 |
inputs_for_deepseek = [
|
| 351 |
+
deepseek_msg,
|
| 352 |
+
deepseek_chatbot,
|
| 353 |
+
deepseek_system_message,
|
| 354 |
+
deepseek_max_tokens,
|
| 355 |
+
deepseek_temperature,
|
| 356 |
+
deepseek_top_p
|
|
|
|
| 357 |
]
|
| 358 |
deepseek_msg.submit(deepseek_respond, inputs_for_deepseek, deepseek_chatbot)
|
| 359 |
deepseek_submit_button.click(deepseek_respond, inputs_for_deepseek, deepseek_chatbot)
|
| 360 |
deepseek_clear_button.click(clear_conversation, outputs=deepseek_chatbot, queue=False)
|
| 361 |
|
| 362 |
if __name__ == "__main__":
|
| 363 |
+
demo.launch()
|