diff --git a/README.md b/README.md index 925ad6e4d648..123925276179 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ from autogen import AssistantAgent, UserProxyAgent, config_list_from_json # See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints # and OAI_CONFIG_LIST_sample config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST") +# You can also set config_list directly as a list, for example, config_list = [{'model': 'gpt-4', 'api_key': ''},] assistant = AssistantAgent("assistant", llm_config={"config_list": config_list}) user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding"}) user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD.") diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index f3ea897de6b6..54739ec5d2f3 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -1026,7 +1026,7 @@ def cost(cls, response: dict): Returns: The cost in USD. 0 if the model is not supported. """ - model = response["model"] + model = response.get("model") if model not in cls.price1K: return 0 # raise ValueError(f"Unknown model: {model}")