Skip to content

Updated app example #201

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Updated app example #201

wants to merge 2 commits into from

Conversation

jpolvto
Copy link
Contributor

@jpolvto jpolvto commented Aug 15, 2025

Added an updated version of this app, which now includes LangGraph. The Bing Search API has been sunset, so it's not included anymore.

Interestingly, this adds similar functionality to Open WebUI or AnythingLLM, but in under 1000 lines of code.

…he Bing Search API has been sunset, so it's not included anymore.
@jpolvto
Copy link
Contributor Author

jpolvto commented Aug 15, 2025

One thing I still needed to include here was the StreamHandler, the LangchainCallbackHandler still does not handle agents out of the box it seems.

`# Callback handler for handling streaming responses from the language model
class StreamHandler(BaseCallbackHandler):
"""
A callback handler for handling streaming responses from the language model.

Attributes:
    msg (cl.Message): The message object used for streaming the response.

Methods:
    on_llm_new_token: Called when a new token is received from the language model.
    on_llm_end: Called when the streaming response from the language model ends.
"""

def __init__(self):
    self.msg = cl.Message(content="")

async def on_llm_new_token(self, token: str, **kwargs):
    await self.msg.stream_token(token)

async def on_llm_end(self, response: str, **kwargs):
    await self.msg.send()
    self.msg = cl.Message(content="")`

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