Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYNPY-1544] Synapse Agent OOP Model #1152

Merged
merged 64 commits into from
Jan 28, 2025
Merged

Conversation

BWMac
Copy link
Contributor

@BWMac BWMac commented Jan 8, 2025

Description:

This PR is the implementation of an OOP model for interacting with the new Synapse Agent API endpoints. The design for the model implementation can be found in Confluence.

The core implementation includes (from "bottom to top"):

  • synapseclient.api.agent_services:
    • Low-level functions for interacting with the API endpoints that are specific to using Synapse Agents.
  • synapseclient.models.AgentPrompt:
  • synapseclient.models.AgentSession:
    • a dataclass representing a chat session with a Synapse Agent.
    • Includes functionality for directly interacting with chat sessions with a Synapse Agent.
    • The AgentSession logic is used in the Agent class, and we will generally recommend that users utilize the Agent class as the primary interface.
    • Asynchronous and Synchronous interfaces are available.
  • synapseclient.models.Agent:
    • a dataclass representing a Synapse Agent you can interact with.
    • Includes functionality for registering a custom agent, starting sessions with agents, sending prompts and also managing more than one session at a time.
    • The basic use case includes one session at a time where a session started by a user (either explicitly with start_session or implicitly by just calling prompt) becomes the default for prompting, but examples for conducting more than one session at a time can be found in the POC script and class docstring.

Notes:

  • All needed unit and integration tests for synchronous and asynchronous implementations are included.
  • Example usage of the models can be found in the class docstrings and in the POC script included in the PR.
  • I took the opportunity to refactor the Experimental section of the documentation, breaking up each model into it's own markdown script which makes maintaining the docs for OOP models a little easier.

@pep8speaks

This comment was marked as outdated.

@BWMac BWMac changed the title WIP [SYNPY-1544] Synapse Agent OOP Model [SYNPY-1544] Synapse Agent OOP Model Jan 8, 2025
@BWMac
Copy link
Contributor Author

BWMac commented Jan 22, 2025

@BryanFauble Ah yes the agent will need to be registered in Synapse Dev.

Copy link
Contributor

@BryanFauble BryanFauble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome changes! This all looks good to me.

When all the tests are passing we can move forward on merging the changes.

@BWMac BWMac merged commit aaa9c50 into develop Jan 28, 2025
24 of 25 checks passed
@BWMac BWMac deleted the synpy-1544-synapse-agent-oop-model branch January 28, 2025 18:23
BWMac added a commit that referenced this pull request Feb 3, 2025
* [SYNPY-1544] Synapse Agent OOP Model (#1152)

* Adds async convenience functions

* expose convenience functions

* updates convenience functions

* updates agent_services

* removes rest_get_async exception handling

* pre-commit fixes

* delete accidentally committed script

* adds initial agent implementation

* clean up agent

* adds missing docstrings

* pre-commit

* updates agent_services

* updates agent.py

* Updates alias ID handling

* adds syncronous interface

* prevent cicular import in storable_entity_components

* remove promt sending and receiving from agent_service

* adds initial (dirty) async job mixin

* pre-commit run

* [SYNPY-1544] potential changes to mixin (#1153)

* Changes for async mixin

* Remove arg

* bug fix

* generalizes send_job_and_wait_async

* removes typing.Self

---------

Co-authored-by: bwmac <bwm03570@gmail.com>

* cleans up agent logic

* adds async job unit tests

* updates async job tests

* adds agent unit tests

* adds integration tests

* pre-commit

* adds examples to agent.py

* removes todos

* adds POC script

* add to mixins

* adds agent docs

* updates agent docs

* reorganize documentation

* updates poc script

* clean up

* add docstring

* removes unused imports

* split too long lines

* force synapse_client kwarg

* updates agent.py

* updates synapse_client docstring description

* updates asynchronous_job

* updates integration tests

* pre-commit

* agent inherited members

* updates docs for inherited members

* missing inherited members

* updates doc formatting

* try team formatting change

* updates script description

* adds Annotation lazy import

* try team formatting change

* more formatting changes

* address review comments in agent.py

* move synchronous docs up a layer

* adds syn login

* adds warning message to docs

* updates docstring examples

* updates docstrings

* adds error handling for agent.get

* async integration tests

* fix conditional

* disables integration tests

* updates docstring for clarity

---------

Co-authored-by: BryanFauble <17128019+BryanFauble@users.noreply.github.com>

* [SYNPY-1544] Fixes docstring (#1155)

* fixes docstring

* protocol docstring

* fix imports

* Removes example setting annotations with Agent class (#1156)

* removes annotation example

* pre-commit

* [SYNPY-1557] Sync a Linked Folder Bug (#1157)

* fixes docstring

* protocol docstring

* fix imports

* adds integration test for expected behavior

* adds fix

* merge weirdness

* fix test docstring

* [SYNPY-1544] Return the AgentPrompt when calling the prompt function (#1158)

* update version v4.7.0

* version v4.7.0 docs

* pre-commit

---------

Co-authored-by: BryanFauble <17128019+BryanFauble@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants