Comments (8)
it doesn't stream responses back to the chat, although it shows them in the Python output.
I see! It's likely due to this:
lanarky/lanarky/callbacks/agents.py
Line 24 in 6127973
I need to update this to handle all agent types. I think currently only zero shot agents are supported.
from lanarky.
@votkon sure! do you maybe have a langchain example or a use case?
from lanarky.
@votkon I think you can use OpenAI functions directly via initialise_agent()
(https://python.langchain.com/docs/modules/agents/agent_types/openai_functions_agent). The function creates an AgentExecutor
instance which is already supported. See example: https://github.com/ajndkr/lanarky/blob/main/examples/app/zero_shot_agent.py
from lanarky.
Thanks for the prompt reply!
I somehow missed this example.
After giving it a try it looks like it doesn't communicate correctly with the frontend app.
In the zero_shot_agent.py example, when I change the
return initialize_agent(
tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
to
return initialize_agent(
tools, llm, agent=AgentType.OPENAI_FUNCTIONS, verbose=True
)
it doesn't stream responses back to the chat, although it shows them in the Python output.
Also, it doesn't look like initialize_agent supports the memory parameter:
https://python.langchain.com/docs/modules/memory/how_to/agent_with_memory
I am doing a simple web chat with conversation memory and the ability to call different tools and/or functions.
Thanks!
from lanarky.
Thanks! Have you had a chance to look into it?
from lanarky.
Thanks! Have you had a chance to look into it?
nope! i have been busy these past few weeks. I will try to find more time to work on this repo.
from lanarky.
Hi @votkon,
Using this custom class
class CustomAsyncAgentsStreamingCallback(AsyncAgentsLanarkyCallback, AsyncLLMChainStreamingCallback):
"""AsyncStreamingResponseCallback handler for AgentExecutor."""
answer_prefix_tokens: list[str] = [""]
and using it as a callback in your StreamingResponse may be a quickfix for you
StreamingResponse.from_chain(
agent_executor,
{"input": query},
media_type="text/event-stream",
callback=CustomAsyncAgentsStreamingCallback
)
from lanarky.
I will add native support for OpenAI functions as part of v0.9 roadmap.
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.