| Name | llama-index-llms-keywordsai JSON |
| Version |
1.1.0
JSON |
| download |
| home_page | None |
| Summary | llama-index llms keywordsai integration |
| upload_time | 2025-07-31 02:42:41 |
| maintainer | None |
| docs_url | None |
| author | llama-index |
| requires_python | <4.0,>=3.9 |
| license | None |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# LlamaIndex Llms Integration: KeywordsAI
## Installation
To install the required package, run:
```bash
%pip install llama-index-llms-keywordsai
```
## Setup
1. Set your KeywordsAI API key as an environment variable. You can replace `"sk-..."` with your actual API key:
```python
import os
os.environ["OPENAI_API_KEY"] = "sk-..."
```
## Basic Usage
### Generate Completions
To generate a completion for a prompt, use the `complete` method:
```python
from llama_index.llms.keywordsai import KeywordsAI
resp = KeywordsAI().complete("Paul Graham is ")
print(resp)
```
### Chat Responses
To send a chat message and receive a response, create a list of `ChatMessage` instances and use the `chat` method:
```python
from llama_index.core.llms import ChatMessage
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality."
),
ChatMessage(role="user", content="What is your name?"),
]
resp = KeywordsAI().chat(messages)
print(resp)
```
## Streaming Responses
### Stream Complete
To stream responses for a prompt, use the `stream_complete` method:
```python
from llama_index.llms.keywordsai import KeywordsAI
llm = KeywordsAI()
resp = llm.stream_complete("Paul Graham is ")
for r in resp:
print(r.delta, end="")
```
### Stream Chat
To stream chat responses, use the `stream_chat` method:
```python
from llama_index.llms.keywordsai import KeywordsAI
from llama_index.core.llms import ChatMessage
llm = KeywordsAI()
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality."
),
ChatMessage(role="user", content="What is your name?"),
]
resp = llm.stream_chat(messages)
for r in resp:
print(r.delta, end="")
```
## Configure Model
You can specify a particular model when creating the `KeywordsAI` instance:
```python
llm = KeywordsAI(model="gpt-3.5-turbo")
resp = llm.complete("Paul Graham is ")
print(resp)
messages = [
ChatMessage(
role="system", content="You are a pirate with a colorful personality."
),
ChatMessage(role="user", content="What is your name?"),
]
resp = llm.chat(messages)
print(resp)
```
## Asynchronous Usage
You can also use asynchronous methods for completion:
```python
from llama_index.llms.keywordsai import KeywordsAI
llm = KeywordsAI(model="gpt-3.5-turbo")
resp = await llm.acomplete("Paul Graham is ")
print(resp)
```
## Set API Key at a Per-Instance Level
If desired, you can have separate LLM instances use different API keys:
```python
from llama_index.llms.keywordsai import KeywordsAI
llm = KeywordsAI(model="gpt-3.5-turbo", api_key="BAD_KEY")
resp = KeywordsAI().complete("Paul Graham is ")
print(resp)
```
### LLM Implementation example
https://docs.llamaindex.ai/en/stable/examples/llm/keywordsai/
Raw data
{
"_id": null,
"home_page": null,
"name": "llama-index-llms-keywordsai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "llama-index",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/69/34/6e93745e8dafbacdd3774fbd0967ed080048f16fc45fa8be1720591d9450/llama_index_llms_keywordsai-1.1.0.tar.gz",
"platform": null,
"description": "# LlamaIndex Llms Integration: KeywordsAI\n\n## Installation\n\nTo install the required package, run:\n\n```bash\n%pip install llama-index-llms-keywordsai\n```\n\n## Setup\n\n1. Set your KeywordsAI API key as an environment variable. You can replace `\"sk-...\"` with your actual API key:\n\n```python\nimport os\n\nos.environ[\"OPENAI_API_KEY\"] = \"sk-...\"\n```\n\n## Basic Usage\n\n### Generate Completions\n\nTo generate a completion for a prompt, use the `complete` method:\n\n```python\nfrom llama_index.llms.keywordsai import KeywordsAI\n\nresp = KeywordsAI().complete(\"Paul Graham is \")\nprint(resp)\n```\n\n### Chat Responses\n\nTo send a chat message and receive a response, create a list of `ChatMessage` instances and use the `chat` method:\n\n```python\nfrom llama_index.core.llms import ChatMessage\n\nmessages = [\n ChatMessage(\n role=\"system\", content=\"You are a pirate with a colorful personality.\"\n ),\n ChatMessage(role=\"user\", content=\"What is your name?\"),\n]\nresp = KeywordsAI().chat(messages)\nprint(resp)\n```\n\n## Streaming Responses\n\n### Stream Complete\n\nTo stream responses for a prompt, use the `stream_complete` method:\n\n```python\nfrom llama_index.llms.keywordsai import KeywordsAI\n\nllm = KeywordsAI()\nresp = llm.stream_complete(\"Paul Graham is \")\nfor r in resp:\n print(r.delta, end=\"\")\n```\n\n### Stream Chat\n\nTo stream chat responses, use the `stream_chat` method:\n\n```python\nfrom llama_index.llms.keywordsai import KeywordsAI\nfrom llama_index.core.llms import ChatMessage\n\nllm = KeywordsAI()\nmessages = [\n ChatMessage(\n role=\"system\", content=\"You are a pirate with a colorful personality.\"\n ),\n ChatMessage(role=\"user\", content=\"What is your name?\"),\n]\nresp = llm.stream_chat(messages)\nfor r in resp:\n print(r.delta, end=\"\")\n```\n\n## Configure Model\n\nYou can specify a particular model when creating the `KeywordsAI` instance:\n\n```python\nllm = KeywordsAI(model=\"gpt-3.5-turbo\")\nresp = llm.complete(\"Paul Graham is \")\nprint(resp)\n\nmessages = [\n ChatMessage(\n role=\"system\", content=\"You are a pirate with a colorful personality.\"\n ),\n ChatMessage(role=\"user\", content=\"What is your name?\"),\n]\nresp = llm.chat(messages)\nprint(resp)\n```\n\n## Asynchronous Usage\n\nYou can also use asynchronous methods for completion:\n\n```python\nfrom llama_index.llms.keywordsai import KeywordsAI\n\nllm = KeywordsAI(model=\"gpt-3.5-turbo\")\nresp = await llm.acomplete(\"Paul Graham is \")\nprint(resp)\n```\n\n## Set API Key at a Per-Instance Level\n\nIf desired, you can have separate LLM instances use different API keys:\n\n```python\nfrom llama_index.llms.keywordsai import KeywordsAI\n\nllm = KeywordsAI(model=\"gpt-3.5-turbo\", api_key=\"BAD_KEY\")\nresp = KeywordsAI().complete(\"Paul Graham is \")\nprint(resp)\n```\n\n### LLM Implementation example\n\nhttps://docs.llamaindex.ai/en/stable/examples/llm/keywordsai/\n",
"bugtrack_url": null,
"license": null,
"summary": "llama-index llms keywordsai integration",
"version": "1.1.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cec676150e318a08f46ab1eca027e67780419e6b61d441a7a2253eae98b4d7e5",
"md5": "1438dc88a75957a611fd79709cbc1a01",
"sha256": "fc158a565e0130f0ce9808744eac7c9d6e041165e25acc31b575b3b5552da723"
},
"downloads": -1,
"filename": "llama_index_llms_keywordsai-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1438dc88a75957a611fd79709cbc1a01",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 7821,
"upload_time": "2025-07-31T02:42:40",
"upload_time_iso_8601": "2025-07-31T02:42:40.116978Z",
"url": "https://files.pythonhosted.org/packages/ce/c6/76150e318a08f46ab1eca027e67780419e6b61d441a7a2253eae98b4d7e5/llama_index_llms_keywordsai-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "69346e93745e8dafbacdd3774fbd0967ed080048f16fc45fa8be1720591d9450",
"md5": "9ab0193c733c76a2fa7f53e4d2de8c98",
"sha256": "e07d96766de852a37c2c4fd560f6139eb37f25677d90eafe0e355a27796c48f6"
},
"downloads": -1,
"filename": "llama_index_llms_keywordsai-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "9ab0193c733c76a2fa7f53e4d2de8c98",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 7662,
"upload_time": "2025-07-31T02:42:41",
"upload_time_iso_8601": "2025-07-31T02:42:41.078817Z",
"url": "https://files.pythonhosted.org/packages/69/34/6e93745e8dafbacdd3774fbd0967ed080048f16fc45fa8be1720591d9450/llama_index_llms_keywordsai-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 02:42:41",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-llms-keywordsai"
}