Skip to content

Commit

Permalink
add new agent model implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
failandimprove1 committed Apr 18, 2024
1 parent bcef579 commit e2f1cc3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion apps/api/src/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ def _create_agents(
for agent in crew_model.agents:
valid_agent_tools = []
tool_schemas: list[dict] | None
logger.info(f"agent model name: {agent.models.name}")
config_list = autogen.config_list_from_json(
"OAI_CONFIG_LIST",
filter_dict={
"model": [agent.model],
"model": [agent.models.name],
},
)
tool_ids = get_tool_ids_from_agent(agent.tools)
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/interfaces/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def update_status(session_id: UUID, status: SessionStatus) -> None:

def get_agent(agent_id: UUID) -> Agent | None:
supabase: Client = create_client(url, key)
response = supabase.table("agents").select("*").eq("id", agent_id).execute()
response = supabase.table("agents").select("*, models(*)").eq("id", agent_id).execute()
if not response.data:
return None

Expand All @@ -606,7 +606,7 @@ def get_agents(
) -> list[Agent] | None:
"""Gets agents, filtered by what parameters are given"""
supabase: Client = create_client(url, key)
query = supabase.table("agents").select("*")
query = supabase.table("agents").select("*, models(*)")

if profile_id:
query = query.eq("profile_id", profile_id)
Expand Down Expand Up @@ -819,4 +819,4 @@ def delete_profile(profile_id: UUID) -> Profile:
if __name__ == "__main__":
from src.models import Session

print(get_api_key_type_ids(["612ddae6-ecdd-4900-9314-1a2c9de6003d"]))
#print(get_api_key_type_ids(["612ddae6-ecdd-4900-9314-1a2c9de6003d"]))
4 changes: 2 additions & 2 deletions apps/api/src/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
"7c707c30-2cfe-46a0-afa7-8bcc38f9687e",
],
"prompt": {
"id": "",
"title": "",
"id": "54bea062-7612-4f3a-8125-485e6cd6175c",
"title": "tool testing",
"content": f"This is a tool testing environment, use the tool: {tool}, {prompt}. Suggest this function call",
},
"created_at": DATE,
Expand Down
8 changes: 7 additions & 1 deletion apps/api/src/models/agent_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

from pydantic import BaseModel

class LLMModel(BaseModel):
id: int
name: str


class Agent(BaseModel):
id: UUID
Expand All @@ -15,7 +19,9 @@ class Agent(BaseModel):
profile_id: UUID
avatar: str
system_message: str
model: Literal["gpt-3.5-turbo", "gpt-4-turbo-preview"]
#model_ is protected namespace, so changed attribute below to llm_model_
llm_model_id: int
models: LLMModel
tools: list[dict]
description: str | None = None
role: str
Expand Down
13 changes: 7 additions & 6 deletions apps/api/src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_agent(agent_id: UUID) -> Agent | None:
Get an agent from the database.
"""
logger.debug(f"Getting agent {agent_id}")
response = supabase.table("agents").select("*").eq("id", agent_id).execute()
response = supabase.table("agents").select("*, models(*)").eq("id", agent_id).execute()
if len(response.data) == 0:
logger.error(f"No agent found for {agent_id}")
return None
Expand All @@ -43,7 +43,7 @@ def get_agent(agent_id: UUID) -> Agent | None:

def get_agents(agent_ids: list[UUID]) -> list[Agent]:
logger.debug(f"getting agents from agent_ids: {agent_ids}")
response = supabase.table("agents").select("*").in_("id", agent_ids).execute()
response = supabase.table("agents").select("*, models(*)").in_("id", agent_ids).execute()
return [Agent(**agent) for agent in response.data]


Expand Down Expand Up @@ -72,7 +72,7 @@ def process_crew(crew: Crew) -> tuple[str, CrewProcessed]:
if agent.system_message == "":
raise ValueError(f"agent {agent.id} had no system message")

message: str = crew.prompt["content"]
message: str = crew.prompt.content
return message, crew_model


Expand Down Expand Up @@ -109,6 +109,7 @@ def parse_autobuild(


if __name__ == "__main__":
message, composition = parse_autobuild(
'"composition": {"message": "create a website for designing your own lamps","agents":[{"role": "UI/UX Designer","system_message": "Design the user interface and user experience for the lamp designing website. This includes creating wireframes, mockups, and interactive prototypes to ensure a user-friendly and visually appealing design."},{"role": "React Developer","system_message": "Develop the front-end of the lamp designing website using React. This includes implementing the UI/UX designs into functional web pages, ensuring responsiveness, and integrating any necessary APIs for lamp design functionalities."},{"role": "Backend Developer","system_message": "Create and manage the server, database, and application logic for the lamp designing website. This includes setting up the server, creating database schemas, and developing APIs for user management, lamp design storage, and retrieval."},{"role": "Quality Assurance Engineer","system_message": "Test the lamp designing website for bugs, performance issues, and usability. This includes conducting both automated and manual tests to ensure the website is reliable, efficient, and user-friendly."}]}'
)
#message, composition = parse_autobuild(
# '"composition": {"message": "create a website for designing your own lamps","agents":[{"role": "UI/UX Designer","system_message": "Design the user interface and user experience for the lamp designing website. This includes creating wireframes, mockups, and interactive prototypes to ensure a user-friendly and visually appealing design."},{"role": "React Developer","system_message": "Develop the front-end of the lamp designing website using React. This includes implementing the UI/UX designs into functional web pages, ensuring responsiveness, and integrating any necessary APIs for lamp design functionalities."},{"role": "Backend Developer","system_message": "Create and manage the server, database, and application logic for the lamp designing website. This includes setting up the server, creating database schemas, and developing APIs for user management, lamp design storage, and retrieval."},{"role": "Quality Assurance Engineer","system_message": "Test the lamp designing website for bugs, performance issues, and usability. This includes conducting both automated and manual tests to ensure the website is reliable, efficient, and user-friendly."}]}'
#)
print(get_agents([UUID("7c707c30-2cfe-46a0-afa7-8bcc38f9687e")]))

0 comments on commit e2f1cc3

Please sign in to comment.