# 带历史上下文的对话请求（With History）

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /api/chat:
    post:
      summary: 带历史上下文的对话请求（With History）
      deprecated: false
      description: >-
        Send a chat message with a conversation history. You can use this same
        approach to start the conversation using multi-shot or chain-of-thought
        prompting.
      tags:
        - 生成对话补全
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: 使用的AI模型名称
                  examples:
                    - gpt-3.5-turbo
                    - gpt-4
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - assistant
                        description: 消息发送者角色
                        examples:
                          - user
                      content:
                        type: string
                        description: 消息内容
                        examples:
                          - 你好，你是谁？
                    required:
                      - role
                      - content
                  description: 对话消息列表
                  examples:
                    - - role: user
                        content: 你好
                      - role: assistant
                        content: 你好！我是AI助手。
              required:
                - model
                - messages
              examples:
                - model: gpt-3.5-turbo
                  messages:
                    - role: user
                      content: 你能做什么？
            examples: {}
      responses:
        '200':
          description: 'A stream of JSON objects is returned:'
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                  created_at:
                    type: string
                  message:
                    type: object
                    properties:
                      role:
                        type: string
                      content:
                        type: string
                    required:
                      - role
                      - content
                    x-apifox-orders:
                      - role
                      - content
                  done:
                    type: boolean
                required:
                  - model
                  - created_at
                  - message
                  - done
                x-apifox-orders:
                  - model
                  - created_at
                  - message
                  - done
              examples:
                '1':
                  summary: Success
                  value:
                    model: llama3.2
                    created_at: '2023-08-04T08:52:19.385406455-07:00'
                    message:
                      role: assistant
                      content: The
                    done: false
                '2':
                  summary: Success
                  value:
                    model: llama3.2
                    created_at: '2023-08-04T19:22:45.499127Z'
                    done: true
                    total_duration: 8113331500
                    load_duration: 6396458
                    prompt_eval_count: 61
                    prompt_eval_duration: 398801000
                    eval_count: 468
                    eval_duration: 7701267000
          headers: {}
          x-apifox-name: Success
        x-200:Final response:
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                  created_at:
                    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
                  - done
                  - total_duration
                  - load_duration
                  - prompt_eval_count
                  - prompt_eval_duration
                  - eval_count
                  - eval_duration
                x-apifox-orders:
                  - model
                  - created_at
                  - done
                  - total_duration
                  - load_duration
                  - prompt_eval_count
                  - prompt_eval_duration
                  - eval_count
                  - eval_duration
          headers: {}
          x-apifox-name: Final response
      security: []
      x-apifox-folder: 生成对话补全
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/6041320/apis/api-272428826-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: http://localhost:11434/api/
    description: 正式环境
security: []

```
