mirror of https://github.com/microsoft/autogen.git
update (#3175)
Co-authored-by: HRUSHIKESH DOKALA <96101829+Hk669@users.noreply.github.com>
This commit is contained in:
parent
adf438abfa
commit
c19f44f626
|
@ -795,7 +795,7 @@ class OpenAIWrapper:
|
|||
n_output_tokens = response.usage.completion_tokens if response.usage is not None else 0 # type: ignore [union-attr]
|
||||
if n_output_tokens is None:
|
||||
n_output_tokens = 0
|
||||
return n_input_tokens * price_1k[0] + n_output_tokens * price_1k[1]
|
||||
return (n_input_tokens * price_1k[0] + n_output_tokens * price_1k[1]) / 1000
|
||||
|
||||
@staticmethod
|
||||
def _update_dict_from_chunk(chunk: BaseModel, d: Dict[str, Any], field: str) -> int:
|
||||
|
|
|
@ -140,10 +140,10 @@ def test_customized_cost():
|
|||
env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo-instruct"]}
|
||||
)
|
||||
for config in config_list:
|
||||
config.update({"price": [1, 1]})
|
||||
config.update({"price": [1000, 1000]})
|
||||
client = OpenAIWrapper(config_list=config_list, cache_seed=None)
|
||||
response = client.create(prompt="1+3=")
|
||||
assert response.cost >= 4, "Due to customized pricing, cost should be greater than 4"
|
||||
assert response.cost >= 4 and response.cost < 10, "Due to customized pricing, cost should be > 4 and < 10"
|
||||
|
||||
|
||||
@pytest.mark.skipif(skip, reason="openai>=1 not installed")
|
||||
|
|
Loading…
Reference in New Issue