Skip to content

Commit b950c6d

Browse files
authored
[SYNPY-1544] Return the AgentPrompt when calling the prompt function (#1158)
1 parent 65422cf commit b950c6d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

synapseclient/models/agent.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ async def prompt_async(
384384
newer_than: Optional[int] = None,
385385
*,
386386
synapse_client: Optional[Synapse] = None,
387-
) -> None:
387+
) -> AgentPrompt:
388388
"""Sends a prompt to the agent and adds the response to the AgentSession's
389389
chat history. A session must be started before sending a prompt.
390390
@@ -431,6 +431,7 @@ async def main():
431431
client.logger.info(f"RESPONSE:\n{agent_prompt.response}\n")
432432
if enable_trace:
433433
client.logger.info(f"TRACE:\n{agent_prompt.trace}")
434+
return agent_prompt
434435

435436

436437
@dataclass
@@ -811,7 +812,7 @@ async def prompt_async(
811812
newer_than: Optional[int] = None,
812813
*,
813814
synapse_client: Optional[Synapse] = None,
814-
) -> None:
815+
) -> AgentPrompt:
815816
"""Sends a prompt to the agent for the current session.
816817
If no session is currently active, a new session will be started.
817818
@@ -908,7 +909,7 @@ async def main():
908909
if not self.current_session:
909910
await self.start_session_async(synapse_client=synapse_client)
910911

911-
await self.current_session.prompt_async(
912+
return await self.current_session.prompt_async(
912913
prompt=prompt,
913914
enable_trace=enable_trace,
914915
newer_than=newer_than,

synapseclient/models/protocols/agent_protocol.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
from synapseclient import Synapse
77

88
if TYPE_CHECKING:
9-
from synapseclient.models import Agent, AgentSession, AgentSessionAccessLevel
9+
from synapseclient.models import (
10+
Agent,
11+
AgentPrompt,
12+
AgentSession,
13+
AgentSessionAccessLevel,
14+
)
1015

1116

1217
class AgentSessionSynchronousProtocol(Protocol):
@@ -109,7 +114,7 @@ def prompt(
109114
newer_than: Optional[int] = None,
110115
*,
111116
synapse_client: Optional[Synapse] = None,
112-
) -> None:
117+
) -> "AgentPrompt":
113118
"""Sends a prompt to the agent and adds the response to the AgentSession's
114119
chat history. A session must be started before sending a prompt.
115120
@@ -140,7 +145,7 @@ def prompt(
140145
print_response=True,
141146
)
142147
"""
143-
return None
148+
return AgentPrompt()
144149

145150

146151
class AgentSynchronousProtocol(Protocol):
@@ -313,7 +318,7 @@ def prompt(
313318
newer_than: Optional[int] = None,
314319
*,
315320
synapse_client: Optional[Synapse] = None,
316-
) -> None:
321+
) -> "AgentPrompt":
317322
"""Sends a prompt to the agent for the current session.
318323
If no session is currently active, a new session will be started.
319324
@@ -388,4 +393,4 @@ def prompt(
388393
session=my_second_session,
389394
)
390395
"""
391-
return None
396+
return AgentPrompt()

0 commit comments

Comments
 (0)