From a585ef52a60b3e2f4dfff19d512d9835cddf377e Mon Sep 17 00:00:00 2001 From: yzlin Date: Tue, 12 Mar 2024 17:50:10 +0800 Subject: [PATCH 1/2] update examples --- examples/di/imitate_webpage.py | 3 +-- examples/di/solve_math_problems.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/di/imitate_webpage.py b/examples/di/imitate_webpage.py index b00157d9d..60ebab389 100644 --- a/examples/di/imitate_webpage.py +++ b/examples/di/imitate_webpage.py @@ -12,8 +12,7 @@ async def main(): web_url = "https://pytorch.org/" prompt = f"""This is a URL of webpage: '{web_url}' . Firstly, utilize Selenium and WebDriver for rendering. -Secondly, convert image to a webpage including HTML, CSS and JS in one go. -Finally, save webpage in a text file. +Secondly, convert image to a webpage including HTML, CSS and JS in one go. Note: All required dependencies and environments have been fully installed and configured.""" di = DataInterpreter(tools=["GPTvGenerator"]) diff --git a/examples/di/solve_math_problems.py b/examples/di/solve_math_problems.py index ae2c1b942..f7fd3d4e3 100644 --- a/examples/di/solve_math_problems.py +++ b/examples/di/solve_math_problems.py @@ -10,4 +10,5 @@ async def main(requirement: str = ""): if __name__ == "__main__": requirement = "Solve this math problem: The greatest common divisor of positive integers m and n is 6. The least common multiple of m and n is 126. What is the least possible value of m + n?" + # answer: 60 (m = 18, n = 42) asyncio.run(main(requirement)) From 19c0db88218933333689654cfb8452d692aed868 Mon Sep 17 00:00:00 2001 From: yzlin Date: Tue, 12 Mar 2024 18:05:50 +0800 Subject: [PATCH 2/2] fix empty choices error when using azure --- metagpt/provider/openai_api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.py index 2126505c7..8f3b71c42 100644 --- a/metagpt/provider/openai_api.py +++ b/metagpt/provider/openai_api.py @@ -87,7 +87,9 @@ class OpenAILLM(BaseLLM): collected_messages = [] async for chunk in response: chunk_message = chunk.choices[0].delta.content or "" if chunk.choices else "" # extract the message - finish_reason = chunk.choices[0].finish_reason if hasattr(chunk.choices[0], "finish_reason") else None + finish_reason = ( + chunk.choices[0].finish_reason if chunk.choices and hasattr(chunk.choices[0], "finish_reason") else None + ) log_llm_stream(chunk_message) collected_messages.append(chunk_message) if finish_reason: