Chat UI 文档

工具

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

工具

工具调用 (Tool calling) 指示模型生成与用户定义模式匹配的输出,该模式可以被解析以调用外部工具。模型仅选择工具及其参数。目前,仅支持 TGI 和带有 Command R+Cohere

TGI 配置

提示模型生成工具调用以及使用结果进行提示时,需要一个自定义的分词器。这些工具的预期格式和生成的工具调用对于 TGI 是硬编码的,所以很可能只有以下配置才有效。

MODELS=`[
  {
    "name" : "CohereForAI/c4ai-command-r-plus",
    "displayName": "Command R+",
    "description": "Command R+ is Cohere's latest LLM and is the first open weight model to beat GPT4 in the Chatbot Arena!",
    "tools": true,
    "tokenizer": "Xenova/c4ai-command-r-v01-tokenizer",
    "modelUrl": "https://huggingface.co/CohereForAI/c4ai-command-r-plus",
    "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
    "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
    "parameters": {
      "stop": ["<|END_OF_TURN_TOKEN|>"],
      "truncate" : 28672,
      "max_new_tokens" : 4096,
      "temperature" : 0.3
    }
  }
]`

Cohere 配置

Cohere 提供程序支持端点的原生工具调用方法。有关实现细节,请参阅 endpoints/cohere

MODELS=`[
  {
    "name": "command-r-plus",
    "displayName": "Command R+",
    "description": "Command R+ is Cohere's latest LLM and is the first open weight model to beat GPT4 in the Chatbot Arena!",
    "tools": true,
    "websiteUrl": "https://docs.cohere.com/docs/command-r-plus",
    "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/cohere-logo.png",
    "endpoints": [{
      "type": "cohere",
      "apiKey": "YOUR_API_KEY"
    }]
  }
]`

添加工具

工具的实现在 src/lib/server/tools 中,并提供了辅助工具以便与 HuggingFace Zero GPU Spaces 轻松集成。未来可能会有一个 OpenAPI 接口用于添加工具。

为其他模型添加支持

TGI 的实现使用了一个自定义的分词器和硬编码的模式来支持工具。而 Cohere 的实现则使用 SDK 中的原生支持来发出工具调用。这是为更多模型添加支持的推荐方法。有关实现细节,请参阅代码的 endpoints/cohere 部分。

< > 在 GitHub 上更新