Spaces:
Running
Running
Ashhar
commited on
Commit
•
b303bae
1
Parent(s):
cf0a10d
hinglish support
Browse files- app.py +8 -2
- constants.py +4 -8
app.py
CHANGED
@@ -257,6 +257,11 @@ def __getClaudeTools():
|
|
257 |
return claudeTools
|
258 |
|
259 |
|
|
|
|
|
|
|
|
|
|
|
260 |
def predict(model: str = None, attempts=0):
|
261 |
model = model or MODEL
|
262 |
|
@@ -303,8 +308,9 @@ def predict(model: str = None, attempts=0):
|
|
303 |
time.sleep(0.2)
|
304 |
return predict(model, attempts + 1)
|
305 |
else:
|
306 |
-
U.pprint("Switching to TOOLS_MODEL")
|
307 |
-
return predict(TOOLS_MODEL)
|
|
|
308 |
toolCalls = responseMessage.tool_calls
|
309 |
|
310 |
# U.pprint(f"{responseMessage=}")
|
|
|
257 |
return claudeTools
|
258 |
|
259 |
|
260 |
+
def __removeFunctionCall(response: str):
|
261 |
+
pattern = r'<function=getGoogleSearchResults>\{"query": ".*?"\}<function>'
|
262 |
+
return re.sub(pattern, '', response)
|
263 |
+
|
264 |
+
|
265 |
def predict(model: str = None, attempts=0):
|
266 |
model = model or MODEL
|
267 |
|
|
|
308 |
time.sleep(0.2)
|
309 |
return predict(model, attempts + 1)
|
310 |
else:
|
311 |
+
# U.pprint("Switching to TOOLS_MODEL")
|
312 |
+
# return predict(TOOLS_MODEL)
|
313 |
+
responseContent = __removeFunctionCall(responseContent)
|
314 |
toolCalls = responseMessage.tool_calls
|
315 |
|
316 |
# U.pprint(f"{responseMessage=}")
|
constants.py
CHANGED
@@ -4,8 +4,9 @@ EXCEPTION_KEYWORD = "<<EXCEPTION>>"
|
|
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 |
-
You make full use of available tools.
|
|
|
9 |
--------
|
10 |
|
11 |
=> Rules:
|
@@ -26,7 +27,7 @@ You make full use of available tools.
|
|
26 |
=> Response Format:
|
27 |
- Don't tell how you arrived at the answer.
|
28 |
- Make full use of markdown to format the answer better, like sub-headings, bold, italics, etc
|
29 |
-
-
|
30 |
- Append this exact keyword "{JSON_SEPARATOR}" to your FINAL response (after appending details and references, if any), and only AFTER this, append a JSON of possible Questions that the user might be interesed in (max 4) strictly in the format described below.
|
31 |
```
|
32 |
{{
|
@@ -35,11 +36,6 @@ You make full use of available tools.
|
|
35 |
```
|
36 |
"""
|
37 |
|
38 |
-
# """
|
39 |
-
# You can also use tools if needed.
|
40 |
-
# Always use the provided tools if you need to answer a question.
|
41 |
-
# If you think you don't know the answer, say "I don't know" or "I'm not sure".
|
42 |
-
# """
|
43 |
|
44 |
USER_ICON = "icons/man.png"
|
45 |
AI_ICON = "icons/survey.png"
|
|
|
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 |
+
- You make full use of available tools.
|
9 |
+
- If someone asks in Hindi or Hinglish, reply in Hinglish only.
|
10 |
--------
|
11 |
|
12 |
=> Rules:
|
|
|
27 |
=> Response Format:
|
28 |
- Don't tell how you arrived at the answer.
|
29 |
- Make full use of markdown to format the answer better, like sub-headings, bold, italics, etc
|
30 |
+
- DO NOT return <function=getGoogleSearchResults> in response content, instead send in tool call
|
31 |
- Append this exact keyword "{JSON_SEPARATOR}" to your FINAL response (after appending details and references, if any), and only AFTER this, append a JSON of possible Questions that the user might be interesed in (max 4) strictly in the format described below.
|
32 |
```
|
33 |
{{
|
|
|
36 |
```
|
37 |
"""
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
USER_ICON = "icons/man.png"
|
41 |
AI_ICON = "icons/survey.png"
|