Bug: The function call plugin name printed is empty

Aperta
#13,516 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

  • #1 di @Whning0513 — chiusa senza merge
  • #13585 di @weiguangli-io — chiusa senza merge
  • #13672 di @aayushbaluni — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp, ollama
Ambito
ai

Direzione di ricerca

Inizia con kernel.Plugins.AddFromObject(plugin1, pluginName: "time") e Microsoft.SemanticKernel.FunctionCallContent.GetFunctionCalls(response), riproducendo l'esempio fornito di chat completion di Ollama. Il lavoro è completato quando la chiamata di funzione risultante espone il nome del plugin registrato, "time", e FunctionName e l'invocazione continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug triage

The function call plugin name printed is empty

Image

using Microsoft.SemanticKernel;

using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.Ollama;
using System.ComponentModel;
using System.Text;

#pragma warning disable SKEXP0110
public class TimePlugin
{
    [KernelFunction, Description("读取指定路径文件的内容,跨平台兼容~目录")]
    public string ReadFile(
        string filePath)
    {
        var ret = File.ReadAllText(filePath, Encoding.UTF8);
        return ret;

    }
    [KernelFunction, Description("This method is used to query the current system time and return it in the format yyyy-MM-dd HH:mm:ss")]
    public string QueryDateTime()
    {
        return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    }

    [KernelFunction, Description("The purpose of this method is to write the text content to the local computer's target path")]
    public void SaveFile(string filePath, string fileContent)
    {
        System.IO.File.WriteAllText(filePath, fileContent);
    }
}

class Program3
{
    public static async Task Main()
    {
        Console.OutputEncoding = System.Text.Encoding.UTF8;
        var builder = Kernel.CreateBuilder();
        var modelId = "qwen3:4b-instruct-2507-q4_K_M";
        var endpoint = new Uri("http://localhost:11434");

        builder.Services.AddOllamaChatCompletion(modelId, endpoint);

        var kernel = builder.Build();
        //KernelPlugin plugin = kernel.ImportPluginFromType<TimePlugin>();
        var plugin1 = new TimePlugin();
        kernel.Plugins.AddFromObject(plugin1, pluginName:"time");
        var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>();

        string prompt = "读取一下d:\\test123.txt的内容";
        var executionSettings = new OllamaPromptExecutionSettings
        {
            FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(autoInvoke: false)
        };

        var t0 = DateTime.Now;
        var response = await chatCompletionService.GetChatMessageContentAsync(prompt, kernel: kernel, executionSettings: executionSettings);
        var functionCalls = Microsoft.SemanticKernel.FunctionCallContent.GetFunctionCalls(response).ToArray();
        foreach (var functionCall in functionCalls)
        {
            Console.WriteLine($" {functionCall.PluginName}, {functionCall.FunctionName}");//error  have no PluginName
            var functionResult = await functionCall.InvokeAsync(kernel);
            Console.WriteLine($"{functionResult.Result}");
       
        }
        Console.WriteLine($"工具调用数 {functionCalls.Length}");
        Console.Write(response.Content);
    }
}


Lingua principale
C#
Stelle
28.8k
Fork
4.9k
Merge medio
2g 17h
PR unite (30g)
48

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/semantic-kernel

Tutte le issue di microsoft/semantic-kernel

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.