-
-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure support multitask.py #136
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,9 +31,11 @@ def tasks_from_chunks(cls, json_chunks): | |||||||||||||||||||||||||||||||||||||||||
@staticmethod | ||||||||||||||||||||||||||||||||||||||||||
def extract_json(completion): | ||||||||||||||||||||||||||||||||||||||||||
for chunk in completion: | ||||||||||||||||||||||||||||||||||||||||||
delta = chunk["choices"][0]["delta"] | ||||||||||||||||||||||||||||||||||||||||||
if "function_call" in delta: | ||||||||||||||||||||||||||||||||||||||||||
yield delta["function_call"]["arguments"] | ||||||||||||||||||||||||||||||||||||||||||
if chunk["choices"]: | ||||||||||||||||||||||||||||||||||||||||||
delta = chunk["choices"][0]["delta"] | ||||||||||||||||||||||||||||||||||||||||||
if "function_call" in delta: | ||||||||||||||||||||||||||||||||||||||||||
if "arguments" in delta["function_call"]: | ||||||||||||||||||||||||||||||||||||||||||
yield delta["function_call"]["arguments"] | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code assumes that the - if "function_call" in delta:
+ if delta and "function_call" in delta: Commitable suggestion
Suggested change
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code assumes that the - if "arguments" in delta["function_call"]:
+ if "arguments" in delta.get("function_call", {}): Commitable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Comment on lines
31
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code assumes that the - if chunk["choices"]:
+ if "choices" in chunk and chunk["choices"]: Commitable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
@staticmethod | ||||||||||||||||||||||||||||||||||||||||||
def get_object(str, stack): | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code assumes that the
delta
key will always be present in thechoices[0]
dictionary. This could lead to a KeyError ifdelta
is not present. It would be safer to check for the existence ofdelta
before accessing it. Here is the improved code:Commitable suggestion