-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebserver.py
More file actions
37 lines (32 loc) · 1.29 KB
/
webserver.py
File metadata and controls
37 lines (32 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
model = ''
def seleceModel(modelName: str) -> str:
global model
model = modelName
# 调试
print(f"Model selected: {model}")
def echo(message: str, history: list) -> list:
return message
def main():
with gr.Blocks() as demo:
gr.Markdown("# A Simple AI Agent")
with gr.Row():
with gr.Column(scale=3):
gr.Markdown("### Select Your Model")
selModel = gr.Dropdown(choices=['ChatGPT o4-mini', 'QWen', 'DeepSeek R1'],
value='ChatGPT o4-mini',
label='Select Your Model')
chatbot = gr.ChatInterface(fn=echo,
type="messages",
examples=['Hello!', 'Hello! Good to see you!'])
with gr.Column(scale=3):
gr.Markdown("### Reasoning Process")
gr.Textbox(label="Reasoning Process", placeholder="Reasoning Process", interactive=False, lines=10)
selModel.change(fn=seleceModel,
inputs=selModel,
outputs=[])
demo.launch()
if __name__ == "__main__":
main()