Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,16 @@ import json
|
|
9 |
import groq
|
10 |
import os
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
custom_css = """
|
13 |
#md {
|
14 |
-
height:
|
15 |
font-size: 30px;
|
16 |
-
background: #
|
17 |
padding: 20px;
|
18 |
color: white;
|
19 |
border: 1 px solid white;
|
@@ -21,18 +26,24 @@ custom_css = """
|
|
21 |
}
|
22 |
"""
|
23 |
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
-
def
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
def llm(message):
|
38 |
message = f"return a json object with the keys: name,email,phone,website \n the values can be found here, leave blank if value is not available:\n {message} \n return a json object only. no text, no explanaition"
|
@@ -48,6 +59,16 @@ def llm(message):
|
|
48 |
except Exception as e:
|
49 |
return f"Error in response generation: {str(e)}"
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
def list_of_clubs(ort):
|
52 |
base_url = "https://vereine-in-deutschland.net"
|
53 |
all_links_text = []
|
@@ -89,7 +110,12 @@ def process_ort(ort):
|
|
89 |
links_text = list_of_clubs(ort)
|
90 |
return links_text
|
91 |
vereine = []
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
93 |
for verein in links_text:
|
94 |
client = Client("mgokg/gemini-2.0-flash-exp")
|
95 |
result = client.predict(
|
@@ -127,7 +153,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
127 |
button = gr.Button("Senden")
|
128 |
|
129 |
# Connect the button to the function
|
130 |
-
button.click(fn=
|
131 |
|
132 |
# Launch the Gradio application
|
133 |
demo.launch()
|
|
|
9 |
import groq
|
10 |
import os
|
11 |
|
12 |
+
google_api_key = os.getenv('google_search')
|
13 |
+
API_URL = "https://blavken-flowiseblav.hf.space/api/v1/prediction/fbc118dc-ec00-4b59-acff-600648958be3"
|
14 |
+
api_key = os.getenv('groq')
|
15 |
+
client = groq.Client(api_key=api_key)
|
16 |
+
|
17 |
custom_css = """
|
18 |
#md {
|
19 |
+
height: 200px;
|
20 |
font-size: 30px;
|
21 |
+
background: #121212;
|
22 |
padding: 20px;
|
23 |
color: white;
|
24 |
border: 1 px solid white;
|
|
|
26 |
}
|
27 |
"""
|
28 |
|
29 |
+
def query(payload):
|
30 |
+
response = requests.post(API_URL, json=payload)
|
31 |
+
return response.json()
|
32 |
|
33 |
+
def google_search(payloads):
|
34 |
+
output = query({
|
35 |
+
"question": f"{payloads}",
|
36 |
+
})
|
37 |
+
print(output)
|
38 |
+
#return result_text
|
39 |
+
|
40 |
+
# Formuliere die Antwort
|
41 |
+
#search_query = f"{payloads} antworte kurz und knapp. antworte auf deutsch. du findest die antwort hier:\n {output}"
|
42 |
+
#result = predict(search_query)
|
43 |
+
texte=""
|
44 |
+
for o in output:
|
45 |
+
texte +=o
|
46 |
+
return texte
|
47 |
|
48 |
def llm(message):
|
49 |
message = f"return a json object with the keys: name,email,phone,website \n the values can be found here, leave blank if value is not available:\n {message} \n return a json object only. no text, no explanaition"
|
|
|
59 |
except Exception as e:
|
60 |
return f"Error in response generation: {str(e)}"
|
61 |
|
62 |
+
def qwen(jsondata):
|
63 |
+
client = Client("Qwen/Qwen2.5-72B-Instruct")
|
64 |
+
result = client.predict(
|
65 |
+
query= f"return valid json \n {jsondata}",
|
66 |
+
history=[],
|
67 |
+
system="You are Qwen, created by Alibaba Cloud. You are a helpful assistant.",
|
68 |
+
api_name="/model_chat"
|
69 |
+
)
|
70 |
+
return result
|
71 |
+
|
72 |
def list_of_clubs(ort):
|
73 |
base_url = "https://vereine-in-deutschland.net"
|
74 |
all_links_text = []
|
|
|
110 |
links_text = list_of_clubs(ort)
|
111 |
return links_text
|
112 |
vereine = []
|
113 |
+
for verein in links_text:
|
114 |
+
prompt=f"impressum {verein}",
|
115 |
+
result = google_search(prompt)
|
116 |
+
json_data = llm(result)
|
117 |
+
vereine.append(result)
|
118 |
+
|
119 |
for verein in links_text:
|
120 |
client = Client("mgokg/gemini-2.0-flash-exp")
|
121 |
result = client.predict(
|
|
|
153 |
button = gr.Button("Senden")
|
154 |
|
155 |
# Connect the button to the function
|
156 |
+
button.click(fn=google_search, inputs=ort_input, outputs=details_output)
|
157 |
|
158 |
# Launch the Gradio application
|
159 |
demo.launch()
|