tuning code

This commit is contained in:
geekan 2024-05-18 15:23:21 +08:00
parent 6d906ce1ed
commit e03db313a2
9 changed files with 40 additions and 39 deletions

View file

@ -34,8 +34,8 @@ from metagpt.utils.common import CodeParser, decode_image, log_and_reraise
from metagpt.utils.cost_manager import CostManager
from metagpt.utils.exceptions import handle_exception
from metagpt.utils.token_counter import (
count_message_tokens,
count_string_tokens,
count_input_tokens,
count_output_tokens,
get_max_completion_tokens,
get_openrouter_tokens,
)
@ -252,8 +252,8 @@ class OpenAILLM(BaseLLM):
return usage
try:
usage.prompt_tokens = count_message_tokens(messages, self.pricing_plan)
usage.completion_tokens = count_string_tokens(rsp, self.pricing_plan)
usage.prompt_tokens = count_input_tokens(messages, self.pricing_plan)
usage.completion_tokens = count_output_tokens(rsp, self.pricing_plan)
except Exception as e:
logger.warning(f"usage calculation failed: {e}")

View file

@ -13,7 +13,7 @@ def llm_output_postprocess(
"""
default use BasePostProcessPlugin if there is not matched plugin.
"""
# TODO choose different model's plugin according to the model_name
# TODO choose different model's plugin according to the model
postprocess_plugin = BasePostProcessPlugin()
result = postprocess_plugin.run(output=output, schema=schema, req_key=req_key)