diff --git a/apps/api/src/crew.py b/apps/api/src/crew.py index 6cac7eb1..d1277c95 100644 --- a/apps/api/src/crew.py +++ b/apps/api/src/crew.py @@ -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) diff --git a/apps/api/src/interfaces/db.py b/apps/api/src/interfaces/db.py index 4675324c..893221da 100644 --- a/apps/api/src/interfaces/db.py +++ b/apps/api/src/interfaces/db.py @@ -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 @@ -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) @@ -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"])) diff --git a/apps/api/src/mock.py b/apps/api/src/mock.py index 40600c41..2a98ec15 100644 --- a/apps/api/src/mock.py +++ b/apps/api/src/mock.py @@ -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, diff --git a/apps/api/src/models/agent_model.py b/apps/api/src/models/agent_model.py index c4cc63f0..ad7c1dbb 100644 --- a/apps/api/src/models/agent_model.py +++ b/apps/api/src/models/agent_model.py @@ -6,6 +6,10 @@ from pydantic import BaseModel +class LLMModel(BaseModel): + id: int + name: str + class Agent(BaseModel): id: UUID @@ -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 diff --git a/apps/api/src/parser.py b/apps/api/src/parser.py index ba0e6aa7..9efcf5b7 100644 --- a/apps/api/src/parser.py +++ b/apps/api/src/parser.py @@ -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 @@ -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] @@ -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 @@ -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")]))