From 43b090c472ed1b4a194523f74ce9869469190a19 Mon Sep 17 00:00:00 2001 From: cmodi-meta <98582575+cmodi-meta@users.noreply.github.com> Date: Wed, 30 Apr 2025 16:27:12 -0700 Subject: [PATCH 1/3] Add Llama API Support --- .../llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml | 5 +++++ metagpt/configs/llm_config.py | 1 + metagpt/provider/openai_api.py | 1 + metagpt/utils/token_counter.py | 4 ++++ 4 files changed, 11 insertions(+) create mode 100644 config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml diff --git a/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml b/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml new file mode 100644 index 000000000..9b48d770c --- /dev/null +++ b/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml @@ -0,0 +1,5 @@ +llm: + api_type: llamaapi + base_url: "https://api.llama.com/compat/v1/" + api_key: "YOUR_API_KEY" + model: llama-4-Maverick-17B-128E-Instruct-FP8 diff --git a/metagpt/configs/llm_config.py b/metagpt/configs/llm_config.py index 2ceef2e2a..f17904d8f 100644 --- a/metagpt/configs/llm_config.py +++ b/metagpt/configs/llm_config.py @@ -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 diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py index c608d1d29..1263865bb 100644 --- a/metagpt/provider/openai_api.py +++ b/metagpt/provider/openai_api.py @@ -52,6 +52,7 @@ from metagpt.utils.token_counter import ( LLMType.DEEPSEEK, LLMType.SILICONFLOW, LLMType.OPENROUTER, + LLMType.LLAMA_API, ] ) class OpenAILLM(BaseLLM): diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index 80bdacae5..e8bf9d811 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -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 } From 2d351e4ba9b3f5832c38969511233038c4fbb4ee Mon Sep 17 00:00:00 2001 From: cmodi-meta <98582575+cmodi-meta@users.noreply.github.com> Date: Thu, 15 May 2025 12:22:24 -0700 Subject: [PATCH 2/3] Add yaml file for other supporting Llama API models --- config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml | 5 +++++ config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml | 5 +++++ .../llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml | 5 +++++ .../llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml | 4 ++-- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml create mode 100644 config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml create mode 100644 config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml diff --git a/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml b/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml new file mode 100644 index 000000000..2ab19c750 --- /dev/null +++ b/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml @@ -0,0 +1,5 @@ +llm: + api_type: llama_api + base_url: "https://api.llama.com/compat/v1/" + api_key: "YOUR_API_KEY" + model: "Llama-3.3-70B-Instruct" diff --git a/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml b/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml new file mode 100644 index 000000000..71b021106 --- /dev/null +++ b/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml @@ -0,0 +1,5 @@ +llm: + api_type: llama_api + base_url: "https://api.llama.com/compat/v1/" + api_key: "YOUR_API_KEY" + model: "Llama-3.3-8B-Instruct" diff --git a/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml b/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml new file mode 100644 index 000000000..c148e7913 --- /dev/null +++ b/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml @@ -0,0 +1,5 @@ +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" diff --git a/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml b/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml index 9b48d770c..a29fa3709 100644 --- a/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml +++ b/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml @@ -1,5 +1,5 @@ llm: - api_type: llamaapi + 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 + model: "Llama-4-Maverick-17B-128E-Instruct-FP8" From d239e5329a3389c9ed677d411241da52a4b7cdc7 Mon Sep 17 00:00:00 2001 From: cmodi-meta <98582575+cmodi-meta@users.noreply.github.com> Date: Thu, 15 May 2025 12:31:17 -0700 Subject: [PATCH 3/3] Include copyright to yaml files --- config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml | 1 + config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml | 1 + config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml | 1 + .../llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml | 1 + 4 files changed, 4 insertions(+) diff --git a/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml b/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml index 2ab19c750..392bbe268 100644 --- a/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml +++ b/config/examples/llamaapi-Llama-3.3-70B-Instruct.yaml @@ -1,3 +1,4 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates llm: api_type: llama_api base_url: "https://api.llama.com/compat/v1/" diff --git a/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml b/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml index 71b021106..c63e4b5d0 100644 --- a/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml +++ b/config/examples/llamaapi-Llama-3.3-8B-Instruct.yaml @@ -1,3 +1,4 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates llm: api_type: llama_api base_url: "https://api.llama.com/compat/v1/" diff --git a/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml b/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml index c148e7913..61504467b 100644 --- a/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml +++ b/config/examples/llamaapi-Llama-4-Scout-17B-16E-Instruct-FP8.yaml @@ -1,3 +1,4 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates llm: api_type: llama_api base_url: "https://api.llama.com/compat/v1/" diff --git a/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml b/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml index a29fa3709..9bea8a93f 100644 --- a/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml +++ b/config/examples/llamaapi-llama-4-Maverick-17B-128E-Instruct-FP8.yaml @@ -1,3 +1,4 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates llm: api_type: llama_api base_url: "https://api.llama.com/compat/v1/"