File tree Expand file tree Collapse file tree 4 files changed +22
-13
lines changed
Expand file tree Collapse file tree 4 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 11[tool .poetry ]
22name = " tuneapi"
3- version = " 0.4.10 "
3+ version = " 0.4.11 "
44description = " Tune AI APIs."
55authors = [
" Frello Technology Private Limited <[email protected] >" ]
66license = " MIT"
Original file line number Diff line number Diff line change 11# Copyright © 2023- Frello Technology Private Limited
22
3- __version__ = "0.4.10 "
3+ __version__ = "0.4.11 "
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ def stream_chat(
154154 }
155155 if stop_sequence :
156156 data ["stop_sequence" ] = stop_sequence
157- if isinstance (chats , tt .Thread ):
157+ if isinstance (chats , tt .Thread ) and len ( chats . tools ) :
158158 data ["tools" ] = [
159159 {"type" : "function" , "function" : x .to_dict ()} for x in chats .tools
160160 ]
@@ -185,15 +185,20 @@ def stream_chat(
185185 line = line .decode ().strip ()
186186 if line :
187187 try :
188- x = json .loads (line .replace ("data: " , "" ))["choices" ][0 ]["delta" ]
189- if "tool_calls" in x :
190- y = x ["tool_calls" ][0 ]["function" ]
188+ delta = json .loads (line .replace ("data: " , "" ))["choices" ][0 ][
189+ "delta"
190+ ]
191+ if "tool_calls" in delta :
192+ y = delta ["tool_calls" ][0 ]["function" ]
191193 if fn_call is None :
192- fn_call = {"name" : y ["name" ], "arguments" : y ["arguments" ]}
194+ fn_call = {
195+ "name" : y ["name" ],
196+ "arguments" : y .get ("arguments" , "" ),
197+ }
193198 else :
194199 fn_call ["arguments" ] += y ["arguments" ]
195- elif "content" in x :
196- yield x ["content" ]
200+ elif "content" in delta :
201+ yield delta ["content" ]
197202 except :
198203 break
199204 if fn_call :
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ def get_files_in_folder(
3333 if _all :
3434 for f in files :
3535 _fp = joinp (root , f )
36- if not ignore_pat .search (_fp ).group ():
36+ _ig_pat = ignore_pat .search (_fp )
37+ if not _ig_pat or not _ig_pat .group ():
3738 all_paths .append (_fp )
3839 continue
3940
@@ -42,21 +43,24 @@ def get_files_in_folder(
4243 print (e )
4344 if f .endswith (e ):
4445 _fp = joinp (root , f )
45- if not ignore_pat .search (_fp ).group ():
46+ _ig_pat = ignore_pat .search (_fp )
47+ if not _ig_pat or not _ig_pat .group ():
4648 all_paths .append (_fp )
4749
4850 else :
4951 for f in os .listdir (folder_abs ):
5052 if _all :
5153 _fp = joinp (folder_abs , f )
52- if not ignore_pat .search (_fp ).group ():
54+ _ig_pat = ignore_pat .search (_fp )
55+ if not _ig_pat or not _ig_pat .group ():
5356 all_paths .append (_fp )
5457 continue
5558
5659 for e in ext :
5760 if f .endswith (e ):
5861 _fp = joinp (folder_abs , f )
59- if not ignore_pat .search (_fp ).group ():
62+ _ig_pat = ignore_pat .search (_fp )
63+ if not _ig_pat or not _ig_pat .group ():
6064 all_paths .append (_fp )
6165
6266 return all_paths
You can’t perform that action at this time.
0 commit comments