From ed6a4d655c5f3429b97ff2f2c44bf6d97cc1c8c0 Mon Sep 17 00:00:00 2001 From: Olivier Schiavo Date: Tue, 4 Feb 2025 12:17:39 +0100 Subject: [PATCH] feat: x-strict: true in openapi spec action for assistants and agents --- .../pre_configured_ai/assistants.mdx | 86 ++++++++++++++++++- pages/docs/features/agents.mdx | 3 + 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/pages/docs/configuration/pre_configured_ai/assistants.mdx b/pages/docs/configuration/pre_configured_ai/assistants.mdx index 02c104884..5554b3b1b 100644 --- a/pages/docs/configuration/pre_configured_ai/assistants.mdx +++ b/pages/docs/configuration/pre_configured_ai/assistants.mdx @@ -28,6 +28,89 @@ ASSISTANTS_BASE_URL=http://your-alt-baseURL:3080/ - Set the timeout period in milliseconds for assistant runs. Helps manage system load by limiting total run operation time. [More info](/docs/configuration/librechat_yaml/object_structure/assistants_endpoint#timeoutms) - Specify which assistant Ids are supported or excluded [More info](/docs/configuration/librechat_yaml/object_structure/assistants_endpoint#supportedids) +## 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/some-type-specific-keywords-are-not-yet-supported for details. + +For example: +```json filename="mathapi.json" +{ + "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." + } + } + } + } + } + } + } + } + } + } +} +``` **Notes:** @@ -39,4 +122,5 @@ ASSISTANTS_BASE_URL=http://your-alt-baseURL:3080/ - gpt-3.5-turbo-1106 - Vision capability is not yet supported. - If you have previously set the [`ENDPOINTS` value in your .env file](./dotenv.md#endpoints), you will need to add the value `assistants` - \ No newline at end of file + + diff --git a/pages/docs/features/agents.mdx b/pages/docs/features/agents.mdx index d913a44d5..fa6960023 100644 --- a/pages/docs/features/agents.mdx +++ b/pages/docs/features/agents.mdx @@ -89,6 +89,9 @@ With the Actions capability, you can dynamically create tools from [OpenAPI spec - Individual domains can be whitelisted for agent actions: - [More info](/docs/configuration/librechat_yaml/object_structure/actions#alloweddomains) +Note that you can add add the 'x-strict': true flag at operation-level in the OpenAPI spec for actions. +If using an OpenAI model supporting it, this will automatically generate function calls with 'strict' mode enabled. +Strict mode supports only a partial subset of json. Read https://platform.openai.com/docs/guides/structured-outputs/some-type-specific-keywords-are-not-yet-supported for details. ### Model Context Protocol (MCP)