Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -99,7 +99,10 @@ public class ReasoningSetting
public class WebSearchSetting
{
public bool IsDefault { get; set; }

[Obsolete("Set SearchContextSize in Parameters")]
public string? SearchContextSize { get; set; }
public Dictionary<string, ModelParamSetting>? Parameters { get; set; }
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ private async Task<List<RoleDialogModel>> AssembleFiles(string conversationId, L
{
ContentType = x.ContentType,
FileUrl = x.FileUrl,
FileStorageUrl = x.FileStorageUrl
FileStorageUrl = x.FileStorageUrl,
FileName = x.FileName,
FileExtension = x.FileExtension
}).ToList();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BotSharp.Plugin.GoogleAI.Constants;
namespace BotSharp.Plugin.GoogleAi;

internal static class Constants
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task<RoleDialogModel> GetChatCompletions(Agent agent, List<RoleDial
};
}

if (responseMessage != null && thoughtPart != null)
if (thoughtPart != null)
{
responseMessage.MetaData ??= [];
responseMessage.MetaData[Constants.ThinkingText] = thoughtPart.Text;
Expand Down Expand Up @@ -263,7 +263,7 @@ public async Task<RoleDialogModel> GetChatCompletionsStreamingAsync(Agent agent,
});

using var textStream = new RealtimeTextStream();
using var thinkingTextStream = new RealtimeTextStream();
using var thinkingStream = new RealtimeTextStream();
ChatThoughtModel? thoughtModel = null;
UsageMetadata? tokenUsage = null;

Expand Down Expand Up @@ -301,7 +301,7 @@ public async Task<RoleDialogModel> GetChatCompletionsStreamingAsync(Agent agent,
if (!string.IsNullOrEmpty(thoughtPart?.Text))
{
var text = thoughtPart.Text;
thinkingTextStream.Collect(text);
thinkingStream.Collect(text);
hub.Push(new()
{
EventName = ChatEvent.OnReceiveLlmStreamMessage,
Expand Down Expand Up @@ -419,7 +419,7 @@ public async Task<RoleDialogModel> GetChatCompletionsStreamingAsync(Agent agent,
}

// Set thinking text in metadata
var thinkingText = thinkingTextStream.GetText();
var thinkingText = thinkingStream.GetText();
if (!string.IsNullOrEmpty(thinkingText))
{
responseMessage.MetaData ??= [];
Expand Down
1 change: 0 additions & 1 deletion src/Plugins/BotSharp.Plugin.GoogleAI/Using.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
global using BotSharp.Abstraction.Functions.Models;
global using BotSharp.Abstraction.Loggers;

global using BotSharp.Plugin.GoogleAI.Constants;
global using BotSharp.Plugin.GoogleAI.Models.Chat;
global using BotSharp.Plugin.GoogleAi.Settings;
global using BotSharp.Plugin.GoogleAi.Providers.Chat;
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ private List<RoleDialogModel> AssembleFiles(string conversationId, IEnumerable<s
{
ContentType = x.ContentType,
FileUrl = x.FileUrl,
FileStorageUrl = x.FileStorageUrl
FileStorageUrl = x.FileStorageUrl,
FileName = x.FileName,
FileExtension = x.FileExtension
}).ToList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<OutputPath>$(SolutionDir)packages</OutputPath>
</PropertyGroup>

<ItemGroup>
<None Remove="Providers\Chat\o23gzei4.rox~" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenAI" />
<PackageReference Include="Rougamo.Fody" />
Expand Down
6 changes: 6 additions & 0 deletions src/Plugins/BotSharp.Plugin.OpenAI/Constants/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BotSharp.Plugin.OpenAI;

internal static class Constants
{
internal const string ThinkingText = "thinking_text";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace BotSharp.Plugin.OpenAI.Models.Web;

/// <summary>
/// Approximate user location hint passed to the OpenAI web search tool.
/// Mirrors the shape of OpenAI's user_location payload (country, region, city, timezone).
/// </summary>
public class WebSearchUserLocation
{
private static readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip,
NumberHandling = JsonNumberHandling.AllowReadingFromString,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};

public string? Country { get; set; }
public string? Region { get; set; }
public string? City { get; set; }
public string? Timezone { get; set; }

[JsonIgnore]
public bool HasAnyValue =>
!string.IsNullOrEmpty(Country)
|| !string.IsNullOrEmpty(Region)
|| !string.IsNullOrEmpty(City)
|| !string.IsNullOrEmpty(Timezone);

public static WebSearchUserLocation? FromJson(string? json)
{
if (string.IsNullOrWhiteSpace(json))
{
return null;
}

try
{
return JsonSerializer.Deserialize<WebSearchUserLocation>(json, _jsonOptions);
}
catch (JsonException)
{
return null;
}
}

}
Loading
Loading