hsaest commited on
Commit
a25c2e7
·
1 Parent(s): b07eb5e

Stop model before tool response boundary

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -2005,6 +2005,7 @@ def call_model(
2005
  messages=messages,
2006
  temperature=temperature,
2007
  max_tokens=max_new_tokens,
 
2008
  )
2009
  return completion.choices[0].message.content or "", model_name
2010
  except Exception as exc:
@@ -2222,6 +2223,8 @@ def build_research_agent(
2222
  )
2223
  dt = time.time() - t0
2224
  model_output = raw_output
 
 
2225
  # Preserve the human-friendly model id for the trace even if the
2226
  # endpoint ignores the "model" param and returns the TGI shim name.
2227
  used_model = display_primary if endpoint_model == primary_model == QUEST_ENDPOINT_MODEL else endpoint_model
 
2005
  messages=messages,
2006
  temperature=temperature,
2007
  max_tokens=max_new_tokens,
2008
+ stop=["\n<tool_response>", "<tool_response>"],
2009
  )
2010
  return completion.choices[0].message.content or "", model_name
2011
  except Exception as exc:
 
2223
  )
2224
  dt = time.time() - t0
2225
  model_output = raw_output
2226
+ if "<tool_response>" in model_output:
2227
+ model_output = model_output[:model_output.find("<tool_response>")].rstrip()
2228
  # Preserve the human-friendly model id for the trace even if the
2229
  # endpoint ignores the "model" param and returns the TGI shim name.
2230
  used_model = display_primary if endpoint_model == primary_model == QUEST_ENDPOINT_MODEL else endpoint_model