Skip to main content

llama-index llms fireworks integration

Project description

LlamaIndex Llms Integration: Fireworks

Installation

  1. Install the required Python packages:

    %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:

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:

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:

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:

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:

from llama_index.llms.fireworks import Fireworks

llm = Fireworks(model="accounts/fireworks/models/kimi-k2-instruct-0905")
resp = llm.complete("Paul Graham is ")
print(resp)

Example output:

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

For a full list of models, check the Fireworks website.

API Key Configuration

To use separate API keys for different instances:

from llama_index.llms.fireworks import Fireworks

llm = Fireworks(
    model="accounts/fireworks/models/kimi-k2-instruct-0905",
    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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_llms_fireworks-0.5.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_fireworks-0.5.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_fireworks-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_fireworks-0.5.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_fireworks-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f2324f4bec64a994ff12fd2767f2be63db46f2191e6688c53d0f9a1a5980299c
MD5 47e2a5eaad3f4a3cf4f3935ccd9bcd26
BLAKE2b-256 dc625f156d398fbcf3ca9ab5f0aaeeac5cfc359e2c82bdd2c210a0d10d67ac4c

See more details on using hashes here.

File details

Details for the file llama_index_llms_fireworks-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_fireworks-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_fireworks-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bd3b8cd5fa446f9f213f9dbab63ccd49b92c98b774a080acb693f3eee6512eb
MD5 c6940c98c13a80b8b18755db07554fc1
BLAKE2b-256 c2d1ffeecaecdeab8b4e0242f4569fbd3baab23a5b5f6e4cd3d06ab0703a1825

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page