Skip to main content

langchain-xinference

This package contains the LangChain integration with Xinference

Installation

pip install -U langchain-xinference

Dependence

Install Xinference by using pip as follows. (For more options, see Installation page.)

pip install "xinference[all]"

To start a local instance of Xinference, run the following command:

$ xinference-local

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"})
chain.stream(input={"country": "France"})  #  streaming data

LLMs

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"})

Metadata

Release files for langchain-xinference 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-xinference 0.1.0
File Size Uploaded
langchain_xinference-0.1.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-xinference 0.1.0
File Interpreter ABI Platform
langchain_xinference-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / langchain_xinference-0.1.0.tar.gz

Download URL langchain_xinference-0.1.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4415d1650be9743a1d6f71a2629095ef8e467ebad6a24fcce8f533c4a3cf9ddb
BLAKE2b-256 checksum
How to use checksums
eed1bda51c7a0e490e963998fe0fc9834c7476e39afb330e7a7128315696b4df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.8

Release files / langchain_xinference-0.1.0-py3-none-any.whl

Download URL langchain_xinference-0.1.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db859b1a3da0eed11b5d0f8269fdff72dfc1953f987ccda85d95b3850590029f
BLAKE2b-256 checksum
How to use checksums
ffa09e161d47820e1d895b61d343b24ebc01b3f8f447a56de34cd41d08ff9785
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.8

Release history Release notifications | RSS feed

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page