An integration package connecting NexaAI and LangChain
Project description
langchain-nexa-ai
This package contains the LangChain integration with Nexa AI.
Installation
pip install -U langchain-core langchain-nexa-ai
And you should get an api key from Nexa Hub and set it as an environment variable (NEXA_API_KEY
)
LLMs
NexaAILLM
class exposes Octopus LLMs from NexaAI. We currently support four catogories: shopping
, conference
, streaming
, and travel
. See our langchain-nexa-ai tutorial and Nexa AI documentation for more details!
from langchain_nexa_ai import NexaAILLM
octopus_llm = NexaAILLM()
result = octopus_llm.invoke("Show recommended products for electronics.", category="shopping")
print(result)
If NEXA_API_KEY
is not set in env, you can also pass api_key as an argument when initializing:
octopus_llm = NexaAILLM(api_key=api_key)
You can also pass a list of catogories (corresponding to each of your prompts) when using generate
method of NexaAILLM
.
result = octopus_llm.generate(
prompts=[
"Show recommended products for electronics.",
"Find a Hotel to stay in Toyko from June 1 to June 10."
],
categories=[
"shopping",
"travel"
]
)
Exploit LCEL
from langchain_nexa_ai import NexaAILLM
from langchain_core.output_parsers import JsonOutputParser
octopus_llm = NexaAILLM()
parser = JsonOutputParser()
chain = octopus_llm | parser
result = chain.invoke(
input="Show me recommended electronics products",
config={
"llms": {
"NexaAILLM": {
"categories": ["shopping"]
}
}
}
)
print(result)
Chat Models
Coming soon.
TODO
- streaming
- docs
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
Hashes for langchain_nexa_ai-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb7cf595f875192968fd69e522934a81715a7091e7668f3d47623528757cac2 |
|
MD5 | 79dde93b9dcc8424255e10b74ce9455c |
|
BLAKE2b-256 | 4f7bcfb967b8c7efb81f3b95a566ee708f43c71ca23f0a3e2217ba851cb0bec1 |