Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,8 @@
|
|
| 1 |
-
import openai
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
history_openai_format.append({"role": "user", "content": human })
|
| 11 |
-
history_openai_format.append({"role": "assistant", "content":assistant})
|
| 12 |
-
history_openai_format.append({"role": "user", "content": message})
|
| 13 |
-
|
| 14 |
-
response = openai.ChatCompletion.create(
|
| 15 |
-
model="gpt-3.5-turbo", # 对话模型的名称
|
| 16 |
-
messages=history_openai_format,
|
| 17 |
-
temperature=1, # 值在[0,1]之间,越大表示回复越具有不确定性
|
| 18 |
-
max_tokens=600, # 回复最大的字符数
|
| 19 |
-
top_p=1,
|
| 20 |
-
frequency_penalty=0, # [-2,2]之间,该值越大则更倾向于产生不同的内容
|
| 21 |
-
presence_penalty=0, # [-2,2]之间,该值越大则更倾向于产生不同的内容
|
| 22 |
-
)
|
| 23 |
-
yield response.choices[0]['message']['content']
|
| 24 |
-
|
| 25 |
-
gr.ChatInterface(predict).queue().launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
from transformers import AutoTokenizer, AutoModel
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True)
|
| 5 |
+
model = AutoModel.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True).half().cuda()
|
| 6 |
+
model = model.eval()
|
| 7 |
+
response, history = model.chat(tokenizer, "你好", history=[])
|
| 8 |
+
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|