Giter Club home page Giter Club logo

Comments (7)

LittleLittleCloud avatar LittleLittleCloud commented on July 20, 2024

方便贴一下生成类的代码吗

from autogen.

lidisi8520 avatar lidisi8520 commented on July 20, 2024

方便贴一下生成类的代码吗

//----------------------
//
// This code was generated by a tool.
//
//----------------------
using Azure.AI.OpenAI;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System;
using AutoGen.Core;
using AutoGen.OpenAI.Extension;

namespace Edensoft.AIManage.SemanticKernel.ToolAgent
{
public partial class AgentTools
{

    private class ClientToolSchema
    {
        [JsonPropertyName(@"url")]
		public List<string> url {get; set;}
        [JsonPropertyName(@"bodyParam")]
		public List<Dictionary<string, object>> bodyParam {get; set;}
        [JsonPropertyName(@"urlParam")]
		public List<string> urlParam {get; set;}
        [JsonPropertyName(@"methodParam")]
		public List<string> methodParam {get; set;}
    }

    public Task<string> ClientToolWrapper(string arguments)
    {
        var schema = JsonSerializer.Deserialize<ClientToolSchema>(
            arguments, 
            new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
            });

        return ClientTool(schema.url, schema.bodyParam, schema.urlParam, schema.methodParam);
    }

    public FunctionContract ClientToolFunctionContract
    {
        get => new FunctionContract
        {
            Namespace = @"Edensoft.AIManage.SemanticKernel.ToolAgent",
            ClassName = @"AgentTools",
            Name = @"ClientTool",
            Description = @"创建http调用外部工具方法",
            ReturnType = typeof(Task<string>),
            Parameters = new []
            {
                new FunctionParameterContract
                {
                    Name = @"url",
                    Description = @"要调用的url",
                    ParameterType = typeof(List<string>),
                    IsRequired = true,
                },
                new FunctionParameterContract
                {
                    Name = @"bodyParam",
                    Description = @"body请求参数",
                    ParameterType = typeof(List<Dictionary<string, object>>),
                    IsRequired = true,
                },
                new FunctionParameterContract
                {
                    Name = @"urlParam",
                    Description = @"get请求参数",
                    ParameterType = typeof(List<string>),
                    IsRequired = true,
                },
                new FunctionParameterContract
                {
                    Name = @"methodParam",
                    Description = @"请求方法 get post put delete",
                    ParameterType = typeof(List<string>),
                    IsRequired = true,
                },
            },
        };
    }

    public Azure.AI.OpenAI.FunctionDefinition ClientToolFunction
    {
        get => this.ClientToolFunctionContract.ToOpenAIFunctionDefinition();
    }
}

}

这个是我添加注释之后生成的类,看起来和没有添加注释的没有什么区别

from autogen.

LittleLittleCloud avatar LittleLittleCloud commented on July 20, 2024

注释会被用于生成function contract和function definition

from autogen.

LittleLittleCloud avatar LittleLittleCloud commented on July 20, 2024

能不能放一下ide截图,看一下是哪里报错了

from autogen.

lidisi8520 avatar lidisi8520 commented on July 20, 2024

能不能放一下ide截图,看一下是哪里报错了

image
这个是启动的时候的报错,基本上都在这里了。但是,在类里面去看, 又看不出什么问题。

from autogen.

LittleLittleCloud avatar LittleLittleCloud commented on July 20, 2024

可能是没在csproj里加这个?

<GenerateDocumentationFile>true</GenerateDocumentationFile>

来源:https://microsoft.github.io/autogen-for-net/articles/Create-type-safe-function-call.html

这个option是ide里默认打开但是编译的时候默认关闭的,会影响source generator的syntax parsing behavior

from autogen.

lidisi8520 avatar lidisi8520 commented on July 20, 2024

可能是没在csproj里加这个? <GenerateDocumentationFile>true</GenerateDocumentationFile>

来源:https://microsoft.github.io/autogen-for-net/articles/Create-type-safe-function-call.html

好的,谢谢,已经解决

from autogen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.