fix: correct typo in properties variable and add null check
This commit is contained in:
parent
0fe7d559c8
commit
dffcaa11c3
@ -18,7 +18,10 @@ const supportedAttributes = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
function filterPropertieAttributes(tool: MCPTool, filterNestedObj = false) {
|
function filterPropertieAttributes(tool: MCPTool, filterNestedObj = false) {
|
||||||
const roperties = tool.inputSchema.properties
|
const properties = tool.inputSchema.properties
|
||||||
|
if (!properties) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
const getSubMap = (obj: Record<string, any>, keys: string[]) => {
|
const getSubMap = (obj: Record<string, any>, keys: string[]) => {
|
||||||
const filtered = Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key)))
|
const filtered = Object.fromEntries(Object.entries(obj).filter(([key]) => keys.includes(key)))
|
||||||
|
|
||||||
@ -46,10 +49,10 @@ function filterPropertieAttributes(tool: MCPTool, filterNestedObj = false) {
|
|||||||
return filtered
|
return filtered
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [key, val] of Object.entries(roperties)) {
|
for (const [key, val] of Object.entries(properties)) {
|
||||||
roperties[key] = getSubMap(val, supportedAttributes)
|
properties[key] = getSubMap(val, supportedAttributes)
|
||||||
}
|
}
|
||||||
return roperties
|
return properties
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mcpToolsToOpenAITools(mcpTools: MCPTool[]): Array<ChatCompletionTool> {
|
export function mcpToolsToOpenAITools(mcpTools: MCPTool[]): Array<ChatCompletionTool> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user