the-drifter23 commited on
Commit
9a90f4a
·
verified ·
1 Parent(s): 50ba9da

Update prompt_compiler.py

Browse files
Files changed (1) hide show
  1. prompt_compiler.py +4 -5
prompt_compiler.py CHANGED
@@ -8,10 +8,10 @@ class PromptCompiler:
8
  self.token_engine = TokenEngine()
9
  self.mode = mode
10
  self.system_prompt = system_prompt or prompt_templates.get(mode, "")
11
-
12
  def compile(self, user_input: str, context: dict = None) -> str:
13
  """
14
- Combines system prompt, user input, and context into a final prompt for the model.
15
  """
16
  context_block = self._format_context(context or {})
17
  final_prompt = f"{self.system_prompt}\n\n{context_block}\n\nUser: {user_input}\n\nLORIEN:"
@@ -23,11 +23,10 @@ class PromptCompiler:
23
  """
24
  if not context:
25
  return ""
26
- formatted = "\n".join([f"[{k.upper()}]: {v}" for k, v in context.items()])
27
- return f"Context:\n{formatted}"
28
 
29
  def estimate_tokens(self, prompt: str) -> int:
30
  """
31
- Estimates token count using the TokenEngine.
32
  """
33
  return self.token_engine.count_tokens(prompt)
 
8
  self.token_engine = TokenEngine()
9
  self.mode = mode
10
  self.system_prompt = system_prompt or prompt_templates.get(mode, "")
11
+
12
  def compile(self, user_input: str, context: dict = None) -> str:
13
  """
14
+ Compile the final prompt from the system prompt, context, and user input.
15
  """
16
  context_block = self._format_context(context or {})
17
  final_prompt = f"{self.system_prompt}\n\n{context_block}\n\nUser: {user_input}\n\nLORIEN:"
 
23
  """
24
  if not context:
25
  return ""
26
+ return "\n".join([f"[{k.upper()}]: {v}" for k, v in context.items()])
 
27
 
28
  def estimate_tokens(self, prompt: str) -> int:
29
  """
30
+ Estimate token usage of the compiled prompt.
31
  """
32
  return self.token_engine.count_tokens(prompt)