Spaces:
Sleeping
Sleeping
EMMA commited on
Commit ·
6d4d2ca
1
Parent(s): 00f82e4
update code
Browse files- app.py +24 -1
- utils/prompt_utils.py +13 -0
app.py
CHANGED
|
@@ -254,7 +254,30 @@ def chatgpt_chat(prompt, system, history, gpt_config, api_index=0):
|
|
| 254 |
return "Error: No API Keys available."
|
| 255 |
|
| 256 |
client = get_gapgpt_client(api_keys[api_index])
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
except Exception as e:
|
| 260 |
print(f"Chat Error: {e}")
|
|
|
|
| 254 |
return "Error: No API Keys available."
|
| 255 |
|
| 256 |
client = get_gapgpt_client(api_keys[api_index])
|
| 257 |
+
|
| 258 |
+
print(
|
| 259 |
+
"\n[PROMPT DEBUG] outgoing messages BEGIN",
|
| 260 |
+
flush=True,
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
for i, msg in enumerate(message):
|
| 264 |
+
print(
|
| 265 |
+
f"[PROMPT DEBUG] message[{i}] role={msg.get('role')}",
|
| 266 |
+
flush=True,
|
| 267 |
+
)
|
| 268 |
+
print("[PROMPT DEBUG] content BEGIN", flush=True)
|
| 269 |
+
print(msg.get("content"), flush=True)
|
| 270 |
+
print("[PROMPT DEBUG] content END", flush=True)
|
| 271 |
+
|
| 272 |
+
print(
|
| 273 |
+
"[PROMPT DEBUG] outgoing messages END\n",
|
| 274 |
+
flush=True,
|
| 275 |
+
)
|
| 276 |
+
|
| 277 |
+
response = client.chat.completions.create(
|
| 278 |
+
messages=message,
|
| 279 |
+
**request,
|
| 280 |
+
)
|
| 281 |
|
| 282 |
except Exception as e:
|
| 283 |
print(f"Chat Error: {e}")
|
utils/prompt_utils.py
CHANGED
|
@@ -169,6 +169,19 @@ def build_prompt_with_search_memory_llamaindex(
|
|
| 169 |
|
| 170 |
# Process history
|
| 171 |
print("related_memos found:", len(related_memos) if related_memos else 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
history_summary = ""
|
| 174 |
if "overall_history" in user_memory:
|
|
|
|
| 169 |
|
| 170 |
# Process history
|
| 171 |
print("related_memos found:", len(related_memos) if related_memos else 0)
|
| 172 |
+
|
| 173 |
+
#-********************Debug*********************
|
| 174 |
+
print("[MEMORY DEBUG] category:", query_category, flush=True)
|
| 175 |
+
print(
|
| 176 |
+
"[MEMORY DEBUG] result type:",
|
| 177 |
+
type(related_memos).__name__,
|
| 178 |
+
flush=True,
|
| 179 |
+
)
|
| 180 |
+
print("[MEMORY DEBUG] retrieved content BEGIN", flush=True)
|
| 181 |
+
print(related_memos, flush=True)
|
| 182 |
+
print("[MEMORY DEBUG] retrieved content END", flush=True)
|
| 183 |
+
|
| 184 |
+
#-********************Debug*********************
|
| 185 |
|
| 186 |
history_summary = ""
|
| 187 |
if "overall_history" in user_memory:
|