Json Schema for LLMs
This commit is contained in:
@@ -56,11 +56,13 @@ type
|
||||
|
||||
// --- Factories ---
|
||||
// Registers a factory function. T must be registered via RegisterType<T> first.
|
||||
// UPDATED: Now supports documentation parameter.
|
||||
class procedure RegisterFactory<T: IInterface>(
|
||||
const Scope: IExecutionScope;
|
||||
const FactoryName: string;
|
||||
const FactoryArgs: TArray<IStaticType>;
|
||||
const FactoryDelegate: TInterfaceFactoryDelegate<T>
|
||||
const FactoryDelegate: TInterfaceFactoryDelegate<T>;
|
||||
const Doc: string = ''
|
||||
);
|
||||
|
||||
// --- Resolution ---
|
||||
@@ -176,8 +178,6 @@ begin
|
||||
var rIntf := rType as TRttiInterfaceType;
|
||||
// If the Interface has an "Invoke" method and is marked as reference-to (or is generic TFunc/TProc),
|
||||
// map it directly to stMethod.
|
||||
// Note: RTTI for "IsReferenceTo" is not always directly available,
|
||||
// but we can check if there is exactly one method named "Invoke".
|
||||
var method := rIntf.GetMethod('Invoke');
|
||||
if Assigned(method) and (Length(rIntf.GetMethods) = 1) then
|
||||
begin
|
||||
@@ -496,7 +496,8 @@ class procedure TRtlTypeRegistry.RegisterFactory<T>(
|
||||
const Scope: IExecutionScope;
|
||||
const FactoryName: string;
|
||||
const FactoryArgs: TArray<IStaticType>;
|
||||
const FactoryDelegate: TInterfaceFactoryDelegate<T>
|
||||
const FactoryDelegate: TInterfaceFactoryDelegate<T>;
|
||||
const Doc: string
|
||||
);
|
||||
var
|
||||
staticType: IStaticType;
|
||||
@@ -518,7 +519,7 @@ begin
|
||||
end;
|
||||
|
||||
var factorySig := TTypes.CreateMethod(FactoryArgs, staticType);
|
||||
Scope.Define(FactoryName, TDataValue(factoryWrapper), factorySig);
|
||||
Scope.Define(FactoryName, TDataValue(factoryWrapper), factorySig, Doc);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user