From fa74c6aefdd3c129ad0e5000e1b869f3507980f1 Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Thu, 5 Dec 2024 12:38:17 +0000 Subject: [PATCH] Add missing `finish_reason` to OpenAI output types (#766) ## Summary Adds the missing `finish_reason: string` field to output types for OpenAI calls. ## Checklist - [ ] ~Added a [docs PR](https://github.com/inngest/website) that references this PR~ N/A Bug fix - [ ] ~Added unit/integration tests~ N/A - [x] Added changesets if applicable ## Related - Helps inngest/agent-kit#17 --- .changeset/lemon-sloths-wave.md | 5 +++++ packages/inngest/src/components/ai/adapters/openai.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changeset/lemon-sloths-wave.md diff --git a/.changeset/lemon-sloths-wave.md b/.changeset/lemon-sloths-wave.md new file mode 100644 index 000000000..c81f95130 --- /dev/null +++ b/.changeset/lemon-sloths-wave.md @@ -0,0 +1,5 @@ +--- +"inngest": patch +--- + +Add missing `finish_reason` to OpenAI output types diff --git a/packages/inngest/src/components/ai/adapters/openai.ts b/packages/inngest/src/components/ai/adapters/openai.ts index cdb081a35..a20e60e16 100644 --- a/packages/inngest/src/components/ai/adapters/openai.ts +++ b/packages/inngest/src/components/ai/adapters/openai.ts @@ -355,6 +355,16 @@ export interface OpenAiAiAdapter extends AiAdapter { * greater than 1. */ choices: { + /** + * The reason the model stopped generating tokens. This will be `stop` + * if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was + * reached, `content_filter` if content was omitted due to a flag from + * our content filters, `tool_calls` if the model called a tool, or + * `function_call` (deprecated) if the model called a function. + */ + finish_reason: string; + /** * The index of the choice in the list of choices. */