Skip to content

Commit

Permalink
added path registry file id to modify script tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Jgmedina95 committed Jan 3, 2024
1 parent 3b1791d commit c09d3a4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mdagent/tools/base_tools/simulation_tools/create_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def remove_leading_spaces(self, text):

class ModifyScriptInput(BaseModel):
query: str = Field(..., description="Simmulation required by the user")
script: str = Field(..., description=" path to the base script file")
script: str = Field(..., description=" simulation ID of the base script file")


class ModifyBaseSimulationScriptTool(BaseTool):
Expand All @@ -149,10 +149,14 @@ def __init__(self, path_registry: Optional[PathRegistry], llm: BaseLanguageModel
self.llm = llm

def _run(self, **input):
base_script_path = input.get("script")
if not base_script_path:
return """No script provided. The keys for the input are:
base_script_id = input.get("script")
if not base_script_id:
return """No id provided. The keys for the input are:
'query' and 'script'"""
try:
base_script_path = self.path_registry.get_mapped_path(base_script_id)
except Exception as e:
return f"Error getting path from file id: {e}"
with open(base_script_path, "r") as file:
base_script = file.read()
base_script = "".join(base_script)
Expand Down

0 comments on commit c09d3a4

Please sign in to comment.