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

Update backend API interfaces to be agnostic to messages list (i.e. MessageGraph) #294

Merged
merged 3 commits into from
Apr 11, 2024

Conversation

andrewnguonly
Copy link
Contributor

@andrewnguonly andrewnguonly commented Apr 11, 2024

Summary

Currently, the OpenGPTs backend only implements MessageGraph. Implementing StateGraph in the backend demonstrates the ability to support arbitrary graphs within OpenGPTs. Migrating the current usage of MessageGraph to StateGraph is the first step.

Changes in this PR are adopted from this PR.

Implementation

  1. Rename internal variables and update docstrings: messages --> values.
  2. Add support for Dict[str, Any] agent state type: Sequence[AnyMessage] --> Union[Sequence[AnyMessage], Dict[str, Any]].
  3. Breaking API changes to rename interfaces to be agnostic to a agent state type.

Breaking API Changes

  1. GET /threads/<tid>/messages --> GET /threads/<tid>/state
    Response: {"messages": [...], ...} --> {"values": [...], "next": []}
  2. POST /threads/<tid>/messages --> POST /threads/<tid>/state
    Body: {"messages": [...]} --> {"values": [...]}

To Do

  • Migrate get_chatbot_executor() to use StateGraph
  • Migrate get_retrieval_executor() to use StateGraph
  • Migrate get_google_agent_executor() to use StateGraph
  • Migrate get_openai_agent_executor() to use StateGraph
  • Migrate get_xml_agent_executor() to use StateGraph

Note: This PR can be merged without completing these to-do's.

@andrewnguonly andrewnguonly changed the title [WIP] Migrate backend to implement StateGraph instead of MessageGraph Draft: Migrate backend to implement StateGraph instead of MessageGraph Apr 11, 2024
@andrewnguonly andrewnguonly changed the title Draft: Migrate backend to implement StateGraph instead of MessageGraph Migrate backend to implement StateGraph instead of MessageGraph Apr 11, 2024
@andrewnguonly
Copy link
Contributor Author

Update: Chatted with @nfcampos offline and the items in the To Do list will be implemented in a separate PR. get_chatbot_executor() and get_retrieval_executor() will be updated, but the rest will be left alone.

@andrewnguonly andrewnguonly changed the title Migrate backend to implement StateGraph instead of MessageGraph Update backend API interfaces to be agnostic to messages list (i.e. MessageGraph) Apr 11, 2024
@andrewnguonly andrewnguonly merged commit 044c314 into langchain-ai:main Apr 11, 2024
6 checks passed
@andrewnguonly andrewnguonly deleted the state-graph branch April 11, 2024 23:49
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.

1 participant