llama-index-llms-everlyai


Namellama-index-llms-everlyai JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
Summaryllama-index llms everlyai integration
upload_time2024-11-18 01:28:54
maintainerNone
docs_urlNone
authorYour Name
requires_python<4.0,>=3.9
licenseMIT
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.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/f9/a4/c72e673c9a506d749a80723305c0def7c316ed49128dbce3c532da83eb3a/llama_index_llms_everlyai-0.3.0.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.3.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c4905a38d093a5e7afaf350b16ca9bc57ca5ea2a653a279eb9cc2b120755a1d8",
                "md5": "aa68e00aa67ff477d4e009ffc2ad54a4",
                "sha256": "9c14fbf7639262fe452fbbcbfdcaaa901387d191ca40b441cb280f915126540b"
            },
            "downloads": -1,
            "filename": "llama_index_llms_everlyai-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa68e00aa67ff477d4e009ffc2ad54a4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 4106,
            "upload_time": "2024-11-18T01:28:53",
            "upload_time_iso_8601": "2024-11-18T01:28:53.144266Z",
            "url": "https://files.pythonhosted.org/packages/c4/90/5a38d093a5e7afaf350b16ca9bc57ca5ea2a653a279eb9cc2b120755a1d8/llama_index_llms_everlyai-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f9a4c72e673c9a506d749a80723305c0def7c316ed49128dbce3c532da83eb3a",
                "md5": "dbc09262b2e0668db8d1b42b058fc726",
                "sha256": "40aa5d16c68e56533dacf444e3d73deab466142852f9e39734debb529abbc919"
            },
            "downloads": -1,
            "filename": "llama_index_llms_everlyai-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "dbc09262b2e0668db8d1b42b058fc726",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 3631,
            "upload_time": "2024-11-18T01:28:54",
            "upload_time_iso_8601": "2024-11-18T01:28:54.739134Z",
            "url": "https://files.pythonhosted.org/packages/f9/a4/c72e673c9a506d749a80723305c0def7c316ed49128dbce3c532da83eb3a/llama_index_llms_everlyai-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 01:28:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-llms-everlyai"
}
        
Elapsed time: 0.45859s