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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|