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

community: added citation to streaming #29176

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

Conversation

WSQsGithub
Copy link

PR message: Added citation for streaming
- Description: Added citation for streaming
- Issue: none
- Dependencies: none
- Twitter handle: none

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jan 13, 2025
Copy link

vercel bot commented Jan 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 0:50am

@dosubot dosubot bot added community Related to langchain-community 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs labels Jan 13, 2025
Copy link
Member

@efriis efriis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

could you add a unit test testing the chunk merging behavior as well?

here's a screenshot of example outputs if helpful re: citation merging
ScreenShot 2025-01-13 at 07 38 19PM

@@ -228,10 +228,12 @@ def _stream(
chunk = chunk.dict()
if len(chunk["choices"]) == 0:
continue
citations = chunk.get("citations", [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe citations come back with every chunk, so you'll have to only return them on the first chunk, or otherwise detect that the citations are identical to the ones already outputted.

Otherwise citations will be repeated when merging AIMessageChunk objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants