Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ static async Task<ChatResponse> ToChatResponseAsync(
/// <param name="response">The <see cref="ChatResponse"/> object whose properties should be updated based on <paramref name="update"/>.</param>
private static void ProcessUpdate(ChatResponseUpdate update, Dictionary<int, ChatMessage> messages, ChatResponse response)
{
response.ResponseId ??= update.ResponseId;
response.ChatThreadId ??= update.ChatThreadId;
response.CreatedAt ??= update.CreatedAt;
response.FinishReason ??= update.FinishReason;
response.ModelId ??= update.ModelId;
response.ResponseId ??= update.ResponseId;

#if NET
ChatMessage message = CollectionsMarshal.GetValueRefOrAddDefault(messages, update.ChoiceIndex, out _) ??=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private static string GetLastSegmentFromPath(string name)
=> name.Substring(name.LastIndexOf('/') + 1);

private static string StripExtension(string name)
=> name.Substring(0, name.LastIndexOf(".", StringComparison.Ordinal));
=> name.Substring(0, name.LastIndexOf('.'));

private static (string path, bool isDir) GetResultPath(
string? executionName = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ private IEnumerable<OllamaChatRequestMessage> ToOllamaChatRequestMessages(ChatMe
currentTextMessage = new OllamaChatRequestMessage
{
Role = content.Role.Value,
Content = textContent.Text ?? string.Empty,
Content = textContent.Text,
};
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ strictObj is bool strictValue ?
// Store the tool mode.
switch (options.ToolMode)
{
case NoneChatToolMode:
runOptions.ToolConstraint = ToolConstraint.None;
break;

case null:
case AutoChatToolMode:
runOptions.ToolConstraint = ToolConstraint.Auto;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task ToChatResponse_SuccessfullyCreatesResponse(bool useAsync, bool
new() { ChoiceIndex = 1, Text = "Hey", ResponseId = "12345", CreatedAt = new DateTimeOffset(1, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model124" },

new() { ChoiceIndex = 0, Text = ", ", AuthorName = "Someone", Role = ChatRole.User, AdditionalProperties = new() { ["a"] = "b" } },
new() { ChoiceIndex = 1, Text = ", ", AuthorName = "Else", Role = ChatRole.System, AdditionalProperties = new() { ["g"] = "h" } },
new() { ChoiceIndex = 1, Text = ", ", AuthorName = "Else", Role = ChatRole.System, ChatThreadId = "123", AdditionalProperties = new() { ["g"] = "h" } },

new() { ChoiceIndex = 0, Text = "world!", CreatedAt = new DateTimeOffset(2, 2, 3, 4, 5, 6, TimeSpan.Zero), AdditionalProperties = new() { ["c"] = "d" } },
new() { ChoiceIndex = 1, Text = "you!", Role = ChatRole.Tool, CreatedAt = new DateTimeOffset(3, 2, 3, 4, 5, 6, TimeSpan.Zero), AdditionalProperties = new() { ["e"] = "f", ["i"] = 42 } },
Expand All @@ -69,6 +69,8 @@ public async Task ToChatResponse_SuccessfullyCreatesResponse(bool useAsync, bool
Assert.Equal(new DateTimeOffset(1, 2, 3, 4, 5, 6, TimeSpan.Zero), response.CreatedAt);
Assert.Equal("model123", response.ModelId);

Assert.Equal("123", response.ChatThreadId);

Assert.Equal(3, response.Choices.Count);

ChatMessage message = response.Choices[0];
Expand Down