Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,8 @@ def parse_links(prompt):
|
|
21 |
}
|
22 |
"""
|
23 |
try:
|
24 |
-
|
|
|
25 |
url = secreturl
|
26 |
payload = {
|
27 |
"chatModel": {
|
@@ -48,34 +49,22 @@ def parse_links(prompt):
|
|
48 |
response = requests.post(url, json=payload, headers=headers)
|
49 |
|
50 |
print(response.json())
|
51 |
-
|
52 |
-
#data = response.json()
|
53 |
-
# Extract the message
|
54 |
-
#ergebnis = data.get('message')
|
55 |
ergebnis = response.json().get('message')
|
56 |
#ergebnis=gr.Markdown()
|
57 |
return ergebnis
|
58 |
-
|
59 |
-
|
60 |
-
# Load the JSON part to validate it's correctly formatted
|
61 |
-
try:
|
62 |
-
data = json.loads(json_part)
|
63 |
-
print(json.dumps(data, indent=2))
|
64 |
-
return json.dumps(data, indent=2)
|
65 |
-
except json.JSONDecodeError as e:
|
66 |
-
print(f"Invalid JSON: {e}")
|
67 |
-
|
68 |
-
#return response.json().get('message')
|
69 |
-
# Rückgabe als Dictionary, um es mit gr.JSON kompatibel zu machen
|
70 |
#return {"body_text": body_text}
|
71 |
|
72 |
except requests.RequestException as e:
|
73 |
return {"error": str(e)}
|
74 |
except Exception as e:
|
75 |
return {"error": str(e)}
|
|
|
76 |
def clear():
|
77 |
-
|
78 |
-
return
|
79 |
|
80 |
# Erstelle die Gradio-Schnittstelle
|
81 |
with gr.Blocks() as demo:
|
@@ -88,6 +77,6 @@ with gr.Blocks() as demo:
|
|
88 |
button = gr.Button("senden")
|
89 |
# Verbinde den Button mit der Funktion
|
90 |
button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
|
91 |
-
clearbutton.click(fn=clear, inputs=
|
92 |
|
93 |
demo.launch()
|
|
|
21 |
}
|
22 |
"""
|
23 |
try:
|
24 |
+
|
25 |
+
#url to api of a self-hosted docker container with perplexica over http://
|
26 |
url = secreturl
|
27 |
payload = {
|
28 |
"chatModel": {
|
|
|
49 |
response = requests.post(url, json=payload, headers=headers)
|
50 |
|
51 |
print(response.json())
|
52 |
+
|
|
|
|
|
|
|
53 |
ergebnis = response.json().get('message')
|
54 |
#ergebnis=gr.Markdown()
|
55 |
return ergebnis
|
56 |
+
|
57 |
+
# return as Dictionary, for gr.JSON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
#return {"body_text": body_text}
|
59 |
|
60 |
except requests.RequestException as e:
|
61 |
return {"error": str(e)}
|
62 |
except Exception as e:
|
63 |
return {"error": str(e)}
|
64 |
+
|
65 |
def clear():
|
66 |
+
clear=""
|
67 |
+
return clear
|
68 |
|
69 |
# Erstelle die Gradio-Schnittstelle
|
70 |
with gr.Blocks() as demo:
|
|
|
77 |
button = gr.Button("senden")
|
78 |
# Verbinde den Button mit der Funktion
|
79 |
button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
|
80 |
+
clearbutton.click(fn=clear, inputs=inputs, outputs=outputs)
|
81 |
|
82 |
demo.launch()
|