Add tools support to sampling (#976)
This commit is contained in:
parent
ad86b53347
commit
15139cc569
1 changed files with 1623 additions and 425 deletions
|
|
@ -20,7 +20,7 @@ public sealed class SampleLlmTool
|
|||
var samplingParams = CreateRequestSamplingParams(prompt ?? string.Empty, "sampleLLM", maxTokens);
|
||||
var sampleResult = await thisServer.SampleAsync(samplingParams, cancellationToken);
|
||||
|
||||
return $"LLM sampling result: {(sampleResult.Content as TextContentBlock)?.Text}";
|
||||
return $"LLM sampling result: {sampleResult.Content.OfType<TextContentBlock>().FirstOrDefault()?.Text}";
|
||||
}
|
||||
|
||||
private static CreateMessageRequestParams CreateRequestSamplingParams(string context, string uri, int maxTokens = 100)
|
||||
|
|
@ -30,7 +30,7 @@ public sealed class SampleLlmTool
|
|||
Messages = [new SamplingMessage
|
||||
{
|
||||
Role = Role.User,
|
||||
Content = new TextContentBlock { Text = $"Resource {uri} context: {context}" },
|
||||
Content = [new TextContentBlock { Text = $"Resource {uri} context: {context}" }],
|
||||
}],
|
||||
SystemPrompt = "You are a helpful test server.",
|
||||
MaxTokens = maxTokens,
|
||||
|
|
|
|||
Loading…
Reference in a new issue