# 支持工具调用的对话请求（with Tools）

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /api/chat:
    post:
      summary: 支持工具调用的对话请求（with Tools）
      deprecated: false
      description: ''
      tags:
        - 生成对话补全
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: 使用的模型名称
                  example: gpt-3.5-turbo
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        description: 消息角色
                        example: user
                      content:
                        type: string
                        description: 消息内容
                        example: 你好，你是谁？
                    required:
                      - role
                      - content
                stream:
                  type: boolean
                  description: 是否使用流式响应
                  example: false
                tools:
                  type: array
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        description: 工具类型
                        example: function
                      function:
                        type: object
                        properties:
                          name:
                            type: string
                            description: 函数名称
                            example: get_current_weather
                          description:
                            type: string
                            description: 函数描述
                            example: 获取当前天气
                          parameters:
                            type: object
                            properties:
                              type:
                                type: string
                                description: 参数类型
                                example: object
                              properties:
                                type: object
                                additionalProperties:
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      description: 属性类型
                                      example: string
                                    description:
                                      type: string
                                      description: 属性描述
                                      example: 城市名称
                                    enum:
                                      type: array
                                      items:
                                        type: string
                                      description: 可选值枚举
                                      example:
                                        - 北京
                                        - 上海
                                        - 广州
                                properties: {}
                              required:
                                type: array
                                items:
                                  type: string
                                description: 必需参数列表
                                example:
                                  - location
              required:
                - model
                - messages
            examples: {}
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                  created_at:
                    type: string
                  message:
                    type: object
                    properties:
                      role:
                        type: string
                      content:
                        type: string
                      tool_calls:
                        type: array
                        items:
                          type: object
                          properties:
                            function:
                              type: object
                              properties:
                                name:
                                  type: string
                                arguments:
                                  type: object
                                  properties:
                                    format:
                                      type: string
                                    location:
                                      type: string
                                  required:
                                    - format
                                    - location
                                  x-apifox-orders:
                                    - format
                                    - location
                              required:
                                - name
                                - arguments
                              x-apifox-orders:
                                - name
                                - arguments
                          x-apifox-orders:
                            - function
                    required:
                      - role
                      - content
                      - tool_calls
                    x-apifox-orders:
                      - role
                      - content
                      - tool_calls
                  done_reason:
                    type: string
                  done:
                    type: boolean
                  total_duration:
                    type: integer
                  load_duration:
                    type: integer
                  prompt_eval_count:
                    type: integer
                  prompt_eval_duration:
                    type: integer
                  eval_count:
                    type: integer
                  eval_duration:
                    type: integer
                required:
                  - model
                  - created_at
                  - message
                  - done_reason
                  - done
                  - total_duration
                  - load_duration
                  - prompt_eval_count
                  - prompt_eval_duration
                  - eval_count
                  - eval_duration
                x-apifox-orders:
                  - model
                  - created_at
                  - message
                  - done_reason
                  - done
                  - total_duration
                  - load_duration
                  - prompt_eval_count
                  - prompt_eval_duration
                  - eval_count
                  - eval_duration
              example:
                model: llama3.2
                created_at: '2024-07-22T20:33:28.123648Z'
                message:
                  role: assistant
                  content: ''
                  tool_calls:
                    - function:
                        name: get_current_weather
                        arguments:
                          format: celsius
                          location: Paris, FR
                done_reason: stop
                done: true
                total_duration: 885095291
                load_duration: 3753500
                prompt_eval_count: 122
                prompt_eval_duration: 328493000
                eval_count: 33
                eval_duration: 552222000
          headers: {}
          x-apifox-name: Success
      security: []
      x-apifox-folder: 生成对话补全
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/6041320/apis/api-272428829-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: http://localhost:11434/api/
    description: 正式环境
security: []

```
