Skip to content

Commit 934e7ea

Browse files
committed
Fix Ollama client
1 parent b7e7dbf commit 934e7ea

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

integration-tests/src/jvmTest/kotlin/ai/koog/integration/tests/executor/ExecutorIntegrationTestBase.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ import io.kotest.inspectors.shouldForAny
7474
import io.kotest.matchers.booleans.shouldBeTrue
7575
import io.kotest.matchers.booleans.shouldNotBeTrue
7676
import io.kotest.matchers.collections.shouldBeEmpty
77-
import io.kotest.matchers.collections.shouldContainAnyOf
7877
import io.kotest.matchers.collections.shouldNotBeEmpty
7978
import io.kotest.matchers.collections.shouldNotContainAnyOf
8079
import io.kotest.matchers.ints.shouldBeGreaterThan
@@ -86,7 +85,6 @@ import kotlinx.coroutines.cancel
8685
import kotlinx.coroutines.runBlocking
8786
import kotlinx.coroutines.test.TestScope
8887
import kotlinx.coroutines.test.runTest
89-
import org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf
9088
import org.junit.jupiter.api.AfterEach
9189
import org.junit.jupiter.api.Assumptions.assumeFalse
9290
import org.junit.jupiter.api.Assumptions.assumeTrue
@@ -895,7 +893,7 @@ abstract class ExecutorIntegrationTestBase {
895893
user("Respond with a short message.")
896894
}
897895
with(getLLMClient(model).execute(prompt, model)) {
898-
parts.shouldContainAnyOf(MessagePart.Text)
896+
parts.shouldForAny { it is MessagePart.Text }
899897
}
900898
}
901899

prompt/prompt-executor/prompt-executor-clients/prompt-executor-openai-client-base/src/commonMain/kotlin/ai/koog/prompt/executor/clients/openai/base/AbstractOpenAILLMClient.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public abstract class AbstractOpenAILLMClient<TResponse : OpenAIBaseLLMResponse,
290290
add(
291291
OpenAIMessage.Tool(
292292
content = OpenAIContent.Text(part.output),
293-
toolCallId = message.id ?: Uuid.random().toString()
293+
toolCallId = part.id ?: Uuid.random().toString()
294294
)
295295
)
296296
}
@@ -314,12 +314,14 @@ public abstract class AbstractOpenAILLMClient<TResponse : OpenAIBaseLLMResponse,
314314
// FIXME: how to handle multiple reasoning messages
315315
reasoningContent = message.parts.filterIsInstance<MessagePart.Reasoning>()
316316
.firstOrNull()?.content?.firstOrNull(),
317-
toolCalls = message.parts.filterIsInstance<MessagePart.Tool.Call>().map {
318-
OpenAIToolCall(
319-
it.id ?: Uuid.random().toString(),
320-
function = OpenAIFunction(it.tool, Json.encodeToString(it.args))
321-
)
322-
}
317+
toolCalls = message.parts.filterIsInstance<MessagePart.Tool.Call>()
318+
.takeIf { it.isNotEmpty() }
319+
?.map {
320+
OpenAIToolCall(
321+
it.id ?: Uuid.random().toString(),
322+
function = OpenAIFunction(it.tool, Json.encodeToString(it.args))
323+
)
324+
}
323325
)
324326
)
325327
}

0 commit comments

Comments
 (0)