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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a31adfe8622ed92af41b13493b9519885f67c2a7cf4f4a8b2a349f43cdbc4c95
|
|
| MD5 |
d5fbfc19fdea5675d96d4be45b209dea
|
|
| BLAKE2b-256 |
14aa7fe1c08395bfc754047462e8461e8e81d685d927be8cb8a14f3d0576d967
|
File details
Details for the file langchain_xinference-0.1.2-py3-none-any.whl.
File metadata
- Download URL: langchain_xinference-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
105b0df4f07820d1b7ea3266ad4c62e9421a1e5a9a6f7d85d125d242b5e13ccc
|
|
| MD5 |
ce949ee3115038fc581ef8018eafeca3
|
|
| BLAKE2b-256 |
ff7ea1576089aa1252c61c6eb1dbfd49ed13b8b0646e66109b63c68fcce9db48
|