Chat UI 文档

OpenAI

Hugging Face's logo
加入 Hugging Face 社区

并获取增强的文档体验

开始使用

OpenAI

特性 可用性
工具
多模态

Chat UI 可以与任何支持 OpenAI API 兼容性的 API 服务器一起使用,例如 text-generation-webuiLocalAIFastChatllama-cpp-pythonialacolvllm

以下示例配置使 Chat UI 可以与 text-generation-webui 一起使用,endpoint.baseUrl 是 OpenAI API 兼容服务器的 url,这会覆盖 OpenAI 实例使用的 baseUrl。 endpoint.completion 确定要使用的端点,默认为 chat_completions,它使用 /chat/completions,将 endpoint.completion 更改为 completions 以使用 /completions 端点。

MODELS=`[
  {
    "name": "text-generation-webui",
    "id": "text-generation-webui",
    "parameters": {
      "temperature": 0.9,
      "top_p": 0.95,
      "repetition_penalty": 1.2,
      "top_k": 50,
      "truncate": 1000,
      "max_new_tokens": 1024,
      "stop": []
    },
    "endpoints": [{
      "type" : "openai",
      "baseURL": "https://#:8000/v1"
    }]
  }
]`

openai 类型包括官方 OpenAI 模型。您可以添加 GPT4/GPT3.5 等作为 “openai” 模型

OPENAI_API_KEY=#your openai api key here
MODELS=`[{
  "name": "gpt-4",
  "displayName": "GPT 4",
  "endpoints" : [{
    "type": "openai",
    "apiKey": "or your openai api key here"
  }]
},{
  "name": "gpt-3.5-turbo",
  "displayName": "GPT 3.5 Turbo",
  "endpoints" : [{
    "type": "openai",
    "apiKey": "or your openai api key here"
  }]
}]`

我们还支持 o1 系列中的模型。您需要向配置中添加更多选项:以下是 o1-mini 的示例

MODELS=`[
  {
      "name": "o1-mini",
      "description": "ChatGPT o1-mini",
      "systemRoleSupported": false,
      "parameters": {
        "max_new_tokens": 2048,
      },
      "endpoints" : [{
        "type": "openai",
        "useCompletionTokens": true,
      }]
  }
]

您还可以使用任何提供兼容 OpenAI API 端点模型提供商。例如,您可以自托管 Portkey 网关,并试用 Azure OpenAI 提供的 Claude 或 GPT。 Anthropic 的 Claude 示例

MODELS=`[{
  "name": "claude-2.1",
  "displayName": "Claude 2.1",
  "description": "Anthropic has been founded by former OpenAI researchers...",
  "parameters": {
    "temperature": 0.5,
    "max_new_tokens": 4096,
  },
  "endpoints": [
    {
      "type": "openai",
      "baseURL": "https://gateway.example.com/v1",
      "defaultHeaders": {
        "x-portkey-config": '{"provider":"anthropic","api_key":"sk-ant-abc...xyz"}'
      }
    }
  ]
}]`

Azure OpenAI 上部署的 GPT 4 示例

MODELS=`[{
  "id": "gpt-4-1106-preview",
  "name": "gpt-4-1106-preview",
  "displayName": "gpt-4-1106-preview",
  "parameters": {
    "temperature": 0.5,
    "max_new_tokens": 4096,
  },
  "endpoints": [
    {
      "type": "openai",
      "baseURL": "https://{resource-name}.openai.azure.com/openai/deployments/{deployment-id}",
      "defaultHeaders": {
        "api-key": "{api-key}"
      },
      "defaultQuery": {
        "api-version": "2023-05-15"
      }
    }
  ]
}]`

DeepInfra

或尝试来自 Deepinfra 的 Mistral

请注意,apiKey 可以为每个端点自定义设置,也可以使用 OPENAI_API_KEY 变量全局设置。

MODELS=`[{
  "name": "mistral-7b",
  "displayName": "Mistral 7B",
  "description": "A 7B dense Transformer, fast-deployed and easily customisable. Small, yet powerful for a variety of use cases. Supports English and code, and a 8k context window.",
  "parameters": {
    "temperature": 0.5,
    "max_new_tokens": 4096,
  },
  "endpoints": [
    {
      "type": "openai",
      "baseURL": "https://api.deepinfra.com/v1/openai",
      "apiKey": "abc...xyz"
    }
  ]
}]`

非流式端点

对于不支持流式的端点,例如 Azure 上的 o1,您可以在端点配置中传递 streamingSupported: false

MODELS=`[{
  "id": "o1-preview",
  "name": "o1-preview",
  "displayName": "o1-preview",
  "systemRoleSupported": false,
  "endpoints": [
    {
      "type": "openai",
      "baseURL": "https://my-deployment.openai.azure.com/openai/deployments/o1-preview",
      "defaultHeaders": {
        "api-key": "$SECRET"
      },
      "streamingSupported": false,
    }
  ]
}]`

其他

一些其他提供商及其 baseURL 以供参考。

Groq: https://api.groq.com/openai/v1 Fireworks: https://api.fireworks.ai/inference/v1

< > 在 GitHub 上 更新