{"version":3,"file":"ILlamaSchema.mjs","sources":["../../src/structures/ILlamaSchema.ts"],"sourcesContent":["import { ILlmSchemaV3_1 } from \"./ILlmSchemaV3_1\";\n\n/**\n * Type schema info of the Llama.\n *\n * `ILlamaSchema` is a type schema info of the Llama function calling.\n *\n * `ILlamaSchema` seems fully supporting the JSON schema definition of the OpenAPI v3.1\n * specification; {@link OpenApiV3_1.IJsonSchema}. By the way, as the\n * {@link OpenApiV3_1.IJsonSchema} has too much ambiguous and duplicated expressions,\n * `ILlamaSchema` is designed to be clear and simple for the Llama function calling,\n * by utilizng {@link ILlmSchemaV3_1} which has been transformed from the\n * {@link OpenApi.IJsonSchema} for the convenience and clarity.\n *\n * Therefore, `ILlamaSchema` does not follow the entire specification of\n * the OpenAPI v3.1. It has own specific restrictions and definitions. Here is the\n * list of how `ILlmSchemaV3_1` is different with the OpenAPI v3.1 JSON schema.\n *\n * - Decompose mixed type: {@link OpenApiV3_1.IJsonSchema.IMixed}\n * - Resolve nullable property: {@link OpenApiV3_1.IJsonSchema.__ISignificant.nullable}\n * - Tuple type is banned: {@link OpenApiV3_1.IJsonSchema.ITuple.prefixItems}\n * - Constant type is banned: {@link OpenApiV3_1.IJsonSchema.IConstant}\n * - Merge {@link OpenApiV3_1.IJsonSchema.IAnyOf} to {@link ILlamaSchema.IOneOf}\n * - Merge {@link OpenApiV3_1.IJsonSchema.IAllOf} to {@link ILlamaSchema.IObject}\n * - Merge {@link OpenApiV3_1.IJsonSchema.IRecursiveReference} to {@link ILlamaSchema.IReference}\n * - Do not support {@link OpenApiV3_1.IJsonSchema.ITuple} type\n *\n * If compare with the {@link OpenApi.IJsonSchema}, the emended JSON schema specification,\n *\n * - {@link ILlamaSchema.IParameters.$defs} instead of the {@link OpenApi.IJsonSchema.schemas}\n * - Do not support {@link OpenApi.IJsonSchema.ITuple} type\n * - {@link ILlamaSchema.properties} and {@link ILlamaSchema.required} are always defined\n *\n * For reference, if you've composed the `ILlamaSchema` type with the\n * {@link ILlamaSchema.IConfig.reference} `false` option (default is `false`), only the\n * recursive named types would be archived into the {@link ILlamaSchema.IParameters.$defs},\n * and the others would be escaped from the {@link ILlamaSchema.IReference} type.\n *\n * @reference https://www.llama.com/docs/model-cards-and-prompt-formats/llama3_2\n * @reference https://github.com/ggerganov/llama.cpp/blob/master/examples/json_schema_to_grammar.py\n * @warning Specified not only by the official documentation, but also by my\n *          experiments. Therefore, its definitions can be inaccurate or be\n *          changed in the future. If you find any wrong or outdated definitions,\n *          please let me know by issue.\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport type ILlamaSchema =\n  | ILlamaSchema.IConstant\n  | ILlamaSchema.IBoolean\n  | ILlamaSchema.IInteger\n  | ILlamaSchema.INumber\n  | ILlamaSchema.IString\n  | ILlamaSchema.IArray\n  | ILlamaSchema.IObject\n  | ILlamaSchema.IReference\n  | ILlamaSchema.IOneOf\n  | ILlamaSchema.INull\n  | ILlamaSchema.IUnknown;\nexport namespace ILlamaSchema {\n  export import IParameters = ILlmSchemaV3_1.IParameters;\n\n  export import IConstant = ILlmSchemaV3_1.IConstant;\n  export import IBoolean = ILlmSchemaV3_1.IBoolean;\n  export import IInteger = ILlmSchemaV3_1.IInteger;\n  export import INumber = ILlmSchemaV3_1.INumber;\n  export import IString = ILlmSchemaV3_1.IString;\n\n  export import IObject = ILlmSchemaV3_1.IObject;\n  export import IArray = ILlmSchemaV3_1.IArray;\n  export import IReference = ILlmSchemaV3_1.IReference;\n  export import IOneOf = ILlmSchemaV3_1.IOneOf;\n  export import INull = ILlmSchemaV3_1.INull;\n  export import IUnknown = ILlmSchemaV3_1.IUnknown;\n\n  /**\n   * Configuration for Llama schema composition.\n   */\n  export interface IConfig {\n    /**\n     * Whether to allow reference type in everywhere.\n     *\n     * If you configure this property to `false`, most of reference types\n     * represented by {@link ILlamaSchema.IReference} would be escaped to\n     * a plain type unless recursive type case.\n     *\n     * This is because some low sized LLM models does not understand the\n     * reference type well, and even the large size LLM models sometimes occur\n     * the hallucination.\n     *\n     * However, the reference type makes the schema size smaller, so that reduces\n     * the LLM token cost. Therefore, if you're using the large size of LLM model,\n     * and want to reduce the LLM token cost, you can configure this property to\n     * `true`.\n     *\n     * @default false\n     */\n    reference: boolean;\n  }\n}\n"],"names":["ILlamaSchema"],"mappings":"AA0DM,IAAWA;;CAAjB,SAAiBA,eAwChB,EAxCD,CAAiBA,iBAAAA,eAwChB,CAAA;;"}