llama-index-llms-fireworks


Namellama-index-llms-fireworks JSON
Version 0.3.2 PyPI version JSON
download
home_pageNone
Summaryllama-index llms fireworks integration
upload_time2025-01-29 03:03:36
maintainerNone
docs_urlNone
authorbenjibc
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: Fireworks

## Installation

1. Install the required Python packages:

   ```bash
   %pip install llama-index-llms-fireworks
   %pip install llama-index
   ```

2. Set the Fireworks API key as an environment variable or pass it directly to the class constructor.

## Usage

### Basic Completion

To generate a simple completion, use the `complete` method:

```python
from llama_index.llms.fireworks import Fireworks

resp = Fireworks().complete("Paul Graham is ")
print(resp)
```

Example output:

```
Paul Graham is a well-known essayist, programmer, and startup entrepreneur. He co-founded Y Combinator, which supported startups like Dropbox, Airbnb, and Reddit.
```

### Basic Chat

To simulate a chat with multiple messages:

```python
from llama_index.core.llms import ChatMessage
from llama_index.llms.fireworks import Fireworks

messages = [
    ChatMessage(
        role="system", content="You are a pirate with a colorful personality"
    ),
    ChatMessage(role="user", content="What is your name"),
]
resp = Fireworks().chat(messages)
print(resp)
```

Example output:

```
Arr matey, ye be askin' for me name? Well, I be known as Captain Redbeard the Terrible!
```

### Streaming Completion

To stream a response in real-time using `stream_complete`:

```python
from llama_index.llms.fireworks import Fireworks

llm = Fireworks()
resp = llm.stream_complete("Paul Graham is ")

for r in resp:
    print(r.delta, end="")
```

Example output (partial):

```
Paul Graham is a well-known essayist, programmer, and venture capitalist...
```

### Streaming Chat

For a streamed conversation, use `stream_chat`:

```python
from llama_index.llms.fireworks import Fireworks
from llama_index.core.llms import ChatMessage

llm = Fireworks()
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="")
```

Example output (partial):

```
Arr matey, ye be askin' for me name? Well, I be known as Captain Redbeard the Terrible...
```

### Model Configuration

To configure the model for more specific behavior:

```python
from llama_index.llms.fireworks import Fireworks

llm = Fireworks(model="accounts/fireworks/models/firefunction-v1")
resp = llm.complete("Paul Graham is ")
print(resp)
```

Example output:

```
Paul Graham is an English-American computer scientist, entrepreneur, venture capitalist, and blogger.
```

### API Key Configuration

To use separate API keys for different instances:

```python
from llama_index.llms.fireworks import Fireworks

llm = Fireworks(
    model="accounts/fireworks/models/firefunction-v1", api_key="YOUR_API_KEY"
)
resp = llm.complete("Paul Graham is ")
print(resp)
```

### LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/fireworks/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-llms-fireworks",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "benjibc",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fd/b2/ff9e2e0d7e9847be910053bf95777eb19a5d8d21f9770ca038c183b71bb8/llama_index_llms_fireworks-0.3.2.tar.gz",
    "platform": null,
    "description": "# LlamaIndex Llms Integration: Fireworks\n\n## Installation\n\n1. Install the required Python packages:\n\n   ```bash\n   %pip install llama-index-llms-fireworks\n   %pip install llama-index\n   ```\n\n2. Set the Fireworks API key as an environment variable or pass it directly to the class constructor.\n\n## Usage\n\n### Basic Completion\n\nTo generate a simple completion, use the `complete` method:\n\n```python\nfrom llama_index.llms.fireworks import Fireworks\n\nresp = Fireworks().complete(\"Paul Graham is \")\nprint(resp)\n```\n\nExample output:\n\n```\nPaul Graham is a well-known essayist, programmer, and startup entrepreneur. He co-founded Y Combinator, which supported startups like Dropbox, Airbnb, and Reddit.\n```\n\n### Basic Chat\n\nTo simulate a chat with multiple messages:\n\n```python\nfrom llama_index.core.llms import ChatMessage\nfrom llama_index.llms.fireworks import Fireworks\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 = Fireworks().chat(messages)\nprint(resp)\n```\n\nExample output:\n\n```\nArr matey, ye be askin' for me name? Well, I be known as Captain Redbeard the Terrible!\n```\n\n### Streaming Completion\n\nTo stream a response in real-time using `stream_complete`:\n\n```python\nfrom llama_index.llms.fireworks import Fireworks\n\nllm = Fireworks()\nresp = llm.stream_complete(\"Paul Graham is \")\n\nfor r in resp:\n    print(r.delta, end=\"\")\n```\n\nExample output (partial):\n\n```\nPaul Graham is a well-known essayist, programmer, and venture capitalist...\n```\n\n### Streaming Chat\n\nFor a streamed conversation, use `stream_chat`:\n\n```python\nfrom llama_index.llms.fireworks import Fireworks\nfrom llama_index.core.llms import ChatMessage\n\nllm = Fireworks()\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)\n\nfor r in resp:\n    print(r.delta, end=\"\")\n```\n\nExample output (partial):\n\n```\nArr matey, ye be askin' for me name? Well, I be known as Captain Redbeard the Terrible...\n```\n\n### Model Configuration\n\nTo configure the model for more specific behavior:\n\n```python\nfrom llama_index.llms.fireworks import Fireworks\n\nllm = Fireworks(model=\"accounts/fireworks/models/firefunction-v1\")\nresp = llm.complete(\"Paul Graham is \")\nprint(resp)\n```\n\nExample output:\n\n```\nPaul Graham is an English-American computer scientist, entrepreneur, venture capitalist, and blogger.\n```\n\n### API Key Configuration\n\nTo use separate API keys for different instances:\n\n```python\nfrom llama_index.llms.fireworks import Fireworks\n\nllm = Fireworks(\n    model=\"accounts/fireworks/models/firefunction-v1\", api_key=\"YOUR_API_KEY\"\n)\nresp = llm.complete(\"Paul Graham is \")\nprint(resp)\n```\n\n### LLM Implementation example\n\nhttps://docs.llamaindex.ai/en/stable/examples/llm/fireworks/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index llms fireworks integration",
    "version": "0.3.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10fd78348c7b3eee5f02f6c81396ae02b9179480917eed134151dcaec59f3fae",
                "md5": "da65ceb713ef3a9d7bbc2111de22ed06",
                "sha256": "3c0516f5684e3a30c2ce915a1ea057ef9a3099137a6ead7eb891c007561702c0"
            },
            "downloads": -1,
            "filename": "llama_index_llms_fireworks-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "da65ceb713ef3a9d7bbc2111de22ed06",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 5467,
            "upload_time": "2025-01-29T03:03:34",
            "upload_time_iso_8601": "2025-01-29T03:03:34.781006Z",
            "url": "https://files.pythonhosted.org/packages/10/fd/78348c7b3eee5f02f6c81396ae02b9179480917eed134151dcaec59f3fae/llama_index_llms_fireworks-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdb2ff9e2e0d7e9847be910053bf95777eb19a5d8d21f9770ca038c183b71bb8",
                "md5": "6c870ee1d82ee3e457560913660618f6",
                "sha256": "767382b8d0b6e37aaf85f8147ab80868210e26a1d60cfe373ad2a5ac3caba7d5"
            },
            "downloads": -1,
            "filename": "llama_index_llms_fireworks-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "6c870ee1d82ee3e457560913660618f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 4491,
            "upload_time": "2025-01-29T03:03:36",
            "upload_time_iso_8601": "2025-01-29T03:03:36.503358Z",
            "url": "https://files.pythonhosted.org/packages/fd/b2/ff9e2e0d7e9847be910053bf95777eb19a5d8d21f9770ca038c183b71bb8/llama_index_llms_fireworks-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-29 03:03:36",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-llms-fireworks"
}
        
Elapsed time: 0.42469s