Skip to content

Commit

Permalink
add agent if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Jan 14, 2025
1 parent 00424d7 commit f37e0ea
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions agixt/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,25 @@ def get_agent_config(self):
)
.first()
)
self.agent_id = str(agent.id) if agent else None
if not agent:
raise HTTPException(status_code=404, detail="Agent not found.")
agent = (
session.query(AgentModel)
.filter(AgentModel.user_id == self.user_id)
.first()
)
if not agent:
# Create an agent.
add_agent(agent_name=self.agent_name, user=self.user)
# Get the agent
agent = (
session.query(AgentModel)
.filter(
AgentModel.name == self.agent_name,
AgentModel.user_id == self.user_id,
)
.first()
)
self.agent_id = str(agent.id) if agent else None
config = {"settings": {}, "commands": {}}
if agent:
all_commands = session.query(Command).all()
Expand Down

0 comments on commit f37e0ea

Please sign in to comment.