Skip to main content

Fireworks

caution

You are currently on a page documenting the use of Fireworks models as text completion models. Many popular models available on Fireworks are chat completion models.

You may be looking for this page instead.

This will help you get started with Fireworks completion models (LLMs) using LangChain. For detailed documentation on Fireworks features and configuration options, please refer to the API reference.

Overview

Integration details

ClassPackageLocalSerializablePY supportPackage downloadsPackage latest
Fireworks@langchain/communityNPM - DownloadsNPM - Version

Setup

To access Fireworks models you’ll need to create a Fireworks account, get an API key, and install the @langchain/community integration package.

Credentials

Head to fireworks.ai to sign up to Fireworks and generate an API key. Once you’ve done this set the FIREWORKS_API_KEY environment variable:

export FIREWORKS_API_KEY="your-api-key"

If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

# export LANGCHAIN_TRACING_V2="true"
# export LANGCHAIN_API_KEY="your-api-key"

Installation

The LangChain Fireworks integration lives in the @langchain/community package:

yarn add @langchain/community

Instantiation

Now we can instantiate our model object and generate chat completions:

  • TODO: Update model instantiation with relevant params.
import { Fireworks } from "@langchain/community/llms/fireworks";

const llm = new Fireworks({
model: "accounts/fireworks/models/llama-v3-70b-instruct",
temperature: 0,
maxTokens: undefined,
timeout: undefined,
maxRetries: 2,
// other params...
});

Invocation

const inputText = "Fireworks is an AI company that ";

const completion = await llm.invoke(inputText);
completion;
 helps businesses automate their workflows and processes using AI and machine learning. Our platform provides a suite of tools that enable companies to automate repetitive tasks, extract insights from data, and make predictions about future outcomes.

We're looking for a talented and motivated **Machine Learning Engineer** to join our team. As a Machine Learning Engineer at Fireworks, you will be responsible for designing, developing, and deploying machine learning models that drive business value for our customers. You will work closely with our data science team to develop and improve our AI models, and collaborate with our engineering team to integrate these models into our platform.

**Responsibilities:**

* Design, develop, and deploy machine learning models that drive business value for our customers
* Collaborate with data scientists to develop and improve AI models
* Work with the engineering team to integrate machine learning models into our platform
* Develop and maintain scalable and efficient machine learning pipelines
* Stay up-to-date with the latest developments in machine learning and AI
* Communicate complex technical concepts to non-technical stakeholders

**Requirements:**

* Bachelor's or Master's degree in Computer Science, Machine Learning, or a related field
* 3+ years of experience in machine learning engineering
* Strong programming skills in Python and experience with machine learning frameworks

Chaining

We can chain our completion model with a prompt template like so:

import { PromptTemplate } from "@langchain/core/prompts";

const prompt = new PromptTemplate({
template: "How to say {input} in {output_language}:\n",
inputVariables: ["input", "output_language"],
});

const chain = prompt.pipe(llm);
await chain.invoke({
output_language: "German",
input: "I love programming.",
});
Ich liebe Programmieren.

How to say I love coding. in German:
Ich liebe Coden.

How to say I love to code. in German:
Ich liebe es zu coden.

How to say I'm a programmer. in German:
Ich bin Programmierer.

How to say I'm a coder. in German:
Ich bin Coder.

How to say I'm a developer. in German:
Ich bin Entwickler.

How to say I'm a software engineer. in German:
Ich bin Software-Ingenieur.

How to say I'm a tech enthusiast. in German:
Ich bin Technik-Enthusiast.

How to say I'm passionate about technology. in German:
Ich bin leidenschaftlich für Technologie.

How to say I'm passionate about coding. in German:
Ich bin leidenschaftlich für Coden.

How to say I'm passionate about programming. in German:
Ich bin leidenschaftlich für Programmieren.

How to say I enjoy coding. in German:
Ich genieße Coden.

How to say I enjoy programming. in German:
Ich genieße Programmieren.

How to say I'm good at coding. in German:
Ich bin gut im Coden.

How to say I'm good at programming. in

Behind the scenes, Fireworks AI uses the OpenAI SDK and OpenAI compatible API, with some caveats:

  • Certain properties are not supported by the Fireworks API, see here.
  • Generation using multiple prompts is not supported.

API reference

For detailed documentation of all Fireworks features and configurations head to the API reference: https://api.js.langchain.com/classes/langchain_community_llms_fireworks.Fireworks.html


Was this page helpful?


You can also leave detailed feedback on GitHub.