kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: small fixes for example ts sdk usage and gateway
rodzic
65a16d8453
commit
938be099df
|
@ -109,7 +109,8 @@ app.all(async (ctx) => {
|
|||
} else {
|
||||
originResponse = await createHttpResponseFromMcpToolCallResponse(ctx, {
|
||||
...resolvedHttpEdgeRequest,
|
||||
toolCallResponse: resolvedOriginToolCallResult.toolCallResponse
|
||||
toolCallResponse: resolvedOriginToolCallResult.toolCallResponse,
|
||||
toolConfig: resolvedOriginToolCallResult.toolConfig
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { AdminDeployment, Tool } from '@agentic/platform-types'
|
||||
import type { AdminDeployment, Tool, ToolConfig } from '@agentic/platform-types'
|
||||
import { assert } from '@agentic/platform-core'
|
||||
|
||||
import type { GatewayHonoContext, McpToolCallResponse } from './types'
|
||||
|
@ -9,11 +9,13 @@ export async function createHttpResponseFromMcpToolCallResponse(
|
|||
{
|
||||
tool,
|
||||
deployment,
|
||||
toolCallResponse
|
||||
toolCallResponse,
|
||||
toolConfig
|
||||
}: {
|
||||
tool: Tool
|
||||
deployment: AdminDeployment
|
||||
toolCallResponse: McpToolCallResponse
|
||||
toolConfig?: ToolConfig
|
||||
}
|
||||
): Promise<Response> {
|
||||
assert(
|
||||
|
@ -29,6 +31,12 @@ export async function createHttpResponseFromMcpToolCallResponse(
|
|||
)
|
||||
|
||||
if (tool.outputSchema) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`tool call "${tool.name}" structured response:`, {
|
||||
outputSchema: tool.outputSchema,
|
||||
toolCallResponse
|
||||
})
|
||||
|
||||
assert(
|
||||
toolCallResponse.structuredContent,
|
||||
502,
|
||||
|
@ -41,7 +49,8 @@ export async function createHttpResponseFromMcpToolCallResponse(
|
|||
data: toolCallResponse.structuredContent as Record<string, unknown>,
|
||||
coerce: false,
|
||||
// TODO: double-check MCP schema on whether additional properties are allowed
|
||||
strictAdditionalProperties: true,
|
||||
strictAdditionalProperties:
|
||||
toolConfig?.outputSchemaAdditionalProperties === false,
|
||||
errorPrefix: `Invalid tool response for tool "${tool.name}"`,
|
||||
errorStatusCode: 502
|
||||
})
|
||||
|
|
|
@ -21,7 +21,7 @@ async function main() {
|
|||
prompt: 'What is the weather in San Francisco?'
|
||||
})
|
||||
|
||||
console.log(result.toolResults[0])
|
||||
console.log(JSON.stringify(result.toolResults[0], null, 2))
|
||||
}
|
||||
|
||||
await main()
|
||||
|
|
|
@ -18,7 +18,7 @@ async function main() {
|
|||
prompt: 'What is the weather in San Francisco?'
|
||||
})
|
||||
|
||||
console.log(result.toolResults[0])
|
||||
console.log(JSON.stringify(result.toolResults[0], null, 2))
|
||||
}
|
||||
|
||||
await main()
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
import { calculator } from '@agentic/calculator'
|
||||
defTool(calculator)
|
||||
|
||||
$`Answer the following arithmetic question: How much is 11 + 4? then divide by 3?`
|
1
todo.md
1
todo.md
|
@ -26,6 +26,7 @@
|
|||
- add caching to public projects api endpoints
|
||||
- add support for [`@google/genai`](https://github.com/googleapis/js-genai) tools adapter and examples
|
||||
- fix gateway sentry deployment upload
|
||||
- add feature about optimized context to marketing site
|
||||
|
||||
## TODO: Post-MVP
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue