pull/700/head
Travis Fischer 2025-03-23 04:30:50 +08:00
rodzic 3b32894992
commit 47dabc296e
3 zmienionych plików z 16 dodań i 6 usunięć

Wyświetl plik

@ -1468,7 +1468,7 @@ export namespace notion {
/** /**
* Agentic Notion client. * Agentic Notion client.
* *
* API specification for Notion * API specification for Notion.
*/ */
export class NotionClient extends AIFunctionsProvider { export class NotionClient extends AIFunctionsProvider {
protected readonly ky: KyInstance protected readonly ky: KyInstance

Wyświetl plik

@ -16,6 +16,7 @@ import {
getAndResolve, getAndResolve,
getComponentDisplayName, getComponentDisplayName,
getComponentName, getComponentName,
getDescription,
getOperationParamsName, getOperationParamsName,
getOperationResponseName, getOperationResponseName,
jsonSchemaToZod, jsonSchemaToZod,
@ -472,10 +473,9 @@ async function main() {
? '`' + path.replaceAll(/{([^}]+)}/g, '${params["$1"]}') + '`' ? '`' + path.replaceAll(/{([^}]+)}/g, '${params["$1"]}') + '`'
: `'${path}'` : `'${path}'`
let description = operation.description || operation.summary const description = getDescription(
if (description && !/[!.?]$/.test(description)) { operation.description || operation.summary
description += '.' )
}
const isDescriptionMultiline = description?.includes('\n') const isDescriptionMultiline = description?.includes('\n')
const aiClientMethod = ` const aiClientMethod = `
@ -604,6 +604,8 @@ import { z } from 'zod'`.trim()
.filter(Boolean) .filter(Boolean)
.join('\n\n') .join('\n\n')
const description = getDescription(spec.info?.description)
const output = ( const output = (
await prettify( await prettify(
[ [
@ -611,7 +613,7 @@ import { z } from 'zod'`.trim()
` `
/** /**
* Agentic ${name} client.${spec.info?.description ? `\n *\n * ${spec.info.description}` : ''} * Agentic ${name} client.${description ? `\n *\n * ${description}` : ''}
*/ */
export class ${clientName} extends AIFunctionsProvider { export class ${clientName} extends AIFunctionsProvider {
protected readonly ky: KyInstance protected readonly ky: KyInstance

Wyświetl plik

@ -322,3 +322,11 @@ export function naiveMergeJSONSchemas(...schemas: IJsonSchema[]): IJsonSchema {
return result as IJsonSchema return result as IJsonSchema
} }
export function getDescription(description?: string): string | undefined {
if (description && !/[!.?]$/.test(description)) {
description += '.'
}
return description
}