Fireworks AI
info
我们支持所有Fireworks AI模型,只需在发送完成请求时设置 fireworks_ai/ 作为前缀
API密钥
# 环境变量
os.environ['FIREWORKS_AI_API_KEY']
示例用法
from litellm import completion
import os
os.environ['FIREWORKS_AI_API_KEY'] = ""
response = completion(
model="fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)
示例用法 - 流式传输
from litellm import completion
import os
os.environ['FIREWORKS_AI_API_KEY'] = ""
response = completion(
model="fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct",
messages=[
{"role": "user", "content": "hello from litellm"}
],
stream=True
)
for chunk in response:
print(chunk)
与LiteLLM代理一起使用
1. 在config.yaml上设置Fireworks AI模型
model_list:
- model_name: fireworks-llama-v3-70b-instruct
litellm_params:
model: fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct
api_key: "os.environ/FIREWORKS_AI_API_KEY"
2. 启动代理
litellm --config config.yaml
3. 测试它
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--data ' {
"model": "fireworks-llama-v3-70b-instruct",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
]
}
'
import openai
client = openai.OpenAI(
api_key="anything",
base_url="http://0.0.0.0:4000"
)
# 请求发送到在litellm代理上设置的模型,`litellm --model`
response = client.chat.completions.create(model="fireworks-llama-v3-70b-instruct", messages = [
{
"role": "user",
"content": "this is a test request, write a short poem"
}
])
print(response)
from langchain.chat_models import ChatOpenAI
from langchain.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
from langchain.schema import HumanMessage, SystemMessage
chat = ChatOpenAI(
openai_api_base="http://0.0.0.0:4000", # 将openai_api_base设置为LiteLLM代理
model = "fireworks-llama-v3-70b-instruct",
temperature=0.1
)
messages = [
SystemMessage(
content="You are a helpful assistant that im using to make a test request to."
),
HumanMessage(
content="test from litellm. tell me why it's amazing in 1 sentence"
),
]
response = chat(messages)
print(response)
支持的模型 - 所有Fireworks AI模型都支持!
info
我们支持所有Fireworks AI模型,只需在发送完成请求时设置 fireworks_ai/ 作为前缀
| 模型名称 | 函数调用 |
|---|---|
| llama-v3p2-1b-instruct | completion(model="fireworks_ai/llama-v3p2-1b-instruct", messages) |
| llama-v3p2-3b-instruct | completion(model="fireworks_ai/llama-v3p2-3b-instruct", messages) |
| llama-v3p2-11b-vision-instruct | completion(model="fireworks_ai/llama-v3p2-11b-vision-instruct", messages) |
| llama-v3p2-90b-vision-instruct | completion(model="fireworks_ai/llama-v3p2-90b-vision-instruct", messages) |
| mixtral-8x7b-instruct | completion(model="fireworks_ai/mixtral-8x7b-instruct", messages) |
| firefunction-v1 | completion(model="fireworks_ai/firefunction-v1", messages) |
| llama-v2-70b-chat | completion(model="fireworks_ai/llama-v2-70b-chat", messages) |
支持的嵌入模型
info
我们支持所有Fireworks AI模型,只需在发送嵌入请求时设置 fireworks_ai/ 作为前缀
| 模型名称 | 函数调用 |
|---|---|
| fireworks_ai/nomic-ai/nomic-embed-text-v1.5 | response = litellm.embedding(model="fireworks_ai/nomic-ai/nomic-embed-text-v1.5", input=input_text) |
| fireworks_ai/nomic-ai/nomic-embed-text-v1 | response = litellm.embedding(model="fireworks_ai/nomic-ai/nomic-embed-text-v1", input=input_text) |
| fireworks_ai/WhereIsAI/UAE-Large-V1 | response = litellm.embedding(model="fireworks_ai/WhereIsAI/UAE-Large-V1", input=input_text) |
| fireworks_ai/thenlper/gte-large | response = litellm.embedding(model="fireworks_ai/thenlper/gte-large", input=input_text) |
| fireworks_ai/thenlper/gte-base | response = litellm.embedding(model="fireworks_ai/thenlper/gte-base", input=input_text) |