LangChain-Fireworks
This is the partner package for tying Fireworks.ai and LangChain. Fireworks really strive to provide good support for LangChain use cases, so if you run into any issues please let us know. You can reach out to us in our Discord channel
Installation
To use the langchain-fireworks package, follow these installation steps:
pip install gigachain-fireworks
Basic usage
Setting up
-
Sign in to Fireworks AI to obtain an API Key to access the models, and make sure it is set as the
FIREWORKS_API_KEYenvironment variable.Once you've signed in and obtained an API key, follow these steps to set the
FIREWORKS_API_KEYenvironment variable:- Linux/macOS: Open your terminal and execute the following command:
export FIREWORKS_API_KEY='your_api_key'
Note: To make this environment variable persistent across terminal sessions, add the above line to your
~/.bashrc,~/.bash_profile, or~/.zshrcfile.- Windows: For Command Prompt, use:
set FIREWORKS_API_KEY=your_api_key
-
Set up your model using a model id. If the model is not set, the default model is
fireworks-llama-v2-7b-chat. See the full, most up-to-date model list on fireworks.ai.
import getpass
import os
# Initialize a Fireworks model
llm = Fireworks(
model="accounts/fireworks/models/mixtral-8x7b-instruct",
base_url="https://api.fireworks.ai/inference/v1/completions",
)
Calling the Model Directly
You can call the model directly with string prompts to get completions.
# Single prompt
output = llm.invoke("Who's the best quarterback in the NFL?")
print(output)
# Calling multiple prompts
output = llm.generate(
[
"Who's the best cricket player in 2016?",
"Who's the best basketball player in the league?",
]
)
print(output.generations)
Advanced usage
Tool use: LangChain Agent + Fireworks function calling model
Please checkout how to teach Fireworks function calling model to use a calculator here.
Fireworks focus on delivering the best experience for fast model inference as well as tool use. You can check out our blog for more details on how it fares compares to GPT-4, the punchline is that it is on par with GPT-4 in terms just function calling use cases, but it is way faster and much cheaper.
RAG: LangChain agent + Fireworks function calling model + MongoDB + Nomic AI embeddings
Please check out the cookbook here for an end to end flow
Metadata
Release files for gigachain-fireworks 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gigachain_fireworks-0.1.7.tar.gz | 16.5 kB | Without provenance | Details for gigachain_fireworks-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gigachain_fireworks-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for gigachain_fireworks-0.1.7-py3-none-any.whl |
Total release size: 33.5 kB
Release files / gigachain_fireworks-0.1.7.tar.gz
| Download URL | gigachain_fireworks-0.1.7.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
739c429b86dbf2480eafee0331b1ec21b59cdedc690074b77ffe2175fba5a10a
|
|
BLAKE2b-256 checksum How to use checksums |
f974c237aadcfb36e505d606728f6097b0863725d2bd09a7b0d2040ce187db90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Darwin/23.5.0
|
Release files / gigachain_fireworks-0.1.7-py3-none-any.whl
| Download URL | gigachain_fireworks-0.1.7-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51a42397ee604199f5468f946fcb2b0804faadca5fa434cccb0a17ec2570cd6b
|
|
BLAKE2b-256 checksum How to use checksums |
8652997e676dcd2f8db88f08495a11ffac926cb1f0bed97dfab3901cc6e7ac1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Darwin/23.5.0
|
Security for gigachain-fireworks 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.