Skip to main content

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-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


Download files

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

Source Distribution

langchain_nexa_ai-0.1.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

langchain_nexa_ai-0.1.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file langchain_nexa_ai-0.1.4.tar.gz.

File metadata

  • Download URL: langchain_nexa_ai-0.1.4.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for langchain_nexa_ai-0.1.4.tar.gz
Algorithm Hash digest
SHA256 eb64b73f1278b4c0465367ac21b7669baff9c0c8c70dd5dd56c5ca1f5716b8a6
MD5 6bc97f7971f0fa1266d370fd6f2ba9c9
BLAKE2b-256 b59fe7c177a308b6324adc167903e18aff6616fe8daa1b842810ae0c9152c5ac

See more details on using hashes here.

Provenance

File details

Details for the file langchain_nexa_ai-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_nexa_ai-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f47ab5841d09f6f4b60aa19e175717e8f4cbf0b7d07b27a6e13f980465d4fd55
MD5 36bcbaf2d7c084c788549a4c050d76f0
BLAKE2b-256 379c53fae9f59d44e96c6f349279bda4fd23c65c80ef6883180b018cbb8ac09a

See more details on using hashes here.

Provenance

Supported by

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