Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -75,6 +75,10 @@ def format_prompt(user_prompt, chat_history):
|
|
75 |
return prompt
|
76 |
|
77 |
# Model inference function
|
|
|
|
|
|
|
|
|
78 |
def model_inference(prompt, web_search):
|
79 |
for response in fetch_response(prompt, web_search):
|
80 |
yield response
|
@@ -108,20 +112,15 @@ def fetch_response(prompt, web_search):
|
|
108 |
yield output
|
109 |
|
110 |
# Create a chatbot interface with a Fetch button
|
111 |
-
def start_inference(prompt, web_search):
|
112 |
-
for response in model_inference(prompt, web_search):
|
113 |
-
return response
|
114 |
-
|
115 |
chatbot = gr.Interface(
|
116 |
fn=start_inference,
|
117 |
inputs=[
|
118 |
gr.Textbox(label="User Prompt", placeholder="Enter your prompt here..."),
|
119 |
-
gr.Checkbox(label="Enable Web Search",
|
120 |
-
"button"
|
121 |
],
|
122 |
outputs=gr.Textbox(label="Response", placeholder="Responses will appear here..."),
|
123 |
live=True
|
124 |
)
|
125 |
|
126 |
# Launch the Gradio interface
|
127 |
-
chatbot.launch(
|
|
|
75 |
return prompt
|
76 |
|
77 |
# Model inference function
|
78 |
+
def start_inference(prompt):
|
79 |
+
web_search = prompt.pop("Enable Web Search", False)
|
80 |
+
return next(model_inference(prompt["User Prompt"], web_search))
|
81 |
+
|
82 |
def model_inference(prompt, web_search):
|
83 |
for response in fetch_response(prompt, web_search):
|
84 |
yield response
|
|
|
112 |
yield output
|
113 |
|
114 |
# Create a chatbot interface with a Fetch button
|
|
|
|
|
|
|
|
|
115 |
chatbot = gr.Interface(
|
116 |
fn=start_inference,
|
117 |
inputs=[
|
118 |
gr.Textbox(label="User Prompt", placeholder="Enter your prompt here..."),
|
119 |
+
gr.Checkbox(label="Enable Web Search", default=False, label_for_default="Search Web", label_for_changed="Searching Web")
|
|
|
120 |
],
|
121 |
outputs=gr.Textbox(label="Response", placeholder="Responses will appear here..."),
|
122 |
live=True
|
123 |
)
|
124 |
|
125 |
# Launch the Gradio interface
|
126 |
+
chatbot.launch()
|