kamran-r123 commited on
Commit
f78f29d
·
1 Parent(s): e6c11b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -3,6 +3,32 @@ import gradio as gr
3
 
4
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  def tokenize(text):
7
  return text
8
  # return tok.encode(text, add_special_tokens=False)
 
3
 
4
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
5
 
6
+ def search_url(search_query):
7
+ API_KEY = st.secrets['AIzaSyDseKKQCAUBmPidu_QapnpJCGLueDWYJbE']
8
+ SEARCH_ENGINE_ID = st.secrets['001ae9bf840514e61']
9
+
10
+ url = 'https://customsearch.googleapis.com/customsearch/v1'
11
+
12
+ params = {
13
+ 'q': search_query,
14
+ 'key': API_KEY,
15
+ 'cx': SEARCH_ENGINE_ID,
16
+ }
17
+
18
+ response = requests.get(url, params=params)
19
+
20
+ results = response.json()
21
+
22
+ # print(results)
23
+
24
+ if 'items' in results:
25
+ for i in range(min(5, len(results['items']))):
26
+ print(f"Link {i + 1}: {results['items'][i]['link']}")
27
+ return results['items'][:5]
28
+ else:
29
+ print("No search results found.")
30
+ return None
31
+
32
  def tokenize(text):
33
  return text
34
  # return tok.encode(text, add_special_tokens=False)