Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,9 @@ import os
|
|
8 |
secreturl = os.environ.get('secret_url')
|
9 |
|
10 |
def parse_links(prompt):
|
11 |
-
#anfrage ='fill in the missing contact information. do not reference the json object. do not use html tags inside the json object. it must be valid json. do not return explanaitons or any other text. thanks for your efforts:)'
|
12 |
Name=prompt
|
|
|
13 |
anfrage ="""
|
14 |
instruction: you are a json expert and your job is extracting information from text, generating valid json and return a json object only. do not return any text. halte dich an das vorgegebene json schema.
|
15 |
prompt: fill in the missing contact information. do not reference the json object. do not use html tags inside the json object. do not return explanaitons or any other text. return a valid json object only.
|
@@ -21,9 +22,10 @@ def parse_links(prompt):
|
|
21 |
}
|
22 |
"""
|
23 |
try:
|
24 |
-
|
25 |
-
#url to api
|
26 |
url = secreturl
|
|
|
27 |
payload = {
|
28 |
"chatModel": {
|
29 |
"provider": "groq",
|
@@ -47,9 +49,6 @@ def parse_links(prompt):
|
|
47 |
}
|
48 |
|
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
|
@@ -61,7 +60,8 @@ def parse_links(prompt):
|
|
61 |
return {"error": str(e)}
|
62 |
except Exception as e:
|
63 |
return {"error": str(e)}
|
64 |
-
|
|
|
65 |
def clear():
|
66 |
clear=""
|
67 |
return clear
|
@@ -71,11 +71,11 @@ with gr.Blocks() as demo:
|
|
71 |
gr.Markdown("# Perplexica WebSearch")
|
72 |
ort_input = gr.Textbox(label="Prompt", placeholder="prompt", value="Aero Club Bamberg e.V.")
|
73 |
links_output = gr.Textbox(label="Antwort")
|
|
|
74 |
with gr.Row():
|
75 |
clearbutton = gr.Button("clear")
|
76 |
-
# Button zum Starten der Parsung
|
77 |
button = gr.Button("senden")
|
78 |
-
|
79 |
button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
|
80 |
clearbutton.click(fn=clear, inputs=[], outputs=links_output)
|
81 |
|
|
|
8 |
secreturl = os.environ.get('secret_url')
|
9 |
|
10 |
def parse_links(prompt):
|
11 |
+
#anfrage ='fill in the missing contact information. do not reference the json object. do not use html tags inside the json object. it must be valid json. do not return explanaitons or any other text. thanks for your efforts:)'
|
12 |
Name=prompt
|
13 |
+
#suite your prompt to your needs
|
14 |
anfrage ="""
|
15 |
instruction: you are a json expert and your job is extracting information from text, generating valid json and return a json object only. do not return any text. halte dich an das vorgegebene json schema.
|
16 |
prompt: fill in the missing contact information. do not reference the json object. do not use html tags inside the json object. do not return explanaitons or any other text. return a valid json object only.
|
|
|
22 |
}
|
23 |
"""
|
24 |
try:
|
25 |
+
#get Perplexica on github
|
26 |
+
#http:// url to perplexica api running inside a docker container. you may use certbot to issue a certificate for the perplexica webserver
|
27 |
url = secreturl
|
28 |
+
|
29 |
payload = {
|
30 |
"chatModel": {
|
31 |
"provider": "groq",
|
|
|
49 |
}
|
50 |
|
51 |
response = requests.post(url, json=payload, headers=headers)
|
|
|
|
|
|
|
52 |
ergebnis = response.json().get('message')
|
53 |
#ergebnis=gr.Markdown()
|
54 |
return ergebnis
|
|
|
60 |
return {"error": str(e)}
|
61 |
except Exception as e:
|
62 |
return {"error": str(e)}
|
63 |
+
|
64 |
+
#clear output
|
65 |
def clear():
|
66 |
clear=""
|
67 |
return clear
|
|
|
71 |
gr.Markdown("# Perplexica WebSearch")
|
72 |
ort_input = gr.Textbox(label="Prompt", placeholder="prompt", value="Aero Club Bamberg e.V.")
|
73 |
links_output = gr.Textbox(label="Antwort")
|
74 |
+
|
75 |
with gr.Row():
|
76 |
clearbutton = gr.Button("clear")
|
|
|
77 |
button = gr.Button("senden")
|
78 |
+
|
79 |
button.click(fn=parse_links, inputs=ort_input, outputs=links_output)
|
80 |
clearbutton.click(fn=clear, inputs=[], outputs=links_output)
|
81 |
|