mgokg commited on
Commit
7145d29
·
verified ·
1 Parent(s): 7c17c33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -65,7 +65,15 @@ def ground_search(prompt):
65
  #print(response.text)
66
  return response.text
67
 
68
-
 
 
 
 
 
 
 
 
69
 
70
  #api_key = os.getenv('groq')
71
  google_api_key = os.getenv('google_search')
@@ -149,7 +157,7 @@ with gr.Blocks(css=custom_css) as demo:
149
  button = gr.Button("Senden")
150
 
151
  # Connect the button to the function
152
- button.click(fn=websearch, inputs=ort_input, outputs=details_output)
153
 
154
  # Launch the Gradio application
155
  demo.launch()
 
65
  #print(response.text)
66
  return response.text
67
 
68
+ def duckduckgo(search_term):
69
+ url = f"https://duckduckgo.com/api?q={search_term}"
70
+ try:
71
+ response = requests.get(url)
72
+ response.raise_for_status() # Raises HTTPError for bad responses
73
+ return response.text # Return the content of the response
74
+ except requests.exceptions.RequestException as e:
75
+ print(f"An error occurred: {e}")
76
+ return response.text
77
 
78
  #api_key = os.getenv('groq')
79
  google_api_key = os.getenv('google_search')
 
157
  button = gr.Button("Senden")
158
 
159
  # Connect the button to the function
160
+ button.click(fn=duckduckgo, inputs=ort_input, outputs=details_output)
161
 
162
  # Launch the Gradio application
163
  demo.launch()