Spaces:
Runtime error
Runtime error
Rivalcoder
commited on
Commit
·
6dd4fed
1
Parent(s):
5c2aee5
Add new Rules
Browse files
llm.py
CHANGED
@@ -89,26 +89,27 @@ def query_gemini(questions, contexts, max_retries=3):
|
|
89 |
for link, content in fetched_results.items():
|
90 |
if not content.startswith("ERROR"):
|
91 |
webresults += f"\n\nRetrieved from {link}:\n{content}"
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
112 |
|
113 |
# Prompt building
|
114 |
t0 = time.perf_counter()
|
@@ -139,8 +140,9 @@ Your job:
|
|
139 |
|
140 |
|
141 |
|
142 |
-
*IMPORTANT LANGUAGE RULE:*
|
143 |
- For EACH question, FIRST detect the language of that specific question.
|
|
|
144 |
- Then generate the answer in THAT SAME language, regardless of the languages used in other questions or in the provided context.
|
145 |
- If Given Questions Contains Two Malayalam and Two English Then You Should also Give Like Two Malayalam Questions answer in Malayalam and Two English Questions answer in English.** Mandatory to follow this rule strictly. **
|
146 |
- Context is Another Language from Question Convert Content TO Question Language And Gives Response in Question Language Only.(##Mandatory to follow this rule strictly.)
|
|
|
89 |
for link, content in fetched_results.items():
|
90 |
if not content.startswith("ERROR"):
|
91 |
webresults += f"\n\nRetrieved from {link}:\n{content}"
|
92 |
+
|
93 |
+
payload = {
|
94 |
+
"questions": questions,
|
95 |
+
"contexts": contexts,
|
96 |
+
"previousResults": "Search Result Datas from The Ai Agent With RealTime Data Access"
|
97 |
+
}
|
98 |
+
webhook_url = "https://hook.us2.make.com/wnsitnljjvqyk2p1d2htl5v1o8hrcodk"
|
99 |
+
|
100 |
+
|
101 |
+
try:
|
102 |
+
resp = requests.post(webhook_url, json=payload, timeout=15)
|
103 |
+
resp.raise_for_status()
|
104 |
+
print("Webhook raw response:", resp.text)
|
105 |
+
webhook_response = resp.json()
|
106 |
+
enriched_context = webhook_response.get("enriched_context", "")
|
107 |
+
except Exception as e:
|
108 |
+
print(f"Webhook call failed: {e}")
|
109 |
+
enriched_context = "\n\n".join(contexts)
|
110 |
+
else:
|
111 |
+
print("⚠️ No URLs found — skipping agent/webhook call.")
|
112 |
+
enriched_context = "\n\n".join(contexts)
|
113 |
|
114 |
# Prompt building
|
115 |
t0 = time.perf_counter()
|
|
|
140 |
|
141 |
|
142 |
|
143 |
+
*IMPORTANT LANGUAGE RULE:*(Mandatory to follow this rule strictly)
|
144 |
- For EACH question, FIRST detect the language of that specific question.
|
145 |
+
- If Context is Different From The Input Question Lnaguage Then Convert The Context Language To The Question Language And Give Response In Question Language Only.(***Completely Mandatory to follow this rule strictly.***)
|
146 |
- Then generate the answer in THAT SAME language, regardless of the languages used in other questions or in the provided context.
|
147 |
- If Given Questions Contains Two Malayalam and Two English Then You Should also Give Like Two Malayalam Questions answer in Malayalam and Two English Questions answer in English.** Mandatory to follow this rule strictly. **
|
148 |
- Context is Another Language from Question Convert Content TO Question Language And Gives Response in Question Language Only.(##Mandatory to follow this rule strictly.)
|