I’m stuck on Stage #FF2
I’ve tried getting my own openrouter api keys and testing with it (it works fine that way)
Here are my logs:
[your_program] entering loop with messages: [
[your_program] {
[your_program] "content": "Determine in how many months the chemical expires by reading README.md. Respond with only a number.",
[your_program] "role": "user"
[your_program] },
[your_program] {
[your_program] "content": "This is a simple python project.\n- The starting point of this project is app/init.py.\n- The file app/chemical.py contains chemical properties.",
[your_program] "name": "ReadFile",
[your_program] "role": "tool"
[your_program] }
[your_program] ]
[tester::#FF2] timed out, test exceeded 45 seconds
[tester::#FF2] Test failed
And here’s a snippet of my code:
loop {
eprintln!(
"entering loop with messages: {}",
serde_json::to_string_pretty(&messages)?
);
let response: Value = client
.chat()
.create_byot(json!({
"messages": messages,
"model": get_model(),
"tools": [
{
"type": "function",
"function": {
"name": "ReadFile",
"description": "Read the contents of a file",
"parameters": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "Path to the file to read"
}
},
"required": ["file_path"]
}
}
}
]
}))
.await?;
eprintln!(
"received response: {}",
serde_json::to_string_pretty(&response)?
);
if let Some(tool_calls) = response["choices"][0]["message"]["tool_calls"].as_array() {
for tool_call in tool_calls {
eprintln!(
"processing tool call: {}",
serde_json::to_string_pretty(tool_call)?
);
let name = tool_call["function"]["name"].as_str().unwrap();
let arguments: Value =
serde_json::from_str(tool_call["function"]["arguments"].as_str().unwrap())?;
if name == "ReadFile" {
let file_path = arguments["file_path"].as_str().unwrap();
let contents = std::fs::read_to_string(file_path)?;
messages.push(json!({
"role": "tool",
"name": name,
"content": contents
}));
}
}
} else if let Some(content) = response["choices"][0]["message"]["content"].as_str() {
eprintln!("no toolcall");
eprintln!("assistant response content: {}", content);
messages.push(json!({
"role": "assistant",
"content": content
}));
println!("{}", content);
break;
} else {
eprintln!("Unexpected response format: {}", response);
break;
}
}