Skip to main content

langchain xinference chain

Project description

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

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

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

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.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

langchain_xinference-0.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_xinference-0.1.1.tar.gz
  • Upload date:
  • Size: 8.3 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.1.tar.gz
Algorithm Hash digest
SHA256 6316da4582a8fed1cf5b9902af8ccbea2115f776ae5ae295e606fea23229db80
MD5 aed5d9ee62c1f7565741393b9aa04d34
BLAKE2b-256 bbe6058fc6714cc007f8861e8ad2e27a309f6f95d4e50dc8c69e9361e25d838e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_xinference-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9afd853842c70a3c5d7695ca9e7c8389fc014a0d7c2dac58b75657cdd9fb6c58
MD5 e34e1faefe21ecd607c88bfe9429721b
BLAKE2b-256 935d7287d2d016131d725b1178c3592e77d0eb55acfdd65687438d3609fa0ee1

See more details on using hashes here.

Supported by

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