# coze开源版（宝塔）

coze已经开源，本着大佬不用教，小白从简的原则，这里只教一下宝塔面板上使用的方法。

### 环境要求

2核4G

提前安装 Docker、Docker Compose，并启动 Docker 服务

国内服务器自行解决镜像源的问题

***

1. 宝塔面板进入`文件`界面，选择想要放置项目的目录，这里以/www为例<br>

   <figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2Fkcoj3HcIFZmqoMxlJlKx%2Fimage.png?alt=media&#x26;token=8bb5f3fe-4755-4088-af7e-377d7cd26185" alt=""><figcaption></figcaption></figure>
2. 进入/www文件夹，点击菜单栏里的终端，输入以下命令克隆代码<br>

   ```
   git clone https://github.com/coze-dev/coze-studio.git
   ```

   <br>

   <figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FRKNBLdDnbSWbfGeCUWFf%2Fimage.png?alt=media&#x26;token=da9d2402-e1dc-42cd-a357-c182888dfd89" alt=""><figcaption></figcaption></figure>

   \
   \
   执行完毕后长这样：\ <br>

   <figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FNbFAoqh1Orw2E60lUB6T%2Fimage.png?alt=media&#x26;token=e0a30946-c19e-4f84-8e58-4d8902d49f8f" alt=""><figcaption></figcaption></figure>

   \
   然后关闭终端窗口<br>
3. 刷新一下目录进入coze-studio文件夹

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FJR2lLev8oXAFNBVlFJ4o%2Fimage.png?alt=media&#x26;token=480cd952-8c54-48f7-8ff9-872c5f4615b7" alt=""><figcaption></figcaption></figure>

4. 然后进入/www/coze-studio/backend/conf/model 文件夹，第一次进入长这样：<br>

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FrJigXCcXrvsnmCTAYlRi%2Fimage.png?alt=media&#x26;token=e8d25f22-7ec2-4550-acee-57570a9ccdf1" alt=""><figcaption></figcaption></figure>

5. 然后点新建空白文本，命名为`模型名称.yaml`

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2F8tUoenWOFIN5uNcVtFii%2Fimage.png?alt=media&#x26;token=e732a209-da96-4bf1-a451-d5e8609cc6b0" alt=""><figcaption></figcaption></figure>

如`openai-gpt-4o.yaml`

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2Fl0JrnrfkEYrLYSTSs09H%2Fimage.png?alt=media&#x26;token=8d547c26-0134-457a-93e1-fe9545db8f57" alt=""><figcaption></figcaption></figure>

6. 双击打开文件，填入下面的内容（需要将秘钥替换成自己的实际秘钥），以下划线部分为必填，点击可查看说明

更多字段说明参考官方[说明文档](https://github.com/coze-dev/coze-studio/wiki/3.-%E6%A8%A1%E5%9E%8B%E9%85%8D%E7%BD%AE#%E5%AD%97%E6%AE%B5%E8%AF%B4%E6%98%8E)

<pre><code>id: 2001
name: GPT-4o
icon_uri: default_icon/openai_v2.png
icon_url: ""
description:
    zh: gpt 模型简介
    en: Multi-modal, 320ms, 88.7% MMLU, excels in education, customer support, health, and entertainment.
default_parameters:
    - name: temperature
      label:
        zh: 生成随机性
        en: Temperature
      desc:
        zh: '- **temperature**: 调高温度会使得模型的输出更多样性和创新性，反之，降低温度会使输出内容更加遵循指令要求但减少多样性。建议不要与“Top p”同时调整。'
        en: '**Temperature**:\n\n- When you increase this value, the model outputs more diverse and innovative content; when you decrease it, the model outputs less diverse content that strictly follows the given instructions.\n- It is recommended not to adjust this value with \"Top p\" at the same time.'
      type: float
      min: "0"
      max: "1"
      default_val:
        balance: "0.8"
        creative: "1"
        default_val: "1.0"
        precise: "0.3"
      precision: 1
      options: []
      style:
        widget: slider
        label:
            zh: 生成多样性
            en: Generation diversity
    - name: max_tokens
      label:
        zh: 最大回复长度
        en: Response max length
      desc:
        zh: 控制模型输出的Tokens 长度上限。通常 100 Tokens 约等于 150 个中文汉字。
        en: You can specify the maximum length of the tokens output through this value. Typically, 100 tokens are approximately equal to 150 Chinese characters.
      type: int
      min: "1"
      max: "4096"
      default_val:
        default_val: "4096"
      options: []
      style:
        widget: slider
        label:
            zh: 输入及输出设置
            en: Input and output settings
    - name: top_p
      label:
        zh: Top P
        en: Top P
      desc:
        zh: '- **Top p 为累计概率**: 模型在生成输出时会从概率最高的词汇开始选择，直到这些词汇的总概率累积达到Top p 值。这样可以限制模型只选择这些高概率的词汇，从而控制输出内容的多样性。建议不要与“生成随机性”同时调整。'
        en: '**Top P**:\n\n- An alternative to sampling with temperature, where only tokens within the top p probability mass are considered. For example, 0.1 means only the top 10% probability mass tokens are considered.\n- We recommend altering this or temperature, but not both.'
      type: float
      min: "0"
      max: "1"
      default_val:
        default_val: "0.7"
      precision: 2
      options: []
      style:
        widget: slider
        label:
            zh: 生成多样性
            en: Generation diversity
    - name: frequency_penalty
      label:
        zh: 重复语句惩罚
        en: Frequency penalty
      desc:
        zh: '- **frequency penalty**: 当该值为正时，会阻止模型频繁使用相同的词汇和短语，从而增加输出内容的多样性。'
        en: '**Frequency Penalty**: When positive, it discourages the model from repeating the same words and phrases, thereby increasing the diversity of the output.'
      type: float
      min: "-2"
      max: "2"
      default_val:
        default_val: "0"
      precision: 2
      options: []
      style:
        widget: slider
        label:
            zh: 生成多样性
            en: Generation diversity
    - name: presence_penalty
      label:
        zh: 重复主题惩罚
        en: Presence penalty
      desc:
        zh: '- **presence penalty**: 当该值为正时，会阻止模型频繁讨论相同的主题，从而增加输出内容的多样性'
        en: '**Presence Penalty**: When positive, it prevents the model from discussing the same topics repeatedly, thereby increasing the diversity of the output.'
      type: float
      min: "-2"
      max: "2"
      default_val:
        default_val: "0"
      precision: 2
      options: []
      style:
        widget: slider
        label:
            zh: 生成多样性
            en: Generation diversity
    - name: response_format
      label:
        zh: 输出格式
        en: Response format
      desc:
        zh: '- **文本**: 使用普通文本格式回复\n- **Markdown**: 将引导模型使用Markdown格式输出回复\n- **JSON**: 将引导模型使用JSON格式输出'
        en: '**Response Format**:\n\n- **Text**: Replies in plain text format\n- **Markdown**: Uses Markdown format for replies\n- **JSON**: Uses JSON format for replies'
      type: int
      min: ""
      max: ""
      default_val:
        default_val: "0"
      options:
        - label: Text
          value: "0"
        - label: Markdown
          value: "1"
        - label: JSON
          value: "2"
      style:
        widget: radio_buttons
        label:
            zh: 输入及输出设置
            en: Input and output settings
meta:
<a data-footnote-ref href="#user-content-fn-1">    name: gpt-4o</a>
<a data-footnote-ref href="#user-content-fn-2">    protocol: openai</a>
    capability:
        function_call: true
        input_modal:
            - text
            - image
        input_tokens: 128000
        json_mode: false
        max_tokens: 128000
        output_modal:
            - text
        output_tokens: 16384
        prefix_caching: false
        reasoning: false
        prefill_response: false
    conn_config:
        base_url: "https://one.ocoolai.com/v1"
<a data-footnote-ref href="#user-content-fn-3">        api_key: "sk-你的秘钥"</a>
        timeout: 0s
<a data-footnote-ref href="#user-content-fn-4">        model: "gpt-4o"</a>
        temperature: 0.7
        frequency_penalty: 0
        presence_penalty: 0
        max_tokens: 4096
        top_p: 1
        top_k: 0
        stop: []
        openai: null
        claude: null
        ark: null
        deepseek: null
        qwen: null
        gemini: null
        custom: {}
    status: 0

</code></pre>

7. 编辑完成后保存文档，每个模型一个yaml文件，想要多个模型参考上述步骤重复添加

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FQO58beC197Ig2cQ5oSaU%2Fimage.png?alt=media&#x26;token=1cd9591b-ffc5-4662-982c-6214743a694e" alt=""><figcaption></figcaption></figure>

8. 回到项目目录，点击docker文件夹进入，点击.env.example文件，原地复制粘贴，在弹窗里将文件名重命名为.env ，然后点击确认

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FTtTm4tz5F3IqitbhfcvG%2Fimage.png?alt=media&#x26;token=ad220b4c-bbee-40e7-a876-b40c98d55c57" alt=""><figcaption></figcaption></figure>

9. 双击.env 文件，找到#openai embedding 部分

* 将base URL改为`https://one.ocoolai.com/v1`
* embedding model改为`text-embedding-3-large`（或其他嵌入模型）
* API Key填成你自己的秘钥
* by azure改为`false`
* 向量维度（DIMS）填3072  -说明这个是模型支持的向量维度，每个模型的不一样，需要自行查询
* request dims小于向量维度即可 -这个是期望返回的向量维度，建议一致，都填3072

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FtweVO6WjBUes2lHRQZxK%2Fimage.png?alt=media&#x26;token=cdec549c-6917-4b7d-8883-4af2ccec71e2" alt=""><figcaption></figcaption></figure>

然后点击保存并关闭窗口

10. docker-compose.yaml文件需要说明一下，如果你的宝塔面板有安装过MySQL和Redis建议将端口映射改一下防止冲突，全新安装可以忽略，当然也建议修改一下，防止以后跟其他服务端口冲突。

* MySQL将`3306`:`3306`改为`3307或者其他差不多的数字`：`3306`<br>

  <figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FtxsuSlivip6fCBb8AAlP%2Fimage.png?alt=media&#x26;token=1cb7a530-0df3-4f3a-a64e-48ae84f676dc" alt=""><figcaption></figcaption></figure>

* Redis也一个道理，改成其他数字：6479<br>

  <figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FojYK2tZL9IVRQMO2hVDl%2Fimage.png?alt=media&#x26;token=05a523f4-ed0b-4cd3-bba8-a05f90682225" alt=""><figcaption></figcaption></figure>

11. 然后保存，在docker文件夹内点击顶栏终端，执行`docker-compose up -d`  <br>

    <figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FKJYVbVdAVz3AK5KgS6D7%2Fimage.png?alt=media&#x26;token=f0629274-9a54-481f-9c4c-e85ba572e82e" alt=""><figcaption></figcaption></figure>

    <br>
12. &#x20;等全部执行完成后，访问服务器IP地址:8888 ,输入一个邮箱地址和密码点击注册即可

<figure><img src="https://436059860-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F27MUvsFs5GaeaERkLQ7I%2Fuploads%2FtrO8XziMlaYVWbV03066%2Fimage.png?alt=media&#x26;token=fbfe7a3b-79ca-4d23-b26f-d110eff44c2b" alt=""><figcaption></figcaption></figure>

[^1]: 模型名，自己方便辨认即可，建议跟站点一致

[^2]: 本站所有模型都填OpenAI，包括claude、deepseek等

[^3]: 需要替换为自己的秘钥

[^4]: 模型名称，必填，该名称属于ID，必须与站点请求模型名称一致，建议直接从模型广场复制
