Skip to content

Commit

Permalink
Updates alias ID handling
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed Jan 10, 2025
1 parent 9b6e035 commit dadbac3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions synapseclient/api/agent_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ async def register_agent(

client = Synapse.get_client(synapse_client=synapse_client)

request = {
"awsAgentId": cloud_agent_id,
"awsAliasId": cloud_alias_id if cloud_alias_id else "TSTALIASID",
}
request = {"awsAgentId": cloud_agent_id}
if cloud_alias_id:
request["awsAliasId"] = cloud_alias_id
return await client.rest_put_async(
uri="/agent/registration", body=json.dumps(request)
)
Expand Down
14 changes: 7 additions & 7 deletions synapseclient/models/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ async def prompt_async(
newer_than=newer_than,
synapse_client=synapse_client,
)
# TODO: This is a bit hacky. Do we need to parse the page instead?
trace = trace_response["page"][0]["message"]

self.chat_history.append(
Expand All @@ -264,7 +265,7 @@ class Agent:
Attributes:
cloud_agent_id: The unique ID of the agent in the cloud provider.
cloud_alias_id: The alias ID of the agent in the cloud provider.
In the Synapse API, this defaults to 'TSTALIASID'.
Defaults to 'TSTALIASID' in the Synapse API.
synapse_registration_id: The ID number of the agent assigned by Synapse.
registered_on: The date the agent was registered.
type: The type of agent.
Expand All @@ -274,7 +275,9 @@ class Agent:
"""The unique ID of the agent in the cloud provider."""

cloud_alias_id: Optional[str] = None
"""The alias ID of the agent in the cloud provider. In the Synapse API, this defaults to 'TSTALIASID'."""
"""The alias ID of the agent in the cloud provider.
Defaults to 'TSTALIASID' in the Synapse API.
"""

registration_id: Optional[int] = None
"""The ID number of the agent assigned by Synapse."""
Expand Down Expand Up @@ -384,7 +387,7 @@ async def start_session_async(
method_to_trace_name=lambda self, **kwargs: f"Get_Agent_Session: {self.registration_id}"
)
async def get_session_async(
self, *, session_id: str, synapse_client: Optional[Synapse] = None
self, session_id: str, *, synapse_client: Optional[Synapse] = None
) -> "AgentSession":
session = await AgentSession(id=session_id).get_async(
synapse_client=synapse_client
Expand All @@ -399,12 +402,12 @@ async def get_session_async(
)
async def prompt(
self,
*,
prompt: str,
enable_trace: bool = False,
print_response: bool = False,
session: Optional[AgentSession] = None,
newer_than: Optional[int] = None,
*,
synapse_client: Optional[Synapse] = None,
) -> None:
"""Sends a prompt to the agent for the current session.
Expand Down Expand Up @@ -438,9 +441,6 @@ async def prompt(
synapse_client=synapse_client,
)

@otel_trace_method(
method_to_trace_name=lambda self, **kwargs: f"Get_Agent_Session_Chat_History: {self.registration_id}"
)
def get_chat_history(self) -> Union[List[AgentPrompt], None]:
"""Gets the chat history for the current session."""
return self.current_session.chat_history if self.current_session else None

0 comments on commit dadbac3

Please sign in to comment.