Skip to content

Commit f30064a

Browse files
authored
added exception in case model (#48)
1 parent c89641d commit f30064a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/agentlab/llm/chat_api.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,15 @@ def __init__(
251251
# Get pricing information
252252
if pricing_func:
253253
pricings = pricing_func()
254-
self.input_cost = float(pricings[model_name]["prompt"])
255-
self.output_cost = float(pricings[model_name]["completion"])
254+
try:
255+
self.input_cost = float(pricings[model_name]["prompt"])
256+
self.output_cost = float(pricings[model_name]["completion"])
257+
except KeyError:
258+
logging.warning(
259+
f"Model {model_name} not found in the pricing information, prices are set to 0. Maybe try upgrading langchain_community."
260+
)
261+
self.input_cost = 0.0
262+
self.output_cost = 0.0
256263
else:
257264
self.input_cost = 0.0
258265
self.output_cost = 0.0

0 commit comments

Comments
 (0)