Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a type that lists the AiAdapter for each format #756

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-cameras-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"inngest": patch
---

Expose a type that lists the `AiAdapter` for each format
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
Loading