1010
1111import tuneapi .utils as tu
1212import tuneapi .types as tt
13- from tuneapi .utils import ENV , SimplerTimes as stime , from_json , to_json
14- from tuneapi .types import Thread , human , Message
13+ from tuneapi .apis .turbo import distributed_chat
1514
1615
1716class Mistral (tt .ModelInterface ):
@@ -23,7 +22,7 @@ def __init__(
2322 ):
2423 self .model_id = id
2524 self .base_url = base_url
26- self .api_token = ENV .MISTRAL_TOKEN ("" )
25+ self .api_token = tu . ENV .MISTRAL_TOKEN ("" )
2726 self .extra_headers = extra_headers
2827
2928 def set_api_token (self , token : str ) -> None :
@@ -95,7 +94,7 @@ def _process_input(self, chats, token: Optional[str] = None):
9594
9695 def chat (
9796 self ,
98- chats : Thread | str ,
97+ chats : tt . Thread | str ,
9998 model : Optional [str ] = None ,
10099 max_tokens : int = 1024 ,
101100 temperature : float = 1 ,
@@ -124,7 +123,7 @@ def chat(
124123
125124 def stream_chat (
126125 self ,
127- chats : Thread | str ,
126+ chats : tt . Thread | str ,
128127 model : Optional [str ] = None ,
129128 max_tokens : int = 1024 ,
130129 temperature : float = 1 ,
@@ -135,7 +134,7 @@ def stream_chat(
135134 extra_headers : Optional [Dict [str , str ]] = None ,
136135 ):
137136 tools = []
138- if isinstance (chats , Thread ):
137+ if isinstance (chats , tt . Thread ):
139138 tools = [{"type" : "function" , "function" : x .to_dict ()} for x in chats .tools ]
140139 headers , messages = self ._process_input (chats , token )
141140 extra_headers = extra_headers or self .extra_headers
@@ -191,6 +190,23 @@ def stream_chat(
191190 except :
192191 break
193192 if fn_call :
194- fn_call ["arguments" ] = from_json (fn_call ["arguments" ])
193+ fn_call ["arguments" ] = tu . from_json (fn_call ["arguments" ])
195194 yield fn_call
196195 return
196+
197+ def distributed_chat (
198+ self ,
199+ prompts : List [tt .Thread ],
200+ post_logic : Optional [callable ] = None ,
201+ max_threads : int = 10 ,
202+ retry : int = 3 ,
203+ pbar = True ,
204+ ):
205+ return distributed_chat (
206+ self ,
207+ prompts = prompts ,
208+ post_logic = post_logic ,
209+ max_threads = max_threads ,
210+ retry = retry ,
211+ pbar = pbar ,
212+ )
0 commit comments