Skip to main content

An integration package connecting Xinference and LangChain

Project description

💻 langchain-xinference

This package contains the LangChain integration with Xinference

🤝 Support

  • Chat
  • Generate
  • Embeddings
  • Reranks
  • Tools Call

🚀 Installation

pip install -U langchain-xinference

☕ Chat Models

ChatXinference class exposes chat models from Xinference.

from langchain_xinference.chat_models import ChatXinference
from langchain.prompts import PromptTemplate

llm = ChatXinference(
  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
         )
prompt = PromptTemplate(input=["country"], template="Q: where can we visit in the capital of {country}? A:")
chain = prompt | llm

chain.invoke(input={"country": "France"})

ai_res = chain.stream(input={"country": "France"})
for chunk in ai_res:
    print(chunk.content)

☕ Generate

Xinference class exposes LLMs from Xinference.

from langchain_xinference.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
 )
prompt = PromptTemplate(input=["country"], template="Q: where can we visit in the capital of {country}? A:")
chain = prompt | llm
chain.invoke(input={"country": "France"})

ai_res = chain.stream(input={"country": "France"})
for chunk in ai_res:
    print(chunk)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_xinference-0.1.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_xinference-0.1.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_xinference-0.1.2.tar.gz.

File metadata

  • Download URL: langchain_xinference-0.1.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.8

File hashes

Hashes for langchain_xinference-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a31adfe8622ed92af41b13493b9519885f67c2a7cf4f4a8b2a349f43cdbc4c95
MD5 d5fbfc19fdea5675d96d4be45b209dea
BLAKE2b-256 14aa7fe1c08395bfc754047462e8461e8e81d685d927be8cb8a14f3d0576d967

See more details on using hashes here.

File details

Details for the file langchain_xinference-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_xinference-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 105b0df4f07820d1b7ea3266ad4c62e9421a1e5a9a6f7d85d125d242b5e13ccc
MD5 ce949ee3115038fc581ef8018eafeca3
BLAKE2b-256 ff7ea1576089aa1252c61c6eb1dbfd49ed13b8b0646e66109b63c68fcce9db48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page