Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,50 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List , Tuple , Union
|
2 |
+
from web_ui import WebUI
|
3 |
+
import math
|
4 |
+
import os
|
5 |
|
6 |
+
from qwen_agent.agents import Assistant
|
7 |
+
from qwen_agent.gui.gradio import gr
|
8 |
+
|
9 |
+
def app_gui ():
|
10 |
+
# Define the agent
|
11 |
+
bot = Assistant(llm={
|
12 |
+
'model' : os.environ.get( "MODELNAME" ),
|
13 |
+
'model_type' : 'qwen_dashscope' ,
|
14 |
+
'generate_cfg' : {
|
15 |
+
'max_input_tokens' : 32768 ,
|
16 |
+
'max_retries' : 10 ,
|
17 |
+
'temperature' : float (os.environ.get( "T" , 0.001 )),
|
18 |
+
'repetition_penalty' : float (os.environ.get( "R" , 1.0 )),
|
19 |
+
"top_k" : int (os.environ.get( "K" , 20 )),
|
20 |
+
"top_p" : float (os.environ.get( "P" , 0.8 )),
|
21 |
+
}},
|
22 |
+
name = 'QwQ-32B-preview' ,
|
23 |
+
description= 'QwQ-32B-Preview is an experimental research model developed by the Qwen Team, focused on advancing AI reasoning capabilities. As a preview release, it demonstrates promising analytical abilities while having several important limitations such as code switching and recursive reasoning loops. Only single-turn queries are supported in this demo.' ,
|
24 |
+
system_message= 'You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step.' ,
|
25 |
+
rag_cfg={ 'max_ref_token' : 32768 , 'rag_searchers' : []},
|
26 |
+
)
|
27 |
+
chatbot_config = {
|
28 |
+
'input.placeholder' : "Type \"/clear\" to clear the history" ,
|
29 |
+
'verbose' : True ,
|
30 |
+
'prompt.suggestions' : [
|
31 |
+
{
|
32 |
+
'text' : 'How many r in strawberry'
|
33 |
+
},
|
34 |
+
{
|
35 |
+
'text' : 'Find the least odd prime factor of $2019^8+1$.'
|
36 |
+
},
|
37 |
+
{
|
38 |
+
'text' : '''Mr. S, Mr. P, and Mr. Q know that there are 16 playing cards in the drawer of the table: A, Q, 4 of hearts, J, 8, 4, 2, 7, 3 of spades, K, Q, 5, 4, 6 of clubs, A, 5 of diamonds. Professor John picked a card from the 16 cards and told Mr. P the number of points on the card and Mr. Q the suit of the card. At this time, Professor John asked Mr. P and Mr. Q: Can you infer what card this is from the known number of points or suit? So, Mr. S heard the following conversation:
|
39 |
+
Mr. P: I don’t know this card.
|
40 |
+
Mr. Q: I know you don’t know this card.
|
41 |
+
Mr. P: Now I know this card.
|
42 |
+
Mr. Q: I know that too.
|
43 |
+
Please tell me: What card is this? '''
|
44 |
+
},
|
45 |
+
]
|
46 |
+
}
|
47 |
+
WebUI(bot, chatbot_config=chatbot_config).run(concurrency_limit= 80)
|
48 |
+
|
49 |
+
if __name__ == '__main__' :
|
50 |
+
app_gui()
|