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

feat: add streaming and websocket support for all chain types #8

Closed
15 of 58 tasks
ajndkr opened this issue Apr 24, 2023 · 13 comments
Closed
15 of 58 tasks

feat: add streaming and websocket support for all chain types #8

ajndkr opened this issue Apr 24, 2023 · 13 comments
Labels
epic EPIC tasks feature New feature or request on-hold

Comments

@ajndkr
Copy link
Owner

ajndkr commented Apr 24, 2023

After #6, it is evident that the chain_wrapper_fn logic is not generic for all chain types. There needs to be a Response class for each chain type. This issue will track progress.

Todo:

Streaming

  • ConversationChain
  • LLMChain
  • LLMBashChain
  • LLMCheckerChain
  • LLMSummarizationCheckerChain
  • LLMMathChain
  • PALChain
  • QAWithSourcesChain
  • SQLDatabaseChain
  • SequentialChain
  • SimpleSequentialChain
  • VectorDBQA
  • VectorDBQAWithSourcesChain
  • APIChain
  • LLMRequestsChain
  • TransformChain
  • MapReduceChain
  • OpenAIModerationChain
  • SQLDatabaseSequentialChain
  • AnalyzeDocumentChain
  • HypotheticalDocumentEmbedder
  • ChatVectorDBChain
  • GraphQAChain
  • ConstitutionalChain
  • QAGenerationChain
  • RetrievalQA
  • RetrievalQAWithSourcesChain
  • ConversationalRetrievalChain
  • OpenAPIEndpointChain

Websocket

  • ConversationChain
  • LLMChain
  • LLMBashChain
  • LLMCheckerChain
  • LLMSummarizationCheckerChain
  • LLMMathChain
  • PALChain
  • QAWithSourcesChain
  • SQLDatabaseChain
  • SequentialChain
  • SimpleSequentialChain
  • VectorDBQA
  • VectorDBQAWithSourcesChain
  • APIChain
  • LLMRequestsChain
  • TransformChain
  • MapReduceChain
  • OpenAIModerationChain
  • SQLDatabaseSequentialChain
  • AnalyzeDocumentChain
  • HypotheticalDocumentEmbedder
  • ChatVectorDBChain
  • GraphQAChain
  • ConstitutionalChain
  • QAGenerationChain
  • RetrievalQA
  • RetrievalQAWithSourcesChain
  • ConversationalRetrievalChain
  • OpenAPIEndpointChain
@ajndkr ajndkr added feature New feature or request epic EPIC tasks labels Apr 24, 2023
@ajndkr ajndkr self-assigned this Apr 24, 2023
@ajndkr ajndkr added this to the v0.4.0 milestone Apr 24, 2023
@pors
Copy link

pors commented Apr 28, 2023

Amazing project!

My use case would be an LLM chatbot, which requires state. FastAPI supports WebSockets which might be a good solution here, or is there another approach possible?

@ajndkr
Copy link
Owner Author

ajndkr commented Apr 28, 2023

hi! i think it depends on how you are building the frontend but I do like the idea of adding support for websockets.

It's already implemented in https://github.com/hwchase17/chat-langchain but it's better if the implementation can be added to this package as well. I will create a feature request for this.

Would you like to contribute towards it?

@pors
Copy link

pors commented Apr 28, 2023

hi! i think it depends on how you are building the frontend

You mean by keeping track of history in the client? And thus sending it again at every request?

but I do like the idea of adding support for websockets.

It's already implemented in https://github.com/hwchase17/chat-langchain but it's better if the implementation can be added to this package as well. I will create a feature request for this.

Cool!

Would you like to contribute towards it?

I'll have a look if I am able to. Maybe you can point out where in your code it would fit best?

@ajndkr
Copy link
Owner Author

ajndkr commented Apr 28, 2023

You mean by keeping track of history in the client? And thus sending it again at every request?

yup yup. for example: https://github.com/mckaywrigley/chatbot-ui.

I'll have a look if I am able to. Maybe you can point out where in your code it would fit best?

Yes sure. I think the responses module seems best for this: https://github.com/ajndkr/fastapi-async-langchain/tree/main/fastapi_async_langchain/responses. You can do the following:

  • create base websocket response
  • create base callback class for websocket inside callbacks module
  • create websocket response for LLMChain (I can take over the rest)

@pors
Copy link

pors commented Apr 29, 2023

@ajndkr Sorry, but I don't have enough time for it. If I was a bit more familiar with FastAPI I'd do it, but I have only worked with Flask for APIs.

@ajndkr
Copy link
Owner Author

ajndkr commented Apr 29, 2023

no problem! i will look into this. will let you know once it's ready.

@pors
Copy link

pors commented Apr 29, 2023

Great, thanks man!

@ajndkr ajndkr removed this from the v0.4.0 milestone May 1, 2023
@ajndkr ajndkr changed the title feat: add streaming support for all chain types feat: add streaming and websocket support for all chain types May 10, 2023
@pors
Copy link

pors commented May 11, 2023

@ajndkr can I contact you somehow? I'm struggling with something similar to your project, maybe you can help me out.

@ajndkr
Copy link
Owner Author

ajndkr commented May 12, 2023

@pors you can find me on twitter! https://twitter.com/ajndkr

@ajndkr ajndkr added the on-hold label May 29, 2023
@ajndkr ajndkr removed their assignment May 31, 2023
@AmineDjeghri
Copy link
Contributor

Using LLMChain doesn't work.

File "/home/outscale/miniconda3/envs/react-qback/lib/python3.9/site-packages/lanarky/routing/utils.py", line 88, in create_request_from_langchain_dependency
    raise TypeError(
TypeError: Error! Creating a Request model for 'LLMChain' is not currently supported by 'LangchainRouter.add_langchain_api_route()'.
Available chain types: ['ConversationChain', 'AgentExecutor', 'RetrievalQAWithSourcesChain', 'ConversationalRetrievalChain']

To use a custom chain type, you must define your own FastAPI endpoint.

I'm looking into a way to use a chat system but without using the memory since the history of messages is stored inside a database and there are different users using the chatbot.
So i can't use ConversationChain. I'm trying with LLMChain instead but it looks like it is not supported

@AmineDjeghri
Copy link
Contributor

AmineDjeghri commented Sep 18, 2023

i added 'LLMChain' in Base Models in /home/outscale/miniconda3/envs/react-qback/lib/python3.9/site-packages/lanarky/routing/utils.py and it worked

['LLMChain', 'ConversationChain', 'AgentExecutor', 'RetrievalQAWithSourcesChain', 'ConversationalRetrievalChain']

@ajndkr
Copy link
Owner Author

ajndkr commented Sep 18, 2023

good catch! @AmineDjeghri

@ajndkr
Copy link
Owner Author

ajndkr commented Nov 16, 2023

closing this issue as I currently have no future plans to add support for all chain and agent types. I will add support iteratively based on demand/popularity.

@ajndkr ajndkr closed this as completed Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic EPIC tasks feature New feature or request on-hold
Projects
None yet
Development

No branches or pull requests

3 participants