jonaschua commited on
Commit
4ce392f
·
verified ·
1 Parent(s): 0ee8f2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -35
app.py CHANGED
@@ -103,43 +103,34 @@ def respond(message, history: list[tuple[str, str]], model, system_message, max_
103
  response += token
104
  yield response
105
 
106
- while mode == "text-to-text":
107
- demo = gr.ChatInterface(
 
 
 
 
108
  respond,
109
- stop_btn = "Stop generation",
110
- title="Ask me anything",
111
- description="Hi there! I am your friendly AI chatbot. Choose from different language models under the Additional Inputs tab below.",
112
- examples=[["Explain quantum computing"], ["Explain forex trading"], ["What is the capital of China?"], ["Make a poem about nature"]],
113
- additional_inputs=[
114
- gr.Dropdown(["DeepSeek-R1-Distill-Qwen-1.5B", "DeepSeek-R1-Distill-Qwen-32B", "Gemma-2-2b", "Gemma-7b", "Llama2-13b-chat", "Llama3-8b-Instruct", "Llama3.1-8b-Instruct", "Llama-3.2-11B-Vision-Instruct", "Microsoft-phi-2", "Mixtral-8x7B-Instruct", "Qwen2.5-Coder-32B-Instruct", "Zephyr-7b-beta"], label="Select Model"),
115
- gr.Textbox(value="You are a friendly and helpful Chatbot, be concise and straight to the point, avoid excessive reasoning.", label="System message"),
116
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
117
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
118
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
119
-
120
- ]
121
- )
122
-
123
- while mode == "image-to-text":
124
- demo = gr.ChatInterface(
125
  respond,
126
- stop_btn = "Stop generation",
127
- multimodal = True,
128
- title="Ask me anything",
129
- description="Hi there! I am your friendly AI chatbot. Choose from different language models under the Additional Inputs tab below.",
130
- examples=[["Explain quantum computing"], ["Explain forex trading"], ["What is the capital of China?"], ["Make a poem about nature"]],
131
- additional_inputs=[
132
- gr.Dropdown(["DeepSeek-R1-Distill-Qwen-1.5B", "DeepSeek-R1-Distill-Qwen-32B", "Gemma-2-2b", "Gemma-7b", "Llama2-13b-chat", "Llama3-8b-Instruct", "Llama3.1-8b-Instruct", "Llama-3.2-11B-Vision-Instruct", "Microsoft-phi-2", "Mixtral-8x7B-Instruct", "Qwen2.5-Coder-32B-Instruct", "Zephyr-7b-beta"], label="Select Model"),
133
- gr.Textbox(value="You are a friendly and helpful Chatbot, be concise and straight to the point, avoid excessive reasoning.", label="System message"),
134
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
135
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
136
- gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
137
-
138
- ],
139
-
140
- url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg",
141
- image = Image.open(requests.get(url, stream=True).raw)
142
- )
 
143
 
144
 
145
  if __name__ == "__main__":
 
103
  response += token
104
  yield response
105
 
106
+
107
+
108
+
109
+ demo = gr.ChatInterface(
110
+
111
+ if mode=="text-to-text":
112
  respond,
113
+ multimodal=False,
114
+ else:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  respond,
116
+ multimodal=True,
117
+ stop_btn = "Stop generation",
118
+ # multimodal = True,
119
+ title="Ask me anything",
120
+ description="Hi there! I am your friendly AI chatbot. Choose from different language models under the Additional Inputs tab below.",
121
+ examples=[["Explain quantum computing"], ["Explain forex trading"], ["What is the capital of China?"], ["Make a poem about nature"]],
122
+ additional_inputs=[
123
+ gr.Dropdown(["DeepSeek-R1-Distill-Qwen-1.5B", "DeepSeek-R1-Distill-Qwen-32B", "Gemma-2-2b", "Gemma-7b", "Llama2-13b-chat", "Llama3-8b-Instruct", "Llama3.1-8b-Instruct", "Llama-3.2-11B-Vision-Instruct", "Microsoft-phi-2", "Mixtral-8x7B-Instruct", "Qwen2.5-Coder-32B-Instruct", "Zephyr-7b-beta"], label="Select Model"),
124
+ gr.Textbox(value="You are a friendly and helpful Chatbot, be concise and straight to the point, avoid excessive reasoning.", label="System message"),
125
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
126
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
127
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
128
+
129
+ ],
130
+
131
+ url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg",
132
+ image = Image.open(requests.get(url, stream=True).raw)
133
+ )
134
 
135
 
136
  if __name__ == "__main__":