Update app.py
Browse files
app.py
CHANGED
@@ -83,7 +83,7 @@ def format_prompt(message, history):
|
|
83 |
prompt += f"[INST] {message} [/INST]"
|
84 |
return prompt
|
85 |
|
86 |
-
def generate(prompt, history=[], temperature=0.1, max_new_tokens=
|
87 |
input_tokens = len(tokenizer.encode(prompt))
|
88 |
available_tokens = 32768 - input_tokens
|
89 |
max_new_tokens = min(max_new_tokens, available_tokens)
|
@@ -100,12 +100,20 @@ def generate(prompt, history=[], temperature=0.1, max_new_tokens=24000, top_p=0.
|
|
100 |
if isinstance(response, dict) and 'generated_text' in response:
|
101 |
output += response['generated_text']
|
102 |
else:
|
103 |
-
output += str(response)
|
104 |
return output, f"Used tokens: {input_tokens + max_new_tokens}"
|
105 |
except Exception as e:
|
106 |
return f"Error: {str(e)}", "Used tokens: 0"
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
|
|
109 |
|
110 |
|
111 |
mychatbot = gr.Chatbot(
|
|
|
83 |
prompt += f"[INST] {message} [/INST]"
|
84 |
return prompt
|
85 |
|
86 |
+
def generate(prompt, history=[], temperature=0.1, max_new_tokens=25000, top_p=0.95, repetition_penalty=1.0):
|
87 |
input_tokens = len(tokenizer.encode(prompt))
|
88 |
available_tokens = 32768 - input_tokens
|
89 |
max_new_tokens = min(max_new_tokens, available_tokens)
|
|
|
100 |
if isinstance(response, dict) and 'generated_text' in response:
|
101 |
output += response['generated_text']
|
102 |
else:
|
103 |
+
output += str(response) # 이 부분을 문자열로 처리
|
104 |
return output, f"Used tokens: {input_tokens + max_new_tokens}"
|
105 |
except Exception as e:
|
106 |
return f"Error: {str(e)}", "Used tokens: 0"
|
107 |
|
108 |
+
demo = gr.Interface(
|
109 |
+
fn=generate,
|
110 |
+
inputs=[gr.Textbox(label="질문을 입력하세요", placeholder="여기에 질문을 입력하세요...", lines=2), gr.JSON(label="History", value=[])],
|
111 |
+
outputs=[gr.Markdown(), gr.Label()],
|
112 |
+
title="AIQ 코드파일럿: OpenLLM v1.12",
|
113 |
+
description="AIQ Codepilot과 상호작용해 보세요."
|
114 |
+
)
|
115 |
|
116 |
+
demo.launch(show_api=False)
|
117 |
|
118 |
|
119 |
mychatbot = gr.Chatbot(
|