|
1 | 1 | import { OpenApi } from "../openapi/OpenApi"; |
2 | | -import { ILlmSchema } from "../schema/ILlmSchema"; |
3 | | -import { IValidation } from "../schema/IValidation"; |
| 2 | +import { ILlmFunction } from "../schema/ILlmFunction"; |
4 | 3 | import { IHttpMigrateRoute } from "./IHttpMigrateRoute"; |
5 | 4 |
|
6 | 5 | /** |
7 | 6 | * LLM function calling schema from OpenAPI operation. |
8 | 7 | * |
9 | | - * `IHttpLlmFunction` represents a single HTTP endpoint converted to LLM |
10 | | - * function calling format. Generated from {@link OpenApi.IOperation} as part of |
11 | | - * {@link IHttpLlmApplication}. |
| 8 | + * Extends {@link ILlmFunction} with HTTP-specific properties. Generated from |
| 9 | + * {@link OpenApi.IOperation} as part of {@link IHttpLlmApplication}. |
12 | 10 | * |
13 | | - * Key properties: |
| 11 | + * - {@link method}, {@link path}: HTTP endpoint info |
| 12 | + * - {@link operation}: Source OpenAPI operation |
| 13 | + * - {@link route}: Source migration route |
14 | 14 | * |
15 | | - * - {@link name}: Function name (max 64 chars for OpenAI compatibility) |
16 | | - * - {@link parameters}: Input schema with path/query/body merged |
17 | | - * - {@link output}: Response schema (undefined if void) |
18 | | - * - {@link description}: Critical for LLM function selection |
19 | | - * - {@link validate}: Built-in argument validator for error feedback |
20 | | - * |
21 | | - * The {@link validate} function is essential: LLMs make frequent type errors |
22 | | - * (e.g., `"123"` instead of `123`). Validate and retry improves success rate |
23 | | - * from ~50% to 99%. |
| 15 | + * Inherits {@link parse} and {@link validate} from {@link ILlmFunction}. |
24 | 16 | * |
25 | 17 | * @author Jeongho Nam - https://github.com/samchon |
26 | 18 | */ |
27 | | -export interface IHttpLlmFunction { |
| 19 | +export interface IHttpLlmFunction extends ILlmFunction { |
28 | 20 | /** HTTP method of the endpoint. */ |
29 | 21 | method: "get" | "post" | "patch" | "put" | "delete"; |
30 | 22 |
|
31 | 23 | /** Path of the endpoint. */ |
32 | 24 | path: string; |
33 | 25 |
|
34 | | - /** |
35 | | - * Function name composed from {@link IHttpMigrateRoute.accessor}. |
36 | | - * |
37 | | - * @maxLength 64 |
38 | | - */ |
39 | | - name: string; |
40 | | - |
41 | | - /** |
42 | | - * Parameter schema. |
43 | | - * |
44 | | - * With keyword mode: single object with pathParameters, query, body merged. |
45 | | - * Without keyword mode: array of [pathParameters..., query?, body?]. |
46 | | - */ |
47 | | - parameters: ILlmSchema.IParameters; |
48 | | - |
49 | | - /** |
50 | | - * Return type as an object parameters schema. |
51 | | - * |
52 | | - * Wraps the return type in an {@link ILlmSchema.IParameters} object with |
53 | | - * `$defs` for shared type definitions and `properties` for the structured |
54 | | - * output. `undefined` if the endpoint returns void. |
55 | | - */ |
56 | | - output?: ILlmSchema.IParameters | undefined; |
57 | | - |
58 | | - /** Function description for LLM context. Critical for function selection. */ |
59 | | - description?: string | undefined; |
60 | | - |
61 | | - /** Whether the function is deprecated. */ |
62 | | - deprecated?: boolean | undefined; |
63 | | - |
64 | 26 | /** Category tags from {@link OpenApi.IOperation.tags}. */ |
65 | 27 | tags?: string[]; |
66 | 28 |
|
67 | | - /** |
68 | | - * Lenient JSON parser with schema-based coercion. |
69 | | - * |
70 | | - * Parses incomplete/malformed JSON (unclosed brackets, trailing commas, |
71 | | - * unclosed strings) and coerces double-stringified values using the |
72 | | - * function's own {@link parameters} schema. |
73 | | - * |
74 | | - * This does NOT perform type validation — use {@link validate} after |
75 | | - * parsing to check the result. |
76 | | - * |
77 | | - * @param str Raw JSON string from LLM output |
78 | | - * @returns Validation result with parsed data or syntax errors |
79 | | - */ |
80 | | - parse: (str: string) => IValidation<unknown>; |
81 | | - |
82 | | - /** |
83 | | - * Validates LLM-composed arguments. |
84 | | - * |
85 | | - * LLMs frequently make type errors. Use this to provide validation feedback |
86 | | - * and retry. Success rate improves from ~50% to 99% on retry. |
87 | | - */ |
88 | | - validate: (args: unknown) => IValidation<unknown>; |
89 | | - |
90 | 29 | /** Returns the source {@link OpenApi.IOperation}. */ |
91 | 30 | operation: () => OpenApi.IOperation; |
92 | 31 |
|
|
0 commit comments