DJAYADEV commited on
Commit
e3379be
·
verified ·
1 Parent(s): 82cd281

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. server/rag_optimizer_environment.py +10 -5
server/rag_optimizer_environment.py CHANGED
@@ -9,6 +9,7 @@ Rag Optimizer Environment Implementation.
9
  The agent acts as a Data Engineer to un-block a broken RAG pipeline.
10
  """
11
 
 
12
  from uuid import uuid4
13
  from typing import Dict, Any, List
14
 
@@ -34,11 +35,10 @@ class RagOptimizerEnvironment(Environment):
34
 
35
  SUPPORTS_CONCURRENT_SESSIONS: bool = True
36
 
37
- def __init__(self):
38
- self._state = State(episode_id=str(uuid4()), step_count=0)
39
-
40
- # Initial messy knowledge base
41
- self.kb = {
42
  "doc_pricing_legacy": {
43
  "text": "Pricing for 2021: Enterprise tier is $1000/mo. Standard is $500/mo. All plans include 10 users.",
44
  "metadata": {"type": "pricing"}
@@ -68,6 +68,10 @@ class RagOptimizerEnvironment(Environment):
68
  **{f"doc_distractor_eng_{i}": {"text": f"Engineering architecture decision record {i}. We decided to use {['React', 'Postgres', 'Redis', 'Kafka'][i%4]} because of scaling concerns.", "metadata":{}} for i in range(10)},
69
  **{f"doc_distractor_random_{i}": {"text": f"Weekly team update notes. Nothing important here, just discussed the weather and the upcoming launch {i}.", "metadata":{}} for i in range(10)},
70
  }
 
 
 
 
71
 
72
  # Hidden test suite for the grader
73
  self.test_suite = [
@@ -106,6 +110,7 @@ class RagOptimizerEnvironment(Environment):
106
 
107
  def reset(self) -> RagOptimizerObservation:
108
  self._state = State(episode_id=str(uuid4()), step_count=0)
 
109
  return RagOptimizerObservation(
110
  message="RagOptimizerEnv Initialized. You have messy chunks in the KB. Resolve conflicts, add metadata tags to short tickets, and splinter monolithic files to win.",
111
  current_docs=self._get_kb_summary(),
 
9
  The agent acts as a Data Engineer to un-block a broken RAG pipeline.
10
  """
11
 
12
+ from copy import deepcopy
13
  from uuid import uuid4
14
  from typing import Dict, Any, List
15
 
 
35
 
36
  SUPPORTS_CONCURRENT_SESSIONS: bool = True
37
 
38
+ @staticmethod
39
+ def _build_initial_kb() -> Dict[str, Dict[str, Any]]:
40
+ """Construct a fresh KB snapshot for each new episode/reset."""
41
+ return {
 
42
  "doc_pricing_legacy": {
43
  "text": "Pricing for 2021: Enterprise tier is $1000/mo. Standard is $500/mo. All plans include 10 users.",
44
  "metadata": {"type": "pricing"}
 
68
  **{f"doc_distractor_eng_{i}": {"text": f"Engineering architecture decision record {i}. We decided to use {['React', 'Postgres', 'Redis', 'Kafka'][i%4]} because of scaling concerns.", "metadata":{}} for i in range(10)},
69
  **{f"doc_distractor_random_{i}": {"text": f"Weekly team update notes. Nothing important here, just discussed the weather and the upcoming launch {i}.", "metadata":{}} for i in range(10)},
70
  }
71
+
72
+ def __init__(self):
73
+ self._state = State(episode_id=str(uuid4()), step_count=0)
74
+ self.kb = deepcopy(self._build_initial_kb())
75
 
76
  # Hidden test suite for the grader
77
  self.test_suite = [
 
110
 
111
  def reset(self) -> RagOptimizerObservation:
112
  self._state = State(episode_id=str(uuid4()), step_count=0)
113
+ self.kb = deepcopy(self._build_initial_kb())
114
  return RagOptimizerObservation(
115
  message="RagOptimizerEnv Initialized. You have messy chunks in the KB. Resolve conflicts, add metadata tags to short tickets, and splinter monolithic files to win.",
116
  current_docs=self._get_kb_summary(),