1111import requests
1212
1313from .auth import get_fireworks_account_id , get_fireworks_api_base , get_fireworks_api_key
14+ from .common_utils import get_user_agent
1415
1516
1617def _map_api_host_to_app_host (api_base : str ) -> str :
@@ -157,7 +158,11 @@ def create_dataset_from_jsonl(
157158 display_name : Optional [str ],
158159 jsonl_path : str ,
159160) -> Tuple [str , Dict [str , Any ]]:
160- headers = {"Authorization" : f"Bearer { api_key } " , "Content-Type" : "application/json" }
161+ headers = {
162+ "Authorization" : f"Bearer { api_key } " ,
163+ "Content-Type" : "application/json" ,
164+ "User-Agent" : get_user_agent (),
165+ }
161166 # Count examples quickly
162167 example_count = 0
163168 with open (jsonl_path , "r" , encoding = "utf-8" ) as f :
@@ -181,7 +186,7 @@ def create_dataset_from_jsonl(
181186 upload_url = f"{ api_base .rstrip ('/' )} /v1/accounts/{ account_id } /datasets/{ dataset_id } :upload"
182187 with open (jsonl_path , "rb" ) as f :
183188 files = {"file" : f }
184- up_headers = {"Authorization" : f"Bearer { api_key } " }
189+ up_headers = {"Authorization" : f"Bearer { api_key } " , "User-Agent" : get_user_agent () }
185190 up_resp = requests .post (upload_url , files = files , headers = up_headers , timeout = 600 )
186191 if up_resp .status_code not in (200 , 201 ):
187192 raise RuntimeError (f"Dataset upload failed: { up_resp .status_code } { up_resp .text } " )
@@ -195,7 +200,12 @@ def create_reinforcement_fine_tuning_job(
195200 body : Dict [str , Any ],
196201) -> Dict [str , Any ]:
197202 url = f"{ api_base .rstrip ('/' )} /v1/accounts/{ account_id } /reinforcementFineTuningJobs"
198- headers = {"Authorization" : f"Bearer { api_key } " , "Content-Type" : "application/json" , "Accept" : "application/json" }
203+ headers = {
204+ "Authorization" : f"Bearer { api_key } " ,
205+ "Content-Type" : "application/json" ,
206+ "Accept" : "application/json" ,
207+ "User-Agent" : get_user_agent (),
208+ }
199209 resp = requests .post (url , json = body , headers = headers , timeout = 60 )
200210 if resp .status_code not in (200 , 201 ):
201211 raise RuntimeError (f"RFT job creation failed: { resp .status_code } { resp .text } " )
0 commit comments