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

[langchain_community.llms.xinference]: Rewrite _stream() method and support stream() method in xinference.py #29259

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

TheSongg
Copy link
Contributor

@TheSongg TheSongg commented Jan 17, 2025

  • PR title:[langchain_community.llms.xinference]: Rewrite _stream() method and support stream() method in xinference.py

  • PR message: Rewrite the _stream method so that the chain.stream() can be used to return data streams.

     chain = prompt | llm
     chain.stream(input=user_input)
    
  • tests:
    from langchain_community.llms import Xinference
    from langchain.prompts import PromptTemplate

    llm = Xinference(
        server_url="http://0.0.0.0:9997",  # replace your xinference server url
        model_uid={model_uid}  # replace model_uid with the model UID return from launching the model
        stream = True
     )
    prompt = PromptTemplate(input=['country'], template="Q: where can we visit in the capital of {country}? A:")
    chain = prompt | llm
    chain.stream(input={'country': 'France'})
    

Copy link

vercel bot commented Jan 17, 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 17, 2025 3:10am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. community Related to langchain-community labels Jan 17, 2025
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Jan 18, 2025
@ccurme ccurme merged commit 1cd4d8d into langchain-ai:master Jan 18, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community lgtm PR looks good. Use to confirm that a PR is ready for merging. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants