Skip to content

Commit

Permalink
Expose a type that lists the AiAdapter for each format
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwilliams committed Nov 22, 2024
1 parent 5b33d29 commit 3466918
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/inngest/src/components/ai/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { type OpenAiAiAdapter } from "./adapters/openai.js";

/**
* A symbol used internally to define the types for a model whilst keeping
* generics clean. Must not be exported outside of this module.
Expand Down Expand Up @@ -60,7 +62,7 @@ export interface AiAdapter {
/**
* The model to use for the inference.
*/
model: this,
model: AiAdapter,

/**
* The input to pass to the model.
Expand Down Expand Up @@ -100,3 +102,15 @@ export namespace AiAdapter {
TOutput extends AiAdapter,
> = (...args: TInput) => TOutput;
}

/**
* A cheeky hack to ensure we account for all AI adapters.
*/
const adapters = {
"openai-chat": null as unknown as OpenAiAiAdapter,
} satisfies Record<AiAdapter.Format, AiAdapter>;

/**
* All AI adapters available for use.
*/
export type AiAdapters = typeof adapters;
2 changes: 1 addition & 1 deletion packages/inngest/src/components/ai/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { AiAdapter } from "./adapter.js";
export type { AiAdapter, AiAdapters } from "./adapter.js";

// Adapters
export * from "./adapters/openai.js";
Expand Down

0 comments on commit 3466918

Please sign in to comment.