-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b4cd25
commit 70848af
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// ========================================================================== | ||
// Squidex Headless CMS | ||
// ========================================================================== | ||
// Copyright (c) Squidex UG (haftungsbeschraenkt) | ||
// All rights reserved. Licensed under the MIT license. | ||
// ========================================================================== | ||
|
||
namespace Squidex.AI; | ||
|
||
public sealed class DelegateChatTool : IChatTool | ||
{ | ||
private readonly Func<ToolContext, CancellationToken, Task<string>> action; | ||
|
||
public ToolSpec Spec { get; } | ||
|
||
public DelegateChatTool(ToolSpec spec, Func<ToolContext, CancellationToken, Task<string>> action) | ||
{ | ||
Spec = spec; | ||
|
||
this.action = action; | ||
} | ||
|
||
public Task<string> ExecuteAsync(ToolContext toolContext, CancellationToken ct) | ||
{ | ||
return action(toolContext, ct); | ||
} | ||
} |