Merge pull request #1820 from cmodi-meta/llama-api-support

Add Llama API Support
This commit is contained in:
better629 2025-06-30 19:41:26 +08:00 committed by GitHub
commit 5aae56e863
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
llm:
api_type: llama_api
base_url: "https://api.llama.com/compat/v1/"
api_key: "YOUR_API_KEY"
model: "Llama-3.3-70B-Instruct"

View file

@ -0,0 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
llm:
api_type: llama_api
base_url: "https://api.llama.com/compat/v1/"
api_key: "YOUR_API_KEY"
model: "Llama-3.3-8B-Instruct"

View file

@ -0,0 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
llm:
api_type: llama_api
base_url: "https://api.llama.com/compat/v1/"
api_key: "YOUR_API_KEY"
model: "Llama-4-Scout-17B-16E-Instruct-FP8"

View file

@ -0,0 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
llm:
api_type: llama_api
base_url: "https://api.llama.com/compat/v1/"
api_key: "YOUR_API_KEY"
model: "Llama-4-Maverick-17B-128E-Instruct-FP8"

View file

@ -43,6 +43,7 @@ class LLMType(Enum):
OPENROUTER_REASONING = "openrouter_reasoning"
BEDROCK = "bedrock"
ARK = "ark" # https://www.volcengine.com/docs/82379/1263482#python-sdk
LLAMA_API = "llama_api"
def __missing__(self, key):
return self.OPENAI

View file

@ -52,6 +52,7 @@ from metagpt.utils.token_counter import (
LLMType.DEEPSEEK,
LLMType.SILICONFLOW,
LLMType.OPENROUTER,
LLMType.LLAMA_API,
]
)
class OpenAILLM(BaseLLM):

View file

@ -113,6 +113,10 @@ TOKEN_COSTS = {
"doubao-pro-128k-240515": {"prompt": 0.0007, "completion": 0.0013},
"llama3-70b-llama3-70b-instruct": {"prompt": 0.0, "completion": 0.0},
"llama3-8b-llama3-8b-instruct": {"prompt": 0.0, "completion": 0.0},
"llama-4-Scout-17B-16E-Instruct-FP8" : {"prompt": 0.0, "completion": 0.0}, # start, for Llama API
"llama-4-Maverick-17B-128E-Instruct-FP8": {"prompt": 0.0, "completion": 0.0},
"llama-3.3-8B-Instruct": {"prompt": 0.0, "completion": 0.0},
"llama-3.3-70B-Instruct": {"prompt": 0.0, "completion": 0.0}, # end, for Llama API
}