Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
-
from
|
|
|
|
|
4 |
|
5 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
6 |
|
@@ -19,10 +21,18 @@ def is_uncertain(question, response):
|
|
19 |
return False
|
20 |
|
21 |
def google_search(query):
|
22 |
-
"""Fetch search results using
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return "Sorry, I couldn't find an answer on Google."
|
27 |
|
28 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
from serpapi import GoogleSearch # Import SerpAPI
|
4 |
+
|
5 |
+
SERPAPI_KEY = "your_serpapi_key_here" # Replace with your API key
|
6 |
|
7 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
8 |
|
|
|
21 |
return False
|
22 |
|
23 |
def google_search(query):
|
24 |
+
"""Fetch search results using SerpAPI."""
|
25 |
+
params = {
|
26 |
+
"q": query,
|
27 |
+
"hl": "en",
|
28 |
+
"gl": "us",
|
29 |
+
"api_key": SERPAPI_KEY
|
30 |
+
}
|
31 |
+
search = GoogleSearch(params)
|
32 |
+
results = search.get_dict()
|
33 |
+
|
34 |
+
if "organic_results" in results:
|
35 |
+
return results["organic_results"][0]["snippet"] # First search result
|
36 |
return "Sorry, I couldn't find an answer on Google."
|
37 |
|
38 |
def respond(message, history, system_message, max_tokens, temperature, top_p):
|