Thiloid commited on
Commit
7a91d3f
·
verified ·
1 Parent(s): 5a5a41b

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +18 -12
run.py CHANGED
@@ -156,21 +156,27 @@ def submit_url(url: str):
156
  print(f"Received URL: {url}")
157
  return url
158
 
159
- with gr.Blocks() as chatbot:
160
- gr.HTML(js_code())
161
- chat_interface = gr.ChatInterface(
162
- response,
163
- chatbot2=gr.Chatbot(value=[[None, "Herzlich willkommen! Ich bin Chätti ein KI-basiertes Studienassistenzsystem, das für jede Anfrage die am besten Studieninformationen empfiehlt.<br>Erzähle mir, was du gerne tust!"]], render_markdown=True),
164
  title="German Studyhelper Chätti"
165
  )
166
 
167
- chatbot.launch(share=True)
168
-
169
- @gr.routes.post("/submit_url")
170
- async def process_url(request):
171
- data = await request.json()
172
- url = data.get("url", "")
173
  submit_url(url)
174
  return {"status": "success"}
175
 
176
- print("Interface up and running!")
 
 
 
 
 
 
 
 
 
156
  print(f"Received URL: {url}")
157
  return url
158
 
159
+ # Define the Gradio interface
160
+ def create_interface():
161
+ return gr.ChatInterface(
162
+ fn=response,
163
+ chatbot=gr.Chatbot(value=[[None, "Herzlich willkommen! Ich bin Chätti ein KI-basiertes Studienassistenzsystem, das für jede Anfrage die am besten Studieninformationen empfiehlt.<br>Erzähle mir, was du gerne tust!"]], render_markdown=True),
164
  title="German Studyhelper Chätti"
165
  )
166
 
167
+ # Define the route for handling URL submissions
168
+ def process_url(request):
169
+ data = json.loads(request.body.decode("utf-8"))
170
+ url = data.get("url")
 
 
171
  submit_url(url)
172
  return {"status": "success"}
173
 
174
+ # Launch the Gradio app with URL capturing
175
+ if __name__ == "__main__":
176
+ with gr.Blocks() as app:
177
+ gr.HTML(js_code) # Include the JavaScript in the app
178
+ create_interface().launch(
179
+ share=True
180
+ )
181
+
182
+ print("Interface up and running!")