mlc-llm [问题]如何在MLCChat Android应用中使用函数调用?

u91tlkcl  于 2个月前  发布在  Android
关注(0)|答案(2)|浏览(47)

一般性问题

目前我使用的是Qwen2-1.5B-Instruct模型。我看到ChatCompletionRequest中有tools参数,但我不清楚如何构建ChatFunctionparameters属性。请问您能提供任何示例吗?

aoyhnmkz

aoyhnmkz1#

我可以像这样创建ChatTool示例:

val chatTool = ChatTool(
    function = ChatFunction(
        name = "get_current_weather",
        description = "Get the current weather",
        parameters = mapOf(
            "type" to "object",
            "properties" to """
|{
|    "location": {
|        "type": "string",
|        "description": "The city and state, e.g. San Francisco, CA",
|    },
|    "format": {
|        "type": "string",
|        "enum": ["celsius", "fahrenheit"],
|        "description": "The temperature unit to use. Infer this from the users location.",
|    },
|}
""".trimMargin(),
            "required" to "[\"location\", \"format\"]"
        )
    )
)
3wabscal

3wabscal2#

也想知道这个!

相关问题