Skip to content

Commit 3ba4cb7

Browse files
committed
fix: OpenAI Multi-turn support
1 parent 0ad73e1 commit 3ba4cb7

File tree

18 files changed

+692
-495
lines changed

18 files changed

+692
-495
lines changed

llm/anthropic/src/bindings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
44
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
55
// * generate_unused_types
66
use golem_llm::golem::llm::llm as __with_name0;
77
#[cfg(target_arch = "wasm32")]
8-
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-anthropic@1.0.0:llm-library:encoded world"]
8+
#[unsafe(
9+
link_section = "component-type:wit-bindgen:0.41.0:golem:llm-anthropic@1.0.0:llm-library:encoded world"
10+
)]
911
#[doc(hidden)]
12+
#[allow(clippy::octal_escapes)]
1013
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1762] = *b"\
1114
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe0\x0c\x01A\x02\x01\
1215
A\x02\x01BO\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
@@ -43,8 +46,8 @@ ng-get-next\x01B\x01p\x15\x01@\x02\x08messages\xc3\0\x06config)\06\x04\0\x04send
4346
\0\x06config)\06\x04\0\x08continue\x01G\x01i=\x01@\x02\x08messages\xc3\0\x06conf\
4447
ig)\0\xc8\0\x04\0\x06stream\x01I\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0%golem:\
4548
llm-anthropic/llm-library@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09\
46-
producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rus\
47-
t\x060.36.0";
49+
producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rus\
50+
t\x060.41.0";
4851
#[inline(never)]
4952
#[doc(hidden)]
5053
pub fn __link_custom_section_describing_imports() {

llm/anthropic/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn process_response(response: MessagesResponse) -> ChatEvent {
130130
Err(e) => {
131131
return ChatEvent::Error(Error {
132132
code: ErrorCode::InvalidRequest,
133-
message: format!("Failed to decode base64 image data: {}", e),
133+
message: format!("Failed to decode base64 image data: {e}"),
134134
provider_error_json: None,
135135
});
136136
}

llm/grok/src/bindings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
44
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
55
// * generate_unused_types
66
use golem_llm::golem::llm::llm as __with_name0;
77
#[cfg(target_arch = "wasm32")]
8-
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-grok@1.0.0:llm-library:encoded world"]
8+
#[unsafe(
9+
link_section = "component-type:wit-bindgen:0.41.0:golem:llm-grok@1.0.0:llm-library:encoded world"
10+
)]
911
#[doc(hidden)]
12+
#[allow(clippy::octal_escapes)]
1013
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1757] = *b"\
1114
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdb\x0c\x01A\x02\x01\
1215
A\x02\x01BO\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
@@ -43,8 +46,8 @@ ng-get-next\x01B\x01p\x15\x01@\x02\x08messages\xc3\0\x06config)\06\x04\0\x04send
4346
\0\x06config)\06\x04\0\x08continue\x01G\x01i=\x01@\x02\x08messages\xc3\0\x06conf\
4447
ig)\0\xc8\0\x04\0\x06stream\x01I\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0\x20gol\
4548
em:llm-grok/llm-library@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09p\
46-
roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\
47-
\x060.36.0";
49+
roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\
50+
\x060.41.0";
4851
#[inline(never)]
4952
#[doc(hidden)]
5053
pub fn __link_custom_section_describing_imports() {

llm/grok/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn convert_content_parts(contents: Vec<ContentPart>) -> crate::client::Content {
183183
let media_type = &image_source.mime_type; // This is already a string
184184
result.push(crate::client::ContentPart::ImageInput {
185185
image_url: crate::client::ImageUrl {
186-
url: format!("data:{};base64,{}", media_type, base64_data),
186+
url: format!("data:{media_type};base64,{base64_data}"),
187187
detail: image_source.detail.map(|d| d.into()),
188188
},
189189
});

llm/llm/src/event_source/ndjson_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn try_parse_line(
126126
return Ok(None);
127127
}
128128

129-
trace!("Parsed NDJSON line: {}", line);
129+
trace!("Parsed NDJSON line: {line}");
130130

131131
// Create a MessageEvent with the JSON line as data
132132
let event = MessageEvent {

llm/llm/src/event_source/stream.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ where
5656
{
5757
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5858
match self {
59-
Self::Utf8(err) => f.write_fmt(format_args!("UTF8 error: {}", err)),
60-
Self::Parser(err) => f.write_fmt(format_args!("Parse error: {}", err)),
61-
Self::Transport(err) => f.write_fmt(format_args!("Transport error: {}", err)),
59+
Self::Utf8(err) => f.write_fmt(format_args!("UTF8 error: {err}")),
60+
Self::Parser(err) => f.write_fmt(format_args!("Parse error: {err}")),
61+
Self::Transport(err) => f.write_fmt(format_args!("Transport error: {err}")),
6262
}
6363
}
6464
}

llm/ollama/src/bindings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
44
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
55
// * generate_unused_types
66
use golem_llm::golem::llm::llm as __with_name0;
77
#[cfg(target_arch = "wasm32")]
8-
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-ollama@1.0.0:llm-library:encoded world"]
8+
#[unsafe(
9+
link_section = "component-type:wit-bindgen:0.41.0:golem:llm-ollama@1.0.0:llm-library:encoded world"
10+
)]
911
#[doc(hidden)]
12+
#[allow(clippy::octal_escapes)]
1013
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1759] = *b"\
1114
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdd\x0c\x01A\x02\x01\
1215
A\x02\x01BO\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
@@ -43,8 +46,8 @@ ng-get-next\x01B\x01p\x15\x01@\x02\x08messages\xc3\0\x06config)\06\x04\0\x04send
4346
\0\x06config)\06\x04\0\x08continue\x01G\x01i=\x01@\x02\x08messages\xc3\0\x06conf\
4447
ig)\0\xc8\0\x04\0\x06stream\x01I\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0\"golem\
4548
:llm-ollama/llm-library@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09p\
46-
roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\
47-
\x060.36.0";
49+
roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\
50+
\x060.41.0";
4851
#[inline(never)]
4952
#[doc(hidden)]
5053
pub fn __link_custom_section_describing_imports() {

llm/ollama/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub fn image_to_base64(source: &str) -> Result<String, Box<dyn std::error::Error
335335
pub fn from_reqwest_error(context: &str, err: reqwest::Error) -> Error {
336336
Error {
337337
code: ErrorCode::InternalError,
338-
message: format!("{}: {}", context, err),
338+
message: format!("{context}: {err}"),
339339
provider_error_json: None,
340340
}
341341
}

llm/ollama/src/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub fn process_response(response: CompletionsResponse) -> ChatEvent {
214214
};
215215

216216
ChatEvent::Message(CompleteResponse {
217-
id: format!("ollama-{}", timestamp),
217+
id: format!("ollama-{timestamp}"),
218218
content,
219219
tool_calls,
220220
metadata,

llm/openai/src/bindings.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
44
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
55
// * generate_unused_types
66
use golem_llm::golem::llm::llm as __with_name0;
77
#[cfg(target_arch = "wasm32")]
8-
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-openai@1.0.0:llm-library:encoded world"]
8+
#[unsafe(
9+
link_section = "component-type:wit-bindgen:0.41.0:golem:llm-openai@1.0.0:llm-library:encoded world"
10+
)]
911
#[doc(hidden)]
12+
#[allow(clippy::octal_escapes)]
1013
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1759] = *b"\
1114
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdd\x0c\x01A\x02\x01\
1215
A\x02\x01BO\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
@@ -43,8 +46,8 @@ ng-get-next\x01B\x01p\x15\x01@\x02\x08messages\xc3\0\x06config)\06\x04\0\x04send
4346
\0\x06config)\06\x04\0\x08continue\x01G\x01i=\x01@\x02\x08messages\xc3\0\x06conf\
4447
ig)\0\xc8\0\x04\0\x06stream\x01I\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0\"golem\
4548
:llm-openai/llm-library@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09p\
46-
roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\
47-
\x060.36.0";
49+
roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\
50+
\x060.41.0";
4851
#[inline(never)]
4952
#[doc(hidden)]
5053
pub fn __link_custom_section_describing_imports() {

0 commit comments

Comments
 (0)