Update run.py
Browse files
run.py
CHANGED
@@ -150,33 +150,31 @@ def js_code():
|
|
150 |
</script>
|
151 |
"""
|
152 |
|
153 |
-
def submit_url(
|
154 |
global global_url
|
|
|
|
|
155 |
global_url = url # Save the URL in the global variable
|
156 |
print(f"Received URL: {url}")
|
157 |
-
return
|
158 |
|
159 |
# Define the Gradio interface
|
160 |
def create_interface():
|
161 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
share=True
|
180 |
)
|
181 |
|
182 |
-
|
|
|
|
|
|
|
|
150 |
</script>
|
151 |
"""
|
152 |
|
153 |
+
def submit_url(request):
|
154 |
global global_url
|
155 |
+
data = json.loads(request.body.decode("utf-8"))
|
156 |
+
url = data.get("url")
|
157 |
global_url = url # Save the URL in the global variable
|
158 |
print(f"Received URL: {url}")
|
159 |
+
return {"status": "success"}
|
160 |
|
161 |
# Define the Gradio interface
|
162 |
def create_interface():
|
163 |
+
# Create a basic gr.Interface to include the JavaScript and handle URL submissions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
with gr.Blocks() as app:
|
165 |
gr.HTML(js_code) # Include the JavaScript in the app
|
166 |
+
gr.ChatInterface(
|
167 |
+
fn=response,
|
168 |
+
chatbot=gr.Chatbot(
|
169 |
+
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!"]],
|
170 |
+
render_markdown=True
|
171 |
+
),
|
172 |
+
title="German Studyhelper Chätti"
|
173 |
+
).launch(
|
174 |
share=True
|
175 |
)
|
176 |
|
177 |
+
# Launch the Gradio app with URL capturing
|
178 |
+
if __name__ == "__main__":
|
179 |
+
create_interface()
|
180 |
+
print("Interface up and running!")
|