1111import os
1212
1313from openai import OpenAI
14- from eval_protocol .types .remote_rollout_processor import InitRequest
1514
1615
1716def main ():
@@ -20,44 +19,42 @@ def main():
2019 # Required arguments from workflow inputs
2120 parser .add_argument ("--model" , required = True , help = "Model to use" )
2221 parser .add_argument ("--metadata" , required = True , help = "JSON serialized metadata object" )
23- parser .add_argument ("--messages" , required = True , help = "JSON serialized messages array" )
24- parser .add_argument ("--tools" , required = False , help = "JSON serialized tools array" )
2522 parser .add_argument ("--model-base-url" , required = True , help = "Base URL for the model API" )
2623
2724 args = parser .parse_args ()
2825
29- # Parse the JSON inputs
26+ # Parse the metadata
3027 try :
3128 metadata = json .loads (args .metadata )
32- messages = json .loads (args .messages )
33- tools = json .loads (args .tools ) if args .tools else None
3429 except Exception as e :
35- print (f"❌ Failed to parse JSON inputs : { e } " )
30+ print (f"❌ Failed to parse metadata : { e } " )
3631 exit (1 )
3732
3833 rollout_id = metadata ["rollout_id" ]
34+ row_id = metadata ["row_id" ]
35+
3936 print (f"🚀 Starting rollout { rollout_id } " )
4037 print (f" Model: { args .model } " )
41- print (f" Messages: { len (messages )} messages" )
38+ print (f" Row ID: { row_id } " )
39+
40+ dataset = [ # In this example, worker has access to the dataset and we use index to associate rows.
41+ "What is the capital of France?" ,
42+ "What is the capital of Germany?" ,
43+ "What is the capital of Italy?" ,
44+ ]
4245
43- # Perform the rollout
44- conversation = messages .copy ()
46+ user_content = dataset [int (row_id )]
47+ messages = [{"role" : "user" , "content" : user_content }]
48+
49+ print (f" Messages: { len (messages )} messages" )
4550
4651 try :
4752 completion_kwargs = {"model" : args .model , "messages" : messages }
48- if tools :
49- completion_kwargs ["tools" ] = tools
5053
5154 client = OpenAI (base_url = args .model_base_url , api_key = os .environ .get ("FIREWORKS_API_KEY" ))
5255
5356 print ("📡 Calling OpenAI completion..." )
5457 completion = client .chat .completions .create (** completion_kwargs )
55- print ("✅ Received response" )
56-
57- # Add assistant response to conversation
58- if completion .choices and completion .choices [0 ].message :
59- assistant_message = completion .choices [0 ].message .model_dump ()
60- conversation .append (assistant_message )
6158
6259 print (f"✅ Rollout { rollout_id } completed successfully" )
6360
0 commit comments