Skip to content

Commit c19f44f

Browse files
yiranwu0Hk669
andauthored
update (#3175)
Co-authored-by: HRUSHIKESH DOKALA <[email protected]>
1 parent adf438a commit c19f44f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

autogen/oai/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def _cost_with_customized_price(
795795
n_output_tokens = response.usage.completion_tokens if response.usage is not None else 0 # type: ignore [union-attr]
796796
if n_output_tokens is None:
797797
n_output_tokens = 0
798-
return n_input_tokens * price_1k[0] + n_output_tokens * price_1k[1]
798+
return (n_input_tokens * price_1k[0] + n_output_tokens * price_1k[1]) / 1000
799799

800800
@staticmethod
801801
def _update_dict_from_chunk(chunk: BaseModel, d: Dict[str, Any], field: str) -> int:

test/oai/test_client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ def test_customized_cost():
140140
env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo-instruct"]}
141141
)
142142
for config in config_list:
143-
config.update({"price": [1, 1]})
143+
config.update({"price": [1000, 1000]})
144144
client = OpenAIWrapper(config_list=config_list, cache_seed=None)
145145
response = client.create(prompt="1+3=")
146-
assert response.cost >= 4, "Due to customized pricing, cost should be greater than 4"
146+
assert response.cost >= 4 and response.cost < 10, "Due to customized pricing, cost should be > 4 and < 10"
147147

148148

149149
@pytest.mark.skipif(skip, reason="openai>=1 not installed")

0 commit comments

Comments
 (0)