-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,150 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ lib/ | |
node_modules/ | ||
|
||
package-lock.json | ||
pnpm-lock.yaml | ||
pnpm-lock.yaml | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { HttpMigration } from "./HttpMigration"; | ||
import { OpenApi } from "./OpenApi"; | ||
import { LlmComposer } from "./converters/LlmComposer"; | ||
import { LlmMerger } from "./converters/LlmMerger"; | ||
import { HttpLlmFunctionFetcher } from "./http/HttpLlmFunctionFetcher"; | ||
import { IHttpConnection } from "./structures/IHttpConnection"; | ||
import { IHttpLlmApplication } from "./structures/IHttpLlmApplication"; | ||
import { IHttpLlmFunction } from "./structures/IHttpLlmFunction"; | ||
import { IHttpMigrateApplication } from "./structures/IHttpMigrateApplication"; | ||
import { IHttpResponse } from "./structures/IHttpResponse"; | ||
import { ILlmSchema } from "./structures/ILlmSchema"; | ||
|
||
export namespace HttpLanguageModel { | ||
export const application = < | ||
Schema extends ILlmSchema, | ||
Operation extends OpenApi.IOperation, | ||
>( | ||
document: | ||
| OpenApi.IDocument<any, Operation> | ||
| IHttpMigrateApplication<any, Operation>, | ||
options?: Partial<IHttpLlmApplication.IOptions>, | ||
): IHttpLlmApplication<Schema> => { | ||
// MIGRATE | ||
if ((document as OpenApi.IDocument)["x-samchon-emended"] === true) | ||
document = HttpMigration.application( | ||
document as OpenApi.IDocument<any, Operation>, | ||
); | ||
return LlmComposer.compose( | ||
document as IHttpMigrateApplication<any, Operation>, | ||
{ | ||
keyword: options?.keyword ?? false, | ||
separate: options?.separate ?? null, | ||
}, | ||
); | ||
}; | ||
|
||
export const schema = (props: { | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
}): ILlmSchema | null => LlmComposer.schema(props); | ||
|
||
export interface IExecutionProps { | ||
/** | ||
* Document of the OpenAI function call schemas. | ||
*/ | ||
document: IHttpLlmApplication; | ||
|
||
/** | ||
* Procedure schema to call. | ||
*/ | ||
procedure: IHttpLlmFunction; | ||
|
||
/** | ||
* Connection info to the server. | ||
*/ | ||
connection: IHttpConnection; | ||
|
||
/** | ||
* Arguments for the function call. | ||
*/ | ||
arguments: any[]; | ||
} | ||
export const execute = (props: IExecutionProps): Promise<unknown> => | ||
HttpLlmFunctionFetcher.execute(props); | ||
|
||
export const propagate = (props: IExecutionProps): Promise<IHttpResponse> => | ||
HttpLlmFunctionFetcher.propagate(props); | ||
|
||
export interface IMergeProps { | ||
function: IHttpLlmFunction; | ||
llm: unknown[]; | ||
human: unknown[]; | ||
} | ||
export const merge = (props: IMergeProps): unknown[] => | ||
LlmMerger.parameters(props); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { OpenApi } from "./OpenApi"; | ||
import { MigrateConverter } from "./converters/MigrateConverter"; | ||
import { HttpMigrateRouteFetcher } from "./http/HttpMigrateRouteFetcher"; | ||
import { IHttpConnection } from "./structures/IHttpConnection"; | ||
import { IHttpMigrateApplication } from "./structures/IHttpMigrateApplication"; | ||
import { IHttpMigrateRoute } from "./structures/IHttpMigrateRoute"; | ||
import { IHttpResponse } from "./structures/IHttpResponse"; | ||
|
||
export namespace HttpMigration { | ||
export const application = < | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>, | ||
>( | ||
document: OpenApi.IDocument<Schema, Operation>, | ||
): IHttpMigrateApplication<Schema, Operation> => | ||
MigrateConverter.convert(document); | ||
|
||
export interface IProps { | ||
connection: IHttpConnection; | ||
route: IHttpMigrateRoute; | ||
parameters: | ||
| Array<string | number | boolean | bigint | null> | ||
| Record<string, string | number | boolean | bigint | null>; | ||
query?: object | undefined; | ||
body?: object | undefined; | ||
} | ||
export const request = (props: IProps): Promise<unknown> => | ||
HttpMigrateRouteFetcher.request(props); | ||
export const propagate = (props: IProps): Promise<IHttpResponse> => | ||
HttpMigrateRouteFetcher.propagate(props); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.