Skip to content

Commit

Permalink
Refactor get_choice_delta_text for safer dict access
Browse files Browse the repository at this point in the history
  • Loading branch information
程允权 committed Jan 28, 2024
1 parent ee0801a commit a68c344
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion metagpt/provider/base_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_choice_text(self, rsp: dict) -> str:

def get_choice_delta_text(self, rsp: dict) -> str:
"""Required to provide the first text of stream choice"""
return rsp.get("choices")[0]["delta"]["content"]
return rsp.get("choices", [{}])[0].get("delta", {}).get("content", "")

def get_choice_function(self, rsp: dict) -> dict:
"""Required to provide the first function of choice
Expand Down

0 comments on commit a68c344

Please sign in to comment.