助手
- OpenAI 的 Assistants API 拥有一个专用的 endpoint。
- Assistants API 支持创建 AI 助手,提供代码解释器、文件知识检索以及函数执行等功能。
- 点击此处阅读深入文档,了解该功能、其工作原理以及功能范围。
- 与常规 OpenAI API 一样,请前往 https://platform.openai.com/account/api-keys 获取密钥。
- 您需要将以下环境变量设置为您的密钥,或者将其设置为
user_provided以便用户提供他们自己的密钥。
ASSISTANTS_API_KEY=your-key- 您可以使用
ASSISTANTS_MODELS来确定您希望可用的模型;否则,将使用从 OpenAI 获取的模型列表(仅显示与 Assistants API 兼容的模型)。
ASSISTANTS_MODELS=gpt-3.5-turbo-0125,gpt-3.5-turbo-16k-0613,gpt-3.5-turbo-16k,gpt-3.5-turbo,gpt-4,gpt-4-0314,gpt-4-32k-0314,gpt-4-0613,gpt-3.5-turbo-0613,gpt-3.5-turbo-1106,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview- 如有必要,你也可以使用
ASSISTANTS_BASE_URL设置一个替代的 base URL,而不是使用官方地址,这与 OpenAI 的OPENAI_REVERSE_PROXY类似。
ASSISTANTS_BASE_URL=http://your-alt-baseURL:3080/- 根据您的需求,还有一些额外的可选配置(例如禁用 assistant builder UI),可以通过
librechat.yaml自定义配置文件 进行设置:
严格函数调用 (Strict function calling)
With librechat you can add add the 'x-strict': true flag at operation-level in the openapi spec for actions. This will automatically generate function calls with 'strict' mode enabled. Note that strict mode supports only a partial subset of json. Read https://platform.openai.com/docs/guides/structured-outputs for details.
例如:
{
"openapi": "3.1.0",
"info": {
"title": "Math.js API",
"description": "API for performing mathematical operations, such as addition, subtraction, etc.",
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.mathjs.org/v4"
}
],
"paths": {
"/": {
"post": {
"summary": "Evaluate a mathematical expression",
"description": "Sends a mathematical expression in the request body to evaluate.",
"operationId": "math",
"x-strict": true,
"parameters": [
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"expr": {
"type": "string",
"description": "The mathematical expression to evaluate (e.g., `2+3`)."
}
},
"required": ["expr"]
}
}
}
},
"responses": {
"200": {
"description": "The result of the evaluated expression.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"result": {
"type": "number",
"description": "The evaluated result of the expression."
}
}
}
}
}
},
"400": {
"description": "Invalid expression provided.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string",
"description": "Error message describing the invalid expression."
}
}
}
}
}
}
}
}
}
}
}注意
注意:
- 在撰写本文时,仅以下模型支持 Retrieval 功能:
- gpt-3.5-turbo-0125
- gpt-4-0125-preview
- gpt-4-turbo-preview
- gpt-4-1106-preview
- gpt-3.5-turbo-1106
- 目前尚不支持 Vision 功能。
- 如果您之前已经在您的 .env 文件中设置了
ENDPOINTS值,则需要添加assistants值。
这篇指南怎么样?