File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def name(self) -> str:
1515 def arguments (self ) -> dict [str , Any ]:
1616 try :
1717 return json .loads (
18- self .json ["arguments" ] or "" if "arguments" in self .json else ""
18+ self .json ["arguments" ] or "{} " if "arguments" in self .json else "{} "
1919 )
2020 except :
2121 return {}
@@ -35,7 +35,7 @@ def role(self) -> Optional[str]:
3535
3636 @property
3737 def index (self ) -> int :
38- return self .json ["index" ]
38+ return self .json ["index" ] if "index" in self . json else 0
3939
4040 @property
4141 def finish_reason (self ) -> Optional [str ]:
@@ -91,4 +91,7 @@ def choices(self) -> list[CompletionChoice]:
9191
9292 @property
9393 def best_choice (self ) -> CompletionChoice :
94- return CompletionChoice (self .json ["choices" ][0 ])
94+ try :
95+ return CompletionChoice (self .json ["choices" ][0 ])
96+ except IndexError :
97+ return CompletionChoice ({})
You can’t perform that action at this time.
0 commit comments