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 @@ -68,6 +68,8 @@ public class LlmModelSetting
/// </summary>
public LlmCostSetting Cost { get; set; } = new();

public bool AllowPdfReading => Capabilities?.Contains(LlmModelCapability.PdfReading) == true;

public override string ToString()
{
return $"[{Type}] {Name} {Endpoint}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using BotSharp.Abstraction.Instructs.Models;
using BotSharp.Abstraction.Instructs;
using BotSharp.Abstraction.Files.Converters;
using BotSharp.Abstraction.Instructs;
using BotSharp.Abstraction.Instructs.Models;
using BotSharp.Abstraction.Instructs.Options;
using BotSharp.Abstraction.MLTasks;

namespace BotSharp.Core.Files.Services;

Expand All @@ -23,11 +24,16 @@ public async Task<string> ReadPdf(string text, List<InstructFileModel> files, In
try
{
var provider = options?.Provider ?? "openai";
var model = options?.Model ?? "gpt-5-mini";

var pdfFiles = await DownloadAndSaveFiles(sessionDir, files);
var targetFiles = pdfFiles;

var settingsService = _services.GetRequiredService<ILlmProviderService>();
var modelSettings = settingsService.GetSetting(provider, model);
var converter = GetImageConverter(options?.ImageConverter);
if (converter == null && provider == "openai")

if (converter == null && modelSettings?.AllowPdfReading != true)
{
var fileCoreSettings = _services.GetRequiredService<FileCoreSettings>();
converter = GetImageConverter(fileCoreSettings?.ImageConverter?.Provider);
Expand All @@ -44,7 +50,7 @@ public async Task<string> ReadPdf(string text, List<InstructFileModel> files, In
text = RenderText(text, options?.Data);

var completion = CompletionProvider.GetChatCompletion(_services, provider: provider,
model: options?.Model ?? "gpt-5-mini", multiModal: true);
model: model, multiModal: true);
var message = await completion.GetChatCompletions(new Agent()
{
Id = innerAgentId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ private string BuildFileName(string? name, string? extension, string defaultName

private IImageConverter? GetImageConverter(string? provider)
{
var converter = _services.GetServices<IImageConverter>().FirstOrDefault(x => x.Provider == (provider ?? "image-handler"));
if (string.IsNullOrEmpty(provider))
{
return null;
}

var converter = _services.GetServices<IImageConverter>().FirstOrDefault(x => x.Provider == provider);
return converter;
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(TargetFramework)</TargetFramework>
Expand All @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Infrastructure\BotSharp.Abstraction\BotSharp.Abstraction.csproj" />
<ProjectReference Include="..\..\Infrastructure\BotSharp.Core\BotSharp.Core.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/Plugins/BotSharp.Plugin.AnthropicAI/Constants/StopReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BotSharp.Plugin.AnthropicAI.Constants;

internal static class StopReason
{
internal const string EndTurn = "end_turn";
internal const string MaxTokens = "max_tokens";
internal const string ToolUse = "tool_use";
internal const string StopSequence = "stop_sequence";
internal const string ContentFilter = "content_filter";
internal const string GuardRail = "guardrail";
}
Loading
Loading