Ashhar commited on
Commit
1a5d173
·
1 Parent(s): 56da5e1

search google more often

Browse files
Files changed (4) hide show
  1. app.py +3 -1
  2. constants.py +4 -36
  3. soup_dump.html +0 -0
  4. tools/tools.py +5 -2
app.py CHANGED
@@ -69,6 +69,8 @@ st.set_page_config(
69
  page_icon=C.AI_ICON,
70
  )
71
 
 
 
72
 
73
  def __isInvalidResponse(response: str):
74
  if len(re.findall(r'\n((?!http)[a-z])', response)) > 3 and "```" not in response:
@@ -285,7 +287,7 @@ def predict(model: str = None):
285
  response = client.chat.completions.create(
286
  model=model,
287
  messages=messagesFormatted,
288
- temperature=0.7,
289
  max_tokens=4000,
290
  stream=False,
291
  tools=tools
 
69
  page_icon=C.AI_ICON,
70
  )
71
 
72
+ st.markdown('<link rel="manifest" href="manifest.json">', unsafe_allow_html=True)
73
+
74
 
75
  def __isInvalidResponse(response: str):
76
  if len(re.findall(r'\n((?!http)[a-z])', response)) > 3 and "```" not in response:
 
287
  response = client.chat.completions.create(
288
  model=model,
289
  messages=messagesFormatted,
290
+ temperature=0.6,
291
  max_tokens=4000,
292
  stream=False,
293
  tools=tools
constants.py CHANGED
@@ -1,46 +1,16 @@
1
  JSON_SEPARATOR = ">>>>"
2
  EXCEPTION_KEYWORD = "<<EXCEPTION>>"
3
 
4
- SYSTEM_MSG = f"""
5
- => Context:
6
-
7
-
8
- -----
9
- => Key Points:
10
-
11
- -----
12
- => Format & Syntax:
13
- Whenever any of the below rules are satisfied, then append this exact keyword "{JSON_SEPARATOR}" to your FINAL response, and only AFTER this, append a JSON as described in the matching rule below.
14
- Apply at most one rule at a time, the most relevant one.
15
- Do not write anything after the JSON
16
-
17
- - Rule 1: If your response has multiple numbered options to choose from, append JSON in this format (alway check for this rule):
18
- ```
19
- {{
20
- "options": [{{ "id": "1", "label": "Option 1"}}, {{ "id": "2", "label": "Option 2"}}]
21
- }}
22
- ```
23
- Do not write "Choose one of the options below:"
24
- Keep options to less than 5.
25
-
26
-
27
- ------
28
- => Task Definition:
29
-
30
-
31
- """
32
 
33
  SYSTEM_MSG = f"""
34
  => Instructions:
35
  You're a helpful assistant who tries to answer as accurately as possible. Always add supporting details wherever possible AFTER the primary answer.
36
- If a query is not in past tense, search google.
37
  --------
38
 
39
  => Rules:
40
- ## Rule 1:
41
- - If you don't know an answer or are not sure if it's correct and latest, then you search google and collect search results.
42
- - You then read through all the google search results, and generate the answer.
43
- - You return the final answer (before Questions JSON) in this format (each point should be in a new line):
44
  {{Generated Answer}}
45
  <Brief details/context about the answer>
46
  \n-------
@@ -49,9 +19,7 @@ If a query is not in past tense, search google.
49
  - Citation 1 with URL
50
  - Citation 2 with URL
51
  - ...
52
-
53
- ## Rule 2:
54
- - If you know the answer and are sure that it's correct and up-to-date, return the answer with details supporting the answer.
55
  --------
56
 
57
  => Response Format:
 
1
  JSON_SEPARATOR = ">>>>"
2
  EXCEPTION_KEYWORD = "<<EXCEPTION>>"
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  SYSTEM_MSG = f"""
6
  => Instructions:
7
  You're a helpful assistant who tries to answer as accurately as possible. Always add supporting details wherever possible AFTER the primary answer.
 
8
  --------
9
 
10
  => Rules:
11
+ - You ALWAYS search google and collect search results before answering.
12
+ - You then read through all the google search results, give them extremely high importance, and then use it to generate the answer.
13
+ - You then return the final answer (before Questions JSON) in this format (each point should be in a new line):
 
14
  {{Generated Answer}}
15
  <Brief details/context about the answer>
16
  \n-------
 
19
  - Citation 1 with URL
20
  - Citation 2 with URL
21
  - ...
22
+ - If you have even slightest of doubt, always search google.
 
 
23
  --------
24
 
25
  => Response Format:
soup_dump.html CHANGED
The diff for this file is too large to render. See raw diff
 
tools/tools.py CHANGED
@@ -8,7 +8,10 @@ load_dotenv()
8
 
9
  def getGoogleSearchResults(query: str):
10
  startTime = time.time()
11
- results = WS.scrapeGoogleSearch(query)
 
 
 
12
  timeTaken = time.time() - startTime
13
  return {
14
  "response": results,
@@ -26,7 +29,7 @@ toolsInfo = {
26
  "type": "function",
27
  "function": {
28
  "name": "getGoogleSearchResults",
29
- "description": "Get google search results for a given query",
30
  "parameters": {
31
  "type": "object",
32
  "properties": {
 
8
 
9
  def getGoogleSearchResults(query: str):
10
  startTime = time.time()
11
+ if query:
12
+ results = WS.scrapeGoogleSearch(query)
13
+ else:
14
+ results = ""
15
  timeTaken = time.time() - startTime
16
  return {
17
  "response": results,
 
29
  "type": "function",
30
  "function": {
31
  "name": "getGoogleSearchResults",
32
+ "description": "Search google and return search results for a given query",
33
  "parameters": {
34
  "type": "object",
35
  "properties": {