refac
This commit is contained in:
@@ -697,9 +697,10 @@ def convert_openapi_to_tool_payload(openapi_spec):
|
|||||||
"parameters": {"type": "object", "properties": {}, "required": []},
|
"parameters": {"type": "object", "properties": {}, "required": []},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extract path and query parameters
|
|
||||||
for param in operation.get("parameters", []):
|
for param in operation.get("parameters", []):
|
||||||
param_name = param["name"]
|
param_name = param.get("name")
|
||||||
|
if not param_name:
|
||||||
|
continue
|
||||||
param_schema = param.get("schema", {})
|
param_schema = param.get("schema", {})
|
||||||
description = param_schema.get("description", "")
|
description = param_schema.get("description", "")
|
||||||
if not description:
|
if not description:
|
||||||
@@ -971,8 +972,10 @@ async def execute_tool_server(
|
|||||||
body_params = {}
|
body_params = {}
|
||||||
|
|
||||||
for param in operation.get("parameters", []):
|
for param in operation.get("parameters", []):
|
||||||
param_name = param["name"]
|
param_name = param.get("name")
|
||||||
param_in = param["in"]
|
if not param_name:
|
||||||
|
continue
|
||||||
|
param_in = param.get("in")
|
||||||
if param_name in params:
|
if param_name in params:
|
||||||
if param_in == "path":
|
if param_in == "path":
|
||||||
path_params[param_name] = params[param_name]
|
path_params[param_name] = params[param_name]
|
||||||
|
|||||||
@@ -449,8 +449,9 @@ export const executeToolServer = async (
|
|||||||
|
|
||||||
if (operation.parameters) {
|
if (operation.parameters) {
|
||||||
operation.parameters.forEach((param: any) => {
|
operation.parameters.forEach((param: any) => {
|
||||||
const paramName = param.name;
|
const paramName = param?.name;
|
||||||
const paramIn = param.in;
|
if (!paramName) return;
|
||||||
|
const paramIn = param?.in;
|
||||||
if (params.hasOwnProperty(paramName)) {
|
if (params.hasOwnProperty(paramName)) {
|
||||||
if (paramIn === 'path') {
|
if (paramIn === 'path') {
|
||||||
pathParams[paramName] = params[paramName];
|
pathParams[paramName] = params[paramName];
|
||||||
@@ -1674,7 +1675,7 @@ export interface ModelMeta {
|
|||||||
profile_image_url?: string;
|
profile_image_url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelParams {}
|
export interface ModelParams { }
|
||||||
|
|
||||||
export type GlobalModelConfig = ModelConfig[];
|
export type GlobalModelConfig = ModelConfig[];
|
||||||
|
|
||||||
|
|||||||
@@ -1277,17 +1277,20 @@ export const convertOpenApiToToolPayload = (openApiSpec) => {
|
|||||||
// Extract path and query parameters
|
// Extract path and query parameters
|
||||||
if (operation.parameters) {
|
if (operation.parameters) {
|
||||||
operation.parameters.forEach((param) => {
|
operation.parameters.forEach((param) => {
|
||||||
let description = param.schema.description || param.description || '';
|
const paramName = param?.name;
|
||||||
if (param.schema.enum && Array.isArray(param.schema.enum)) {
|
if (!paramName) return;
|
||||||
description += `. Possible values: ${param.schema.enum.join(', ')}`;
|
const paramSchema = param?.schema ?? {};
|
||||||
|
let description = paramSchema.description || param.description || '';
|
||||||
|
if (paramSchema.enum && Array.isArray(paramSchema.enum)) {
|
||||||
|
description += `. Possible values: ${paramSchema.enum.join(', ')}`;
|
||||||
}
|
}
|
||||||
tool.parameters.properties[param.name] = {
|
tool.parameters.properties[paramName] = {
|
||||||
type: param.schema.type,
|
type: paramSchema.type,
|
||||||
description: description
|
description: description
|
||||||
};
|
};
|
||||||
|
|
||||||
if (param.required) {
|
if (param.required) {
|
||||||
tool.parameters.required.push(param.name);
|
tool.parameters.required.push(paramName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user