Comments (13)
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?
from lanarky.
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)
from lanarky.
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']
from lanarky.
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?
from lanarky.
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?
from lanarky.
@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.
from lanarky.
no problem! i will look into this. will let you know once it's ready.
from lanarky.
Great, thanks man!
from lanarky.
@ajndkr can I contact you somehow? I'm struggling with something similar to your project, maybe you can help me out.
from lanarky.
@pors you can find me on twitter! https://twitter.com/ajndkr
from lanarky.
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
from lanarky.
good catch! @AmineDjeghri
from lanarky.
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.
from lanarky.
Related Issues (20)
- Question: SSE StreamingResponse support for FastAPI HOT 2
- Final answer not returned with using GPTCache, with streaming JSON. HOT 6
- LangchainRouter not using chain's built-in memory HOT 2
- Feature Request: Customized Chain Support HOT 4
- Issue with Gradio Integration in conversation_retrieval in examples/app HOT 4
- StreamingResponse SSE text/event-stream requires "data:" prefix and "\n\n" terminator to work properly HOT 5
- typing-extensions outdated for pydantic v2 HOT 6
- Vercel is not recognizing my LangchainRouter HOT 3
- Create Streaming for Agent types and add Memory HOT 2
- How to custom an AsyncLanarkyCallback in llmchain? HOT 7
- UserWarning: Field name "raise_error" shadows an attribute in parent "AsyncCallbackHandler"; HOT 7
- How to export OpenAI-Compatible API ? HOT 2
- Streaming sometimes has no response on repeated same request HOT 10
- AttributeError: module 'openai' has no attribute 'aiosession' HOT 5
- bug: callback handlers for langchain adapter doesn't work for LLMs without async support HOT 1
- bug: Expected response header Content-Type to contain 'text/event-stream', got 'text/plain' HOT 31
- bug: TokenStreamingCallbackHandler accepts only one key HOT 5
- bug: openai error: list index out of range HOT 1
- feat: LLMChain was deprecated HOT 1
- Allow langchain version > 0.2.0 to be used HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lanarky.