本页还没有译文
本页 22 段还没译成한국어,下面显示的是英文原文。ChatFireworks integration
还没翻译译自英文(docs.langchain.com)本页 22 段都还没译
Fireworks AI is an AI inference platform to run and customize models. For a list of all models served by Fireworks see the Fireworks docs.
This guide will help you getting started with ChatFireworks chat models. For detailed documentation of all ChatFireworks features and configurations head to the API reference.
Overview
Integration details
| Class | Package | Serializable | PY support | Downloads | Version |
|---|---|---|---|---|---|
ChatFireworks | @langchain/fireworks | ✅ | ✅ |
Model features
See the links in the table headers below for guides on how to use specific features.
| Tool calling | Structured output | Image input | Audio input | Video input | Token-level streaming | Token usage | Logprobs |
|---|---|---|---|---|---|---|---|
| ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
Setup
To access ChatFireworks models you'll need to create a Fireworks account, get an API key, and install the @langchain/fireworks integration package.
Credentials
Head to the Fireworks website 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 LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"Installation
The LangChain ChatFireworks integration lives in the @langchain/fireworks package:
npm install @langchain/fireworks @langchain/coreyarn add @langchain/fireworks @langchain/corepnpm add @langchain/fireworks @langchain/coreInstantiation
Now we can instantiate our model object and generate chat completions:
import { ChatFireworks } from "@langchain/fireworks"
const llm = new ChatFireworks({
model: "accounts/fireworks/models/llama-v3p1-70b-instruct",
temperature: 0,
maxTokens: undefined,
timeout: undefined,
maxRetries: 2,
// other params...
})Invocation
const aiMsg = await llm.invoke([
[
"system",
"You are a helpful assistant that translates English to French. Translate the user sentence.",
],
["human", "I love programming."],
])
aiMsgAIMessage {
"id": "chatcmpl-9rBYHbb6QYRrKyr2tMhO9pH4AYXR4",
"content": "J'adore la programmation.",
"additional_kwargs": {},
"response_metadata": {
"tokenUsage": {
"completionTokens": 8,
"promptTokens": 31,
"totalTokens": 39
},
"finish_reason": "stop"
},
"tool_calls": [],
"invalid_tool_calls": [],
"usage_metadata": {
"input_tokens": 31,
"output_tokens": 8,
"total_tokens": 39
}
}console.log(aiMsg.content)J'adore la programmation.API reference
For detailed documentation of all ChatFireworks features and configurations head to the API reference.