mirror of https://github.com/dapr/quickstarts.git
Set up a tool function.
Signed-off-by: Alexander Trauzzi <acj@trauzzi.me>
This commit is contained in:
parent
56f19a8081
commit
16a790fc1a
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="System.Text.Json" Version="9.0.1" />
|
<PackageReference Include="System.Text.Json" Version="9.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -5,4 +5,4 @@ apps:
|
||||||
- appDirPath: ./conversation/
|
- appDirPath: ./conversation/
|
||||||
appID: conversation
|
appID: conversation
|
||||||
daprHTTPPort: 3500
|
daprHTTPPort: 3500
|
||||||
command: ["dotnet", "run"]
|
command: ["dotnet", "run"]
|
||||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
||||||
using Dapr.AI.Conversation;
|
using Dapr.AI.Conversation;
|
||||||
using Dapr.AI.Conversation.ConversationRoles;
|
using Dapr.AI.Conversation.ConversationRoles;
|
||||||
using Dapr.AI.Conversation.Extensions;
|
using Dapr.AI.Conversation.Extensions;
|
||||||
|
using Dapr.AI.Conversation.Tools;
|
||||||
|
|
||||||
const string conversationComponentName = "echo";
|
const string conversationComponentName = "echo";
|
||||||
const string prompt = "What is dapr?";
|
const string prompt = "What is dapr?";
|
||||||
|
@ -27,14 +28,39 @@ var app = builder.Build();
|
||||||
|
|
||||||
var conversationClient = app.Services.GetRequiredService<DaprConversationClient>();
|
var conversationClient = app.Services.GetRequiredService<DaprConversationClient>();
|
||||||
|
|
||||||
var conversationOptions = new ConversationOptions(conversationComponentName);
|
var conversationOptions = new ConversationOptions(conversationComponentName)
|
||||||
|
{
|
||||||
|
Tools = [
|
||||||
|
new ToolFunction("demo")
|
||||||
|
{
|
||||||
|
Parameters = new Dictionary<string, object?> {
|
||||||
|
{ "type", "object" },
|
||||||
|
{ "properties", new Dictionary<string, object?>
|
||||||
|
{
|
||||||
|
{ "location", new Dictionary<string, object?>
|
||||||
|
{
|
||||||
|
{ "type", "string" },
|
||||||
|
{ "description", "The city and state, e.g. San Francisco, CA" },
|
||||||
|
} },
|
||||||
|
{ "unit", new Dictionary<string, object?>
|
||||||
|
{
|
||||||
|
{ "type", "string" },
|
||||||
|
{ "enum", new[] { "celsius", "fahrenheit" } },
|
||||||
|
{ "description", "The temperature unit to use" },
|
||||||
|
} },
|
||||||
|
} },
|
||||||
|
{ "required", "location" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
var inputs = new ConversationInput(new List<IConversationMessage>
|
var inputs = new ConversationInput(new List<IConversationMessage>
|
||||||
{
|
{
|
||||||
new UserMessage {
|
new UserMessage {
|
||||||
Name = "TestUser",
|
Name = "TestUser",
|
||||||
Content = [
|
Content = [
|
||||||
new MessageContent(prompt),
|
new MessageContent(prompt),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapr.AI" Version="1.16.0-rc16" />
|
<PackageReference Include="Dapr.AI" Version="1.16.0-rc18" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in New Issue