From 8ddc6a0f2773925a918f79988caa409d3e0ab166 Mon Sep 17 00:00:00 2001 From: Siddharth Balyan Date: Sat, 25 May 2024 18:31:32 +0530 Subject: [PATCH 1/2] session.chat working without specifying user --- .../agents_api/common/protocol/sessions.py | 17 ++--- .../models/entry/proc_mem_context.py | 4 +- .../agents_api/models/session/session_data.py | 68 +++++++++++++++++++ agents-api/docker-compose.yml | 4 ++ 4 files changed, 83 insertions(+), 10 deletions(-) diff --git a/agents-api/agents_api/common/protocol/sessions.py b/agents-api/agents_api/common/protocol/sessions.py index a85ee1ae4..01259383d 100644 --- a/agents-api/agents_api/common/protocol/sessions.py +++ b/agents-api/agents_api/common/protocol/sessions.py @@ -9,6 +9,7 @@ from .agents import AgentDefaultSettings +from typing import Optional, Dict class SessionSettings(AgentDefaultSettings): """ @@ -26,19 +27,19 @@ class SessionData(BaseModel): """ agent_id: UUID - user_id: UUID + user_id: Optional[UUID] session_id: UUID situation: str - summary: str | None - user_name: str | None - user_about: str - agent_name: str | None + summary: Optional[str] + user_name: Optional[str] + user_about: Optional[str] + agent_name: Optional[str] agent_about: str updated_at: float created_at: float model: str default_settings: SessionSettings render_templates: bool = False - metadata: dict = {} - user_metadata: dict = {} - agent_metadata: dict = {} + metadata: Dict = {} + user_metadata: Optional[Dict] = None + agent_metadata: Dict = {} diff --git a/agents-api/agents_api/models/entry/proc_mem_context.py b/agents-api/agents_api/models/entry/proc_mem_context.py index e6b48471b..bf8724951 100644 --- a/agents-api/agents_api/models/entry/proc_mem_context.py +++ b/agents-api/agents_api/models/entry/proc_mem_context.py @@ -56,7 +56,7 @@ def proc_mem_context_query( :create _input {{ session_id: Uuid, agent_id: Uuid, - user_id: Uuid, + user_id: Uuid?, # tool_query: , doc_query: , }} @@ -213,7 +213,7 @@ def proc_mem_context_query( user_doc_id: Uuid? default null, }} }} {{ - # Collect document information based on agent ID and document query embedding. + # Collect document information based on user ID and document query embedding. # Collect user docs # Search for user docs diff --git a/agents-api/agents_api/models/session/session_data.py b/agents-api/agents_api/models/session/session_data.py index 8d09d452b..f403ad3e5 100644 --- a/agents-api/agents_api/models/session/session_data.py +++ b/agents-api/agents_api/models/session/session_data.py @@ -97,6 +97,74 @@ def session_data_query( "min_p": min_p, "preset": preset, } + ?[ + agent_id, + user_id, + session_id, + situation, + summary, + updated_at, + created_at, + user_name, + user_about, + agent_name, + agent_about, + model, + default_settings, + metadata, + render_templates, + user_metadata, + agent_metadata, + ] := input[developer_id, session_id], + *sessions{ + developer_id, + session_id, + situation, + summary, + created_at, + updated_at: validity, + metadata, + render_templates, + @ "NOW" + }, + *session_lookup{ + agent_id, + user_id, + session_id, + }, updated_at = to_int(validity), + not *users{ + user_id + }, user_name=null, user_about=null, user_metadata=null, + *agents{ + agent_id, + name: agent_name, + about: agent_about, + model, + metadata: agent_metadata, + }, + *agent_default_settings { + agent_id, + frequency_penalty, + presence_penalty, + length_penalty, + repetition_penalty, + top_p, + temperature, + min_p, + preset, + }, + default_settings = { + "frequency_penalty": frequency_penalty, + "presence_penalty": presence_penalty, + "length_penalty": length_penalty, + "repetition_penalty": repetition_penalty, + "top_p": top_p, + "temperature": temperature, + "min_p": min_p, + "preset": preset, + } + + """ return (query, {"developer_id": str(developer_id), "session_id": str(session_id)}) diff --git a/agents-api/docker-compose.yml b/agents-api/docker-compose.yml index 7697ac7b3..ae21334d9 100644 --- a/agents-api/docker-compose.yml +++ b/agents-api/docker-compose.yml @@ -64,6 +64,8 @@ services: image: ghcr.io/huggingface/text-embeddings-inference:1.0 ports: - "8082:80" + volumes: + - ~/.cache/huggingface/hub:/data shm_size: "2gb" deploy: resources: @@ -82,6 +84,8 @@ services: image: ghcr.io/huggingface/text-embeddings-inference:1.0 ports: - "8083:80" + volumes: + - ~/.cache/huggingface/hub:/data shm_size: "2gb" deploy: resources: From 0163829129fd6c7040c7bba08ebdb388a635e506 Mon Sep 17 00:00:00 2001 From: alt-glitch Date: Sat, 25 May 2024 18:04:52 +0000 Subject: [PATCH 2/2] refactor: Lint agents-api (CI) --- agents-api/agents_api/common/protocol/sessions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/agents-api/agents_api/common/protocol/sessions.py b/agents-api/agents_api/common/protocol/sessions.py index 01259383d..c9fa81075 100644 --- a/agents-api/agents_api/common/protocol/sessions.py +++ b/agents-api/agents_api/common/protocol/sessions.py @@ -11,6 +11,7 @@ from typing import Optional, Dict + class SessionSettings(AgentDefaultSettings): """ A placeholder for session-specific settings, inheriting from AgentDefaultSettings.