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>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.1" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="9.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -5,4 +5,4 @@ apps:
|
|||
- appDirPath: ./conversation/
|
||||
appID: conversation
|
||||
daprHTTPPort: 3500
|
||||
command: ["dotnet", "run"]
|
||||
command: ["dotnet", "run"]
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
using Dapr.AI.Conversation;
|
||||
using Dapr.AI.Conversation.ConversationRoles;
|
||||
using Dapr.AI.Conversation.Extensions;
|
||||
using Dapr.AI.Conversation.Tools;
|
||||
|
||||
const string conversationComponentName = "echo";
|
||||
const string prompt = "What is dapr?";
|
||||
|
@ -27,14 +28,39 @@ var app = builder.Build();
|
|||
|
||||
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>
|
||||
{
|
||||
new UserMessage {
|
||||
Name = "TestUser",
|
||||
Content = [
|
||||
new MessageContent(prompt),
|
||||
],
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapr.AI" Version="1.16.0-rc16" />
|
||||
<PackageReference Include="Dapr.AI" Version="1.16.0-rc18" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue