Spaces:
Sleeping
Sleeping
Commit ·
7b3dbf5
1
Parent(s): a8d7d80
Remove conversation history from LLM context to reduce tokens
Browse files- prompts.py +0 -10
- reasoning_engine.py +2 -10
prompts.py
CHANGED
|
@@ -908,16 +908,6 @@ def build_compact_context(context: Dict) -> str:
|
|
| 908 |
if concerns and isinstance(concerns, list):
|
| 909 |
lines.append(f"[CONCERNS] " + ", ".join(str(c)[:30] for c in concerns[:3]))
|
| 910 |
|
| 911 |
-
# --- Conversation History (for follow-ups) ---
|
| 912 |
-
conv = context.get("conversation_history", [])
|
| 913 |
-
if conv:
|
| 914 |
-
lines.append(f"[CONV] {len(conv)} prior turns")
|
| 915 |
-
if len(conv) > 0:
|
| 916 |
-
last = conv[-1]
|
| 917 |
-
role = last.get("role", "")
|
| 918 |
-
content = last.get("content", "")[:50]
|
| 919 |
-
lines.append(f" Last: {role}: {content}...")
|
| 920 |
-
|
| 921 |
return "\n".join(lines) if lines else "No data"
|
| 922 |
|
| 923 |
|
|
|
|
| 908 |
if concerns and isinstance(concerns, list):
|
| 909 |
lines.append(f"[CONCERNS] " + ", ".join(str(c)[:30] for c in concerns[:3]))
|
| 910 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 911 |
return "\n".join(lines) if lines else "No data"
|
| 912 |
|
| 913 |
|
reasoning_engine.py
CHANGED
|
@@ -372,16 +372,8 @@ class ReasoningEngine:
|
|
| 372 |
persona = context.get("persona", {}) if context else {}
|
| 373 |
persona_instructions = persona.get("instructions", "Provide clear, helpful farming advice.")
|
| 374 |
|
| 375 |
-
#
|
| 376 |
-
|
| 377 |
-
if conv_history:
|
| 378 |
-
history_text = "Recent conversation:\n"
|
| 379 |
-
for turn in conv_history[-3:]:
|
| 380 |
-
role = turn.get("role", "")
|
| 381 |
-
content = turn.get("content", "")[:100]
|
| 382 |
-
history_text += f" {role.capitalize()}: {content}\n"
|
| 383 |
-
else:
|
| 384 |
-
history_text = "This is the first message in the conversation."
|
| 385 |
|
| 386 |
# Format zone context
|
| 387 |
zone_data = context.get("zone_analysis", {}) if context else {}
|
|
|
|
| 372 |
persona = context.get("persona", {}) if context else {}
|
| 373 |
persona_instructions = persona.get("instructions", "Provide clear, helpful farming advice.")
|
| 374 |
|
| 375 |
+
# Conversation history disabled to reduce token usage
|
| 376 |
+
history_text = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
|
| 378 |
# Format zone context
|
| 379 |
zone_data = context.get("zone_analysis", {}) if context else {}
|