|
1 | 1 | use crate::client::{ |
2 | 2 | CreateModelResponseRequest, CreateModelResponseResponse, Detail, InnerInput, InnerInputItem, |
3 | | - Input, InputItem, OutputItem, OutputMessageContent, Tool, |
| 3 | + Input, InputItem, OpenOutputItem, OutputItem, OutputMessageContent, Tool, |
4 | 4 | }; |
5 | 5 | use base64::{engine::general_purpose, Engine as _}; |
6 | 6 | use golem_llm::error::error_code_from_status; |
7 | 7 | use golem_llm::golem::llm::llm::{ |
8 | 8 | Config, ContentPart, Error, ErrorCode, Event, ImageDetail, ImageReference, Message, Response, |
9 | 9 | ResponseMetadata, Role, ToolCall, ToolDefinition, ToolResult, Usage, |
10 | 10 | }; |
| 11 | +use log::trace; |
11 | 12 | use reqwest::StatusCode; |
12 | 13 | use std::collections::HashMap; |
13 | 14 | use std::str::FromStr; |
@@ -221,30 +222,35 @@ pub fn process_model_response(response: CreateModelResponseResponse) -> Result<R |
221 | 222 |
|
222 | 223 | for output_item in response.output { |
223 | 224 | match output_item { |
224 | | - OutputItem::Message { content, .. } => { |
225 | | - for content in content { |
226 | | - match content { |
227 | | - OutputMessageContent::Text { text, .. } => { |
228 | | - contents.push(ContentPart::Text(text)); |
229 | | - } |
230 | | - OutputMessageContent::Refusal { refusal, .. } => { |
231 | | - contents.push(ContentPart::Text(format!("Refusal: {refusal}"))); |
| 225 | + OpenOutputItem::Known(output_item) => match output_item { |
| 226 | + OutputItem::Message { content, .. } => { |
| 227 | + for content in content { |
| 228 | + match content { |
| 229 | + OutputMessageContent::Text { text, .. } => { |
| 230 | + contents.push(ContentPart::Text(text)); |
| 231 | + } |
| 232 | + OutputMessageContent::Refusal { refusal, .. } => { |
| 233 | + contents.push(ContentPart::Text(format!("Refusal: {refusal}"))); |
| 234 | + } |
232 | 235 | } |
233 | 236 | } |
234 | 237 | } |
235 | | - } |
236 | | - OutputItem::ToolCall { |
237 | | - arguments, |
238 | | - call_id, |
239 | | - name, |
240 | | - .. |
241 | | - } => { |
242 | | - let tool_call = ToolCall { |
243 | | - id: call_id, |
| 238 | + OutputItem::ToolCall { |
| 239 | + arguments, |
| 240 | + call_id, |
244 | 241 | name, |
245 | | - arguments_json: arguments, |
246 | | - }; |
247 | | - tool_calls.push(tool_call); |
| 242 | + .. |
| 243 | + } => { |
| 244 | + let tool_call = ToolCall { |
| 245 | + id: call_id, |
| 246 | + name, |
| 247 | + arguments_json: arguments, |
| 248 | + }; |
| 249 | + tool_calls.push(tool_call); |
| 250 | + } |
| 251 | + }, |
| 252 | + OpenOutputItem::Other(value) => { |
| 253 | + trace!("Ignoring unknown output item: {value:?}"); |
248 | 254 | } |
249 | 255 | } |
250 | 256 | } |
|
0 commit comments