Spaces:
Running
Running
Commit ·
f67c348
1
Parent(s): b11491b
ActionType
Browse files- inference.py +3 -3
- server/second_brain_env_environment.py +7 -8
inference.py
CHANGED
|
@@ -178,9 +178,9 @@ def get_agent_action(
|
|
| 178 |
print(f"[DEBUG] LLM parse error: {exc}", flush=True)
|
| 179 |
# Fallback actions per task
|
| 180 |
fallbacks = {
|
| 181 |
-
"note_categorization": SecondBrainAction(action_type=
|
| 182 |
-
"memory_retrieval": SecondBrainAction(action_type=
|
| 183 |
-
"knowledge_synthesis": SecondBrainAction(action_type=
|
| 184 |
}
|
| 185 |
return fallbacks[task_name]
|
| 186 |
|
|
|
|
| 178 |
print(f"[DEBUG] LLM parse error: {exc}", flush=True)
|
| 179 |
# Fallback actions per task
|
| 180 |
fallbacks = {
|
| 181 |
+
"note_categorization": SecondBrainAction(action_type=ActionType.categorize, content="work"),
|
| 182 |
+
"memory_retrieval": SecondBrainAction(action_type=ActionType.retrieve, content="important note"),
|
| 183 |
+
"knowledge_synthesis": SecondBrainAction(action_type=ActionType.synthesize, content="key information"),
|
| 184 |
}
|
| 185 |
return fallbacks[task_name]
|
| 186 |
|
server/second_brain_env_environment.py
CHANGED
|
@@ -7,7 +7,6 @@ from typing import Any, Dict, List, Optional
|
|
| 7 |
from uuid import uuid4
|
| 8 |
|
| 9 |
from openenv.core.env_server.interfaces import Environment
|
| 10 |
-
from models import SecondBrainState
|
| 11 |
|
| 12 |
# We import models relative to the server's working directory
|
| 13 |
import sys, os
|
|
@@ -132,10 +131,10 @@ class SecondBrainEnvironment(Environment):
|
|
| 132 |
current_note = self._notes_queue[self._current_note_idx]
|
| 133 |
correct = current_note["correct_category"]
|
| 134 |
|
| 135 |
-
if action.action_type ==
|
| 136 |
reward = 0.0
|
| 137 |
feedback = f"Skipped. Correct category was '{correct}'."
|
| 138 |
-
elif action.action_type ==
|
| 139 |
if action.content.strip().lower() == correct:
|
| 140 |
reward = 0.10
|
| 141 |
self._correct_count += 1
|
|
@@ -176,7 +175,7 @@ class SecondBrainEnvironment(Environment):
|
|
| 176 |
|
| 177 |
current_q = self._questions_queue[self._current_q_idx]
|
| 178 |
|
| 179 |
-
if action.action_type ==
|
| 180 |
query = action.content
|
| 181 |
# Score all KB notes against the query
|
| 182 |
scored = []
|
|
@@ -235,7 +234,7 @@ class SecondBrainEnvironment(Environment):
|
|
| 235 |
remaining=remaining,
|
| 236 |
)
|
| 237 |
|
| 238 |
-
elif action.action_type ==
|
| 239 |
self._retrieval_scores.append(0.0)
|
| 240 |
self._current_q_idx += 1
|
| 241 |
done = self._current_q_idx >= len(self._questions_queue)
|
|
@@ -269,7 +268,7 @@ class SecondBrainEnvironment(Environment):
|
|
| 269 |
|
| 270 |
current_q = self._questions_queue[self._current_q_idx]
|
| 271 |
|
| 272 |
-
if action.action_type ==
|
| 273 |
# Agent is collecting relevant notes before synthesizing
|
| 274 |
query = action.content
|
| 275 |
scored = []
|
|
@@ -300,7 +299,7 @@ class SecondBrainEnvironment(Environment):
|
|
| 300 |
remaining=len(self._questions_queue) - self._current_q_idx,
|
| 301 |
)
|
| 302 |
|
| 303 |
-
elif action.action_type ==
|
| 304 |
answer = action.content.lower()
|
| 305 |
expected = current_q["expected_insight"].lower()
|
| 306 |
themes = current_q["key_themes"]
|
|
@@ -359,7 +358,7 @@ class SecondBrainEnvironment(Environment):
|
|
| 359 |
remaining=len(self._questions_queue) - self._current_q_idx,
|
| 360 |
)
|
| 361 |
|
| 362 |
-
elif action.action_type ==
|
| 363 |
self._synthesis_scores.append(0.0)
|
| 364 |
self._collected_note_ids = []
|
| 365 |
self._current_q_idx += 1
|
|
|
|
| 7 |
from uuid import uuid4
|
| 8 |
|
| 9 |
from openenv.core.env_server.interfaces import Environment
|
|
|
|
| 10 |
|
| 11 |
# We import models relative to the server's working directory
|
| 12 |
import sys, os
|
|
|
|
| 131 |
current_note = self._notes_queue[self._current_note_idx]
|
| 132 |
correct = current_note["correct_category"]
|
| 133 |
|
| 134 |
+
if action.action_type == ActionType.skip:
|
| 135 |
reward = 0.0
|
| 136 |
feedback = f"Skipped. Correct category was '{correct}'."
|
| 137 |
+
elif action.action_type == ActionType.categorize:
|
| 138 |
if action.content.strip().lower() == correct:
|
| 139 |
reward = 0.10
|
| 140 |
self._correct_count += 1
|
|
|
|
| 175 |
|
| 176 |
current_q = self._questions_queue[self._current_q_idx]
|
| 177 |
|
| 178 |
+
if action.action_type == ActionType.retrieve:
|
| 179 |
query = action.content
|
| 180 |
# Score all KB notes against the query
|
| 181 |
scored = []
|
|
|
|
| 234 |
remaining=remaining,
|
| 235 |
)
|
| 236 |
|
| 237 |
+
elif action.action_type == ActionType.skip:
|
| 238 |
self._retrieval_scores.append(0.0)
|
| 239 |
self._current_q_idx += 1
|
| 240 |
done = self._current_q_idx >= len(self._questions_queue)
|
|
|
|
| 268 |
|
| 269 |
current_q = self._questions_queue[self._current_q_idx]
|
| 270 |
|
| 271 |
+
if action.action_type == ActionType.retrieve:
|
| 272 |
# Agent is collecting relevant notes before synthesizing
|
| 273 |
query = action.content
|
| 274 |
scored = []
|
|
|
|
| 299 |
remaining=len(self._questions_queue) - self._current_q_idx,
|
| 300 |
)
|
| 301 |
|
| 302 |
+
elif action.action_type == ActionType.synthesize:
|
| 303 |
answer = action.content.lower()
|
| 304 |
expected = current_q["expected_insight"].lower()
|
| 305 |
themes = current_q["key_themes"]
|
|
|
|
| 358 |
remaining=len(self._questions_queue) - self._current_q_idx,
|
| 359 |
)
|
| 360 |
|
| 361 |
+
elif action.action_type == ActionType.skip:
|
| 362 |
self._synthesis_scores.append(0.0)
|
| 363 |
self._collected_note_ids = []
|
| 364 |
self._current_q_idx += 1
|