Futuresony commited on
Commit
e6bc483
·
verified ·
1 Parent(s): 1b31e5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
- from web import search # This will now use the `web` tool correctly
 
 
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 web search."""
23
- results = search(query) # This calls the web tool
24
- if results:
25
- return results[0] # Return first result
 
 
 
 
 
 
 
 
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):