Skip to content

Commit

Permalink
Widens the AiAdapter types to allow for easy overrides (#770)
Browse files Browse the repository at this point in the history
## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

Widens typing for `AiAdapter` types for use with `@inngest/agent-kit`,
to allow for some easier checking of subtypes with `extends`.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~Added a [docs PR](https://github.com/inngest/website) that
references this PR~ N/A Internal
- [ ] ~Added unit/integration tests~ N/A
- [x] Added changesets if applicable

## Related
<!-- A space for any related links, issues, or PRs. -->
<!-- Linear issues are autolinked. -->
<!-- e.g. - INN-123 -->
<!-- GitHub issues/PRs can be linked using shorthand. -->
<!-- e.g. "- inngest/inngest#123" -->
<!-- Feel free to remove this section if there are no applicable related
links.-->
- Testing with inngest/agent-kit#17
  • Loading branch information
jpwilliams authored Dec 6, 2024
1 parent 145a9bd commit 3aab141
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-falcons-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"inngest": patch
---

Widen the `AiAdapter` types to allow for easy overrides
17 changes: 17 additions & 0 deletions packages/inngest/src/components/ai/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export interface AiAdapter {
*/
format: AiAdapter.Format;

/**
* The constructor options for the adapter.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: any;

/**
* The input and output types for this AI I/O format.
*
Expand Down Expand Up @@ -79,6 +85,17 @@ export interface AiAdapter {
* types.
*/
export namespace AiAdapter {
export interface Any extends Omit<AiAdapter, "format"> {
/**
* The I/O format for the adapter.
*
* Allows any value, such that this type can be easily used with any
* adapter.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
format: any;
}

/**
* A helper used to infer the input type of an adapter.
*/
Expand Down
4 changes: 3 additions & 1 deletion packages/inngest/src/components/ai/models/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ export namespace Anthropic {
/**
* An Anthropic model using the Anthropic format for I/O.
*/
export type AiModel = AnthropicAiAdapter & { options: AiModelOptions };
export interface AiModel extends AnthropicAiAdapter {
options: AiModelOptions;
}
}
4 changes: 3 additions & 1 deletion packages/inngest/src/components/ai/models/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ export namespace OpenAi {
/**
* An OpenAI model using the OpenAI format for I/O.
*/
export type AiModel = OpenAiAiAdapter & { options: AiModelOptions };
export interface AiModel extends OpenAiAiAdapter {
options: AiModelOptions;
}
}

0 comments on commit 3aab141

Please sign in to comment.