langchain-nexa-ai


Namelangchain-nexa-ai JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/langchain-ai/langchain
SummaryAn integration package connecting NexaAI and LangChain
upload_time2024-07-02 00:52:37
maintainerNone
docs_urlNone
authorEthan Wang
requires_python<4.0,>=3.8.1
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # langchain-nexa-ai

This package contains the LangChain integration with [Nexa AI](https://www.nexa4ai.com/).

## Installation

```bash
pip install -U langchain-nexa-ai
```

And you should get an api key from [Nexa Hub](https://hub.nexa4ai.com/api_keys) 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](./docs/tutorial.ipynb) and [Nexa AI documentation](https://docs.nexa4ai.com/docs/overview) for more details!

```python
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:

```python
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`.

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

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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/langchain-ai/langchain",
    "name": "langchain-nexa-ai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ethan Wang",
    "author_email": "ethan@nexa4ai.com",
    "download_url": "https://files.pythonhosted.org/packages/b5/9f/e7c177a308b6324adc167903e18aff6616fe8daa1b842810ae0c9152c5ac/langchain_nexa_ai-0.1.4.tar.gz",
    "platform": null,
    "description": "# langchain-nexa-ai\n\nThis package contains the LangChain integration with [Nexa AI](https://www.nexa4ai.com/).\n\n## Installation\n\n```bash\npip install -U langchain-nexa-ai\n```\n\nAnd you should get an api key from [Nexa Hub](https://hub.nexa4ai.com/api_keys) and set it as an environment variable (`NEXA_API_KEY`)\n\n## LLMs\n\n`NexaAILLM` class exposes Octopus LLMs from NexaAI. We currently support four catogories: `shopping`, `conference`, `streaming`, and `travel`. See our [langchain-nexa-ai tutorial](./docs/tutorial.ipynb) and [Nexa AI documentation](https://docs.nexa4ai.com/docs/overview) for more details!\n\n```python\nfrom langchain_nexa_ai import NexaAILLM\n\noctopus_llm = NexaAILLM()\nresult = octopus_llm.invoke(\"Show recommended products for electronics.\", category=\"shopping\")\nprint(result)\n```\n\nIf `NEXA_API_KEY` is not set in env, you can also pass api_key as an argument when initializing:\n\n```python\noctopus_llm = NexaAILLM(api_key=api_key)\n```\n\nYou can also pass a list of catogories (corresponding to each of your prompts) when using `generate` method of `NexaAILLM`.\n\n```python\nresult = octopus_llm.generate(\n    prompts=[\n        \"Show recommended products for electronics.\",\n        \"Find a Hotel to stay in Toyko from June 1 to June 10.\"\n    ],\n    categories=[\n        \"shopping\",\n        \"travel\"\n    ]\n)\n```\n\n### Exploit LCEL\n\n```python\nfrom langchain_nexa_ai import NexaAILLM\nfrom langchain_core.output_parsers import JsonOutputParser\n\noctopus_llm = NexaAILLM()\nparser = JsonOutputParser()\n\nchain = octopus_llm | parser\n\nresult = chain.invoke(\n    input=\"Show me recommended electronics products\",\n    config={\n        \"llms\": {\n            \"NexaAILLM\": {\n                \"categories\": [\"shopping\"]\n            }\n        }\n    }\n)\nprint(result)\n```\n\n## Chat Models\n\nComing soon.\n\n## TODO\n\n- [ ] streaming\n- [ ] docs\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An integration package connecting NexaAI and LangChain",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/langchain-ai/langchain",
        "Repository": "https://github.com/langchain-ai/langchain",
        "Source Code": "https://github.com/langchain-ai/langchain/tree/master/libs/partners/nexa-ai"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "379c53fae9f59d44e96c6f349279bda4fd23c65c80ef6883180b018cbb8ac09a",
                "md5": "36bcbaf2d7c084c788549a4c050d76f0",
                "sha256": "f47ab5841d09f6f4b60aa19e175717e8f4cbf0b7d07b27a6e13f980465d4fd55"
            },
            "downloads": -1,
            "filename": "langchain_nexa_ai-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36bcbaf2d7c084c788549a4c050d76f0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8.1",
            "size": 4935,
            "upload_time": "2024-07-02T00:52:36",
            "upload_time_iso_8601": "2024-07-02T00:52:36.640058Z",
            "url": "https://files.pythonhosted.org/packages/37/9c/53fae9f59d44e96c6f349279bda4fd23c65c80ef6883180b018cbb8ac09a/langchain_nexa_ai-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b59fe7c177a308b6324adc167903e18aff6616fe8daa1b842810ae0c9152c5ac",
                "md5": "6bc97f7971f0fa1266d370fd6f2ba9c9",
                "sha256": "eb64b73f1278b4c0465367ac21b7669baff9c0c8c70dd5dd56c5ca1f5716b8a6"
            },
            "downloads": -1,
            "filename": "langchain_nexa_ai-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "6bc97f7971f0fa1266d370fd6f2ba9c9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8.1",
            "size": 4676,
            "upload_time": "2024-07-02T00:52:37",
            "upload_time_iso_8601": "2024-07-02T00:52:37.643430Z",
            "url": "https://files.pythonhosted.org/packages/b5/9f/e7c177a308b6324adc167903e18aff6616fe8daa1b842810ae0c9152c5ac/langchain_nexa_ai-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-02 00:52:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "langchain-ai",
    "github_project": "langchain",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "langchain-nexa-ai"
}
        
Elapsed time: 0.44180s