Name | llama-index-llms-fireworks JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | llama-index llms fireworks integration |
upload_time | 2024-11-18 01:28:10 |
maintainer | None |
docs_url | None |
author | benjibc |
requires_python | <4.0,>=3.9 |
license | MIT |
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/a0/2d/43a90b3785ceff64f1357708cef08eeb128afbbe940d518e7f127f9d56fd/llama_index_llms_fireworks-0.3.0.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.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "305f295885481c6e5afc311e2704d229a229edde2f9709a2d042acdbca3b69ea",
"md5": "d448b4daeac159fe232e6a1dfd5c528d",
"sha256": "6d2fad66fc0bf5d9bd0424f8e9fb01504718b7b0ec5daf5c3876336178026110"
},
"downloads": -1,
"filename": "llama_index_llms_fireworks-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d448b4daeac159fe232e6a1dfd5c528d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 5429,
"upload_time": "2024-11-18T01:28:09",
"upload_time_iso_8601": "2024-11-18T01:28:09.519923Z",
"url": "https://files.pythonhosted.org/packages/30/5f/295885481c6e5afc311e2704d229a229edde2f9709a2d042acdbca3b69ea/llama_index_llms_fireworks-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a02d43a90b3785ceff64f1357708cef08eeb128afbbe940d518e7f127f9d56fd",
"md5": "3694bd060e623afd403f95cc147359f8",
"sha256": "cff316e5b0d67dd12912ca2df5302ff46e2a979fd722ec2159d49f015a480db0"
},
"downloads": -1,
"filename": "llama_index_llms_fireworks-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3694bd060e623afd403f95cc147359f8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 4564,
"upload_time": "2024-11-18T01:28:10",
"upload_time_iso_8601": "2024-11-18T01:28:10.391846Z",
"url": "https://files.pythonhosted.org/packages/a0/2d/43a90b3785ceff64f1357708cef08eeb128afbbe940d518e7f127f9d56fd/llama_index_llms_fireworks-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-18 01:28:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-llms-fireworks"
}