Skip to main content

Python client library for the Fireworks.ai Generative AI Platform

Project description

Fireworks.ai Python library

Fireworks.ai Python Library provides a convenient API for accessing Fireworks supported LLMs. We are targeting our API to be very similar to OpenAI's API so you can replace OpenAI usage with minimal modifications

Installation

pip install --upgrade fireworks-ai

Example code

List

import fireworks.client
fireworks.client.api_key = "your-key"
print(fireworks.client.Models.list())
object='list' data=[Model(id="accounts/fireworks/models/llama-v2-7b", object="model", created=0), ...]

Completion

import fireworks.client
fireworks.client.api_key = "your-key"
completion = fireworks.client.Completion.create("accounts/fireworks/models/llama-v2-7b", "Once upon a time", temperature=0.7, n=2, max_tokens=16)
print(completion)
id='cmpl-988e179fa14fbaebdf17c713' object='text_completion' created=1691602259 model='accounts/fireworks/models/llama-v2-7b' choices=[Choice(text=', there was an emperor who reigned over all the kingdoms of the', index=0, finish_reason='length'), Choice(text=', a boy lived in a small house with his mom and dad. His', index=1, finish_reason='length')]

Async completion

import asyncio
import fireworks.client
fireworks.client.api_key = "your-key"
async def main():
    response = await fireworks.client.Completion.acreate("accounts/fireworks/models/llama-v2-7b", "Once upon a time", echo=True, max_tokens=16)
    print(response.choices[0].text)
asyncio.run(main())

then run the script

$ python test.py
Once upon a time, there used to be a huge mountain that was the most famous mou

Requirements

  • Python 3.9

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

fireworks-ai-0.3.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

fireworks_ai-0.3.0-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file fireworks-ai-0.3.0.tar.gz.

File metadata

  • Download URL: fireworks-ai-0.3.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.13.0 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.13

File hashes

Hashes for fireworks-ai-0.3.0.tar.gz
Algorithm Hash digest
SHA256 de46d929b65b16df7e87a9c144ee7dd3019a6ee910faae5aa4938ab2909b20bd
MD5 bf579622e5090a73a5a7e149f534f38f
BLAKE2b-256 95ac5b2e80122c79adc87f62535ec99abe40050755f13653a4e5fd81aaf08437

See more details on using hashes here.

File details

Details for the file fireworks_ai-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: fireworks_ai-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.13.0 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.13

File hashes

Hashes for fireworks_ai-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2edd55aeb1212644ed248b769330149408b7b1576ead522d9a215bdee26d4c4
MD5 47a95d065d3dfbc8ffec8b03b4541dca
BLAKE2b-256 ab9922c4e0358bbb510256715e89b37b2383a85a98a2ef1885f3f406fa524ef6

See more details on using hashes here.

Supported by

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