Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

fix bug

geekan4370060802b3
diff --git a/config/config2.yaml.example b/config/config2.yaml.example
index 8f4a33fc1..2217f1b2c 100644
--- a/config/config2.yaml.example
+++ b/config/config2.yaml.example
@@ -1,5 +1,5 @@
llm:
- api_type: "openai"
+ api_type: "openai" # or azure / ollama etc.
base_url: "YOUR_BASE_URL"
api_key: "YOUR_API_KEY"
model: "gpt-4-turbo-preview" # or gpt-3.5-turbo-1106 / gpt-4-1106-preview
diff --git a/metagpt/actions/research.py b/metagpt/actions/research.py
index 2ebeadb66..316e9f299 100644
--- a/metagpt/actions/research.py
+++ b/metagpt/actions/research.py
@@ -133,7 +133,7 @@ class CollectLinks(Action):
if len(remove) == 0:
break
- model_name = config.get_openai_llm().model
+ model_name = config.model
prompt = reduce_message_length(gen_msg(), model_name, system_text, 4096)
logger.debug(prompt)
queries = await self._aask(prompt, [system_text])
diff --git a/metagpt/utils/cost_manager.py b/metagpt/utils/cost_manager.py
index 7bf5154b6..c4c93f91f 100644
--- a/metagpt/utils/cost_manager.py
+++ b/metagpt/utils/cost_manager.py
@@ -41,6 +41,10 @@ class CostManager(BaseModel):
"""
self.total_prompt_tokens += prompt_tokens
self.total_completion_tokens += completion_tokens
+ if model not in TOKEN_COSTS:
+ logger.warning(f"Model {model} not found in TOKEN_COSTS.")
+ return
+
cost = (
prompt_tokens * TOKEN_COSTS[model]["prompt"] + completion_tokens * TOKEN_COSTS[model]["completion"]
) / 1000