Name | llama-index-llms-everlyai JSON |
Version |
0.2.1
JSON |
| download |
home_page | None |
Summary | llama-index llms everlyai integration |
upload_time | 2024-10-08 22:26:19 |
maintainer | None |
docs_url | None |
author | Your Name |
requires_python | <4.0,>=3.8.1 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# LlamaIndex Llms Integration: Everlyai
## Installation
1. Install the required Python packages:
```bash
%pip install llama-index-llms-everlyai
!pip install llama-index
```
2. Set the EverlyAI API key as an environment variable or pass it directly to the constructor:
```python
import os
os.environ["EVERLYAI_API_KEY"] = "<your-api-key>"
```
Or use it directly in your Python code:
```python
llm = EverlyAI(api_key="your-api-key")
```
## Usage
### Basic Chat
To send a message and get a response (e.g., a joke):
```python
from llama_index.llms.everlyai import EverlyAI
from llama_index.core.llms import ChatMessage
# Initialize EverlyAI with API key
llm = EverlyAI(api_key="your-api-key")
# Create a message
message = ChatMessage(role="user", content="Tell me a joke")
# Call the chat method
resp = llm.chat([message])
print(resp)
```
Example output:
```
Why don't scientists trust atoms?
Because they make up everything!
```
### Streamed Chat
To stream a response for more dynamic conversations (e.g., storytelling):
```python
message = ChatMessage(role="user", content="Tell me a story in 250 words")
resp = llm.stream_chat([message])
for r in resp:
print(r.delta, end="")
```
Example output (partial):
```
As the sun set over the horizon, a young girl named Lily sat on the beach, watching the waves roll in...
```
### Complete Tasks
To use the `complete` method for simpler tasks like telling a joke:
```python
resp = llm.complete("Tell me a joke")
print(resp)
```
Example output:
```
Why don't scientists trust atoms?
Because they make up everything!
```
### Streamed Completion
For generating responses like stories using `stream_complete`:
```python
resp = llm.stream_complete("Tell me a story in 250 words")
for r in resp:
print(r.delta, end="")
```
Example output (partial):
```
As the sun set over the horizon, a young girl named Maria sat on the beach, watching the waves roll in...
```
## Notes
- Ensure the API key is set correctly before making any requests.
- The `stream_chat` and `stream_complete` methods allow for real-time response streaming, making them ideal for dynamic and lengthy outputs like stories.
### LLM Implementation example
https://docs.llamaindex.ai/en/stable/examples/llm/everlyai/
Raw data
{
"_id": null,
"home_page": null,
"name": "llama-index-llms-everlyai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8.1",
"maintainer_email": null,
"keywords": null,
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/81/3c/f213a118c6f7faadc4558f3f865b331624e70235784fc99bf32824f9191f/llama_index_llms_everlyai-0.2.1.tar.gz",
"platform": null,
"description": "# LlamaIndex Llms Integration: Everlyai\n\n## Installation\n\n1. Install the required Python packages:\n\n ```bash\n %pip install llama-index-llms-everlyai\n !pip install llama-index\n ```\n\n2. Set the EverlyAI API key as an environment variable or pass it directly to the constructor:\n\n ```python\n import os\n\n os.environ[\"EVERLYAI_API_KEY\"] = \"<your-api-key>\"\n ```\n\n Or use it directly in your Python code:\n\n ```python\n llm = EverlyAI(api_key=\"your-api-key\")\n ```\n\n## Usage\n\n### Basic Chat\n\nTo send a message and get a response (e.g., a joke):\n\n```python\nfrom llama_index.llms.everlyai import EverlyAI\nfrom llama_index.core.llms import ChatMessage\n\n# Initialize EverlyAI with API key\nllm = EverlyAI(api_key=\"your-api-key\")\n\n# Create a message\nmessage = ChatMessage(role=\"user\", content=\"Tell me a joke\")\n\n# Call the chat method\nresp = llm.chat([message])\nprint(resp)\n```\n\nExample output:\n\n```\nWhy don't scientists trust atoms?\nBecause they make up everything!\n```\n\n### Streamed Chat\n\nTo stream a response for more dynamic conversations (e.g., storytelling):\n\n```python\nmessage = ChatMessage(role=\"user\", content=\"Tell me a story in 250 words\")\nresp = llm.stream_chat([message])\n\nfor r in resp:\n print(r.delta, end=\"\")\n```\n\nExample output (partial):\n\n```\nAs the sun set over the horizon, a young girl named Lily sat on the beach, watching the waves roll in...\n```\n\n### Complete Tasks\n\nTo use the `complete` method for simpler tasks like telling a joke:\n\n```python\nresp = llm.complete(\"Tell me a joke\")\nprint(resp)\n```\n\nExample output:\n\n```\nWhy don't scientists trust atoms?\nBecause they make up everything!\n```\n\n### Streamed Completion\n\nFor generating responses like stories using `stream_complete`:\n\n```python\nresp = llm.stream_complete(\"Tell me a story in 250 words\")\n\nfor r in resp:\n print(r.delta, end=\"\")\n```\n\nExample output (partial):\n\n```\nAs the sun set over the horizon, a young girl named Maria sat on the beach, watching the waves roll in...\n```\n\n## Notes\n\n- Ensure the API key is set correctly before making any requests.\n- The `stream_chat` and `stream_complete` methods allow for real-time response streaming, making them ideal for dynamic and lengthy outputs like stories.\n\n### LLM Implementation example\n\nhttps://docs.llamaindex.ai/en/stable/examples/llm/everlyai/\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index llms everlyai integration",
"version": "0.2.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7590e20a39d4b0cef2a81d6797208190a76739229bad1645e301d9c5c503d2f9",
"md5": "32bbf682743f5be6f23be57e40428faa",
"sha256": "4acd43a9e54f15fbc062a6d625815f73a2a5c23fc4dad0edb3079e8f20415099"
},
"downloads": -1,
"filename": "llama_index_llms_everlyai-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32bbf682743f5be6f23be57e40428faa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8.1",
"size": 4106,
"upload_time": "2024-10-08T22:26:18",
"upload_time_iso_8601": "2024-10-08T22:26:18.482279Z",
"url": "https://files.pythonhosted.org/packages/75/90/e20a39d4b0cef2a81d6797208190a76739229bad1645e301d9c5c503d2f9/llama_index_llms_everlyai-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "813cf213a118c6f7faadc4558f3f865b331624e70235784fc99bf32824f9191f",
"md5": "dd53d9a4486a58e8d6d84e23938370be",
"sha256": "7b8b5ca6216fdaf2adcf62d6e1d0a452376cd867b9cb5c515796a2c2f8449f48"
},
"downloads": -1,
"filename": "llama_index_llms_everlyai-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "dd53d9a4486a58e8d6d84e23938370be",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8.1",
"size": 3550,
"upload_time": "2024-10-08T22:26:19",
"upload_time_iso_8601": "2024-10-08T22:26:19.408084Z",
"url": "https://files.pythonhosted.org/packages/81/3c/f213a118c6f7faadc4558f3f865b331624e70235784fc99bf32824f9191f/llama_index_llms_everlyai-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-08 22:26:19",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-llms-everlyai"
}