From b3d70b949582ed13d3cc80b5524354e1cfdf28ae Mon Sep 17 00:00:00 2001 From: "hash-worker[bot]" <180894564+hash-worker[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:52:01 +0000 Subject: [PATCH] Update npm package `openai` to v4.76.2 (#5601) Co-authored-by: hash-worker[bot] <180894564+hash-worker[bot]@users.noreply.github.com> Co-authored-by: Ciaran Morinan Co-authored-by: Ciaran Morinan <37743469+CiaranMn@users.noreply.github.com> --- apps/hash-ai-worker-ts/package.json | 2 +- .../flow-activities/answer-question-action.ts | 15 ++++---- .../src/activities/shared/embeddings.ts | 3 +- apps/hash-api/package.json | 2 +- yarn.lock | 34 ++++--------------- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/apps/hash-ai-worker-ts/package.json b/apps/hash-ai-worker-ts/package.json index 16aeab58da4..b9e31c727c8 100644 --- a/apps/hash-ai-worker-ts/package.json +++ b/apps/hash-ai-worker-ts/package.json @@ -81,7 +81,7 @@ "md5": "2.3.0", "mime-types": "2.1.35", "officeparser": "4.2.0", - "openai": "4.68.4", + "openai": "4.76.2", "openai-chat-tokens": "0.2.8", "papaparse": "5.4.1", "pdf2json": "3.1.4", diff --git a/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts b/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts index 588f6191828..e0c9286d872 100644 --- a/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts +++ b/apps/hash-ai-worker-ts/src/activities/flow-activities/answer-question-action.ts @@ -17,15 +17,9 @@ import { StatusCode } from "@local/status"; import { Context } from "@temporalio/activity"; import dedent from "dedent"; import { CodeInterpreter, Sandbox } from "e2b"; -import { OpenAI } from "openai"; +import type { OpenAI } from "openai"; import { logger } from "../shared/activity-logger.js"; -import type { PermittedOpenAiModel } from "../shared/openai-client.js"; -import { stringify } from "../shared/stringify.js"; -import type { FlowActionActivity } from "./types.js"; -import ChatCompletionUserMessageParam = OpenAI.ChatCompletionUserMessageParam; -import ChatCompletionToolMessageParam = OpenAI.ChatCompletionToolMessageParam; - import { getFlowContext } from "../shared/get-flow-context.js"; import { getLlmResponse } from "../shared/get-llm-response.js"; import { @@ -37,6 +31,9 @@ import type { LlmToolDefinition } from "../shared/get-llm-response/types.js"; import { graphApiClient } from "../shared/graph-api-client.js"; import { mapActionInputEntitiesToEntities } from "../shared/map-action-input-entities-to-entities.js"; import { openAiSeed } from "../shared/open-ai-seed.js"; +import type { PermittedOpenAiModel } from "../shared/openai-client.js"; +import { stringify } from "../shared/stringify.js"; +import type { FlowActionActivity } from "./types.js"; const answerTools: LlmToolDefinition[] = [ { @@ -202,7 +199,7 @@ const callModel = async ( const toolCalls = getToolCallsFromLlmAssistantMessage({ message }); - const responseMessages: ChatCompletionToolMessageParam[] = []; + const responseMessages: OpenAI.ChatCompletionToolMessageParam[] = []; /** * Defining these outside the loop so that in cases where the maximum iteration is reached, @@ -384,7 +381,7 @@ const callModel = async ( ); } - const responseMessage: ChatCompletionUserMessageParam = { + const responseMessage: OpenAI.ChatCompletionUserMessageParam = { role: "user", content: "You didn't make any valid tool calls as part of your response. Please review the tools available to you and use the appropriate one.", diff --git a/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts b/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts index 12acea4ea34..cd8bba3ba41 100644 --- a/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts +++ b/apps/hash-ai-worker-ts/src/activities/shared/embeddings.ts @@ -9,7 +9,8 @@ import type { } from "@local/hash-graph-types/ontology"; import { extractBaseUrl } from "@local/hash-subgraph/type-system-patch"; import OpenAI from "openai"; -import Usage = OpenAI.CreateEmbeddingResponse.Usage; + +type Usage = OpenAI.CreateEmbeddingResponse.Usage; const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, diff --git a/apps/hash-api/package.json b/apps/hash-api/package.json index 3c6175c2328..acf4506a811 100644 --- a/apps/hash-api/package.json +++ b/apps/hash-api/package.json @@ -99,7 +99,7 @@ "nanoid": "3.3.8", "nodemailer": "6.9.16", "oembed-providers": "1.0.20241022", - "openai": "4.68.4", + "openai": "4.76.2", "ts-json-schema-generator": "1.5.1", "tsx": "4.19.2", "typescript": "5.6.3", diff --git a/yarn.lock b/yarn.lock index 1d2e296564e..664faf217b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -327,7 +327,7 @@ __metadata: md5: "npm:2.3.0" mime-types: "npm:2.1.35" officeparser: "npm:4.2.0" - openai: "npm:4.68.4" + openai: "npm:4.76.2" openai-chat-tokens: "npm:0.2.8" papaparse: "npm:5.4.1" pdf2json: "npm:3.1.4" @@ -444,7 +444,7 @@ __metadata: nanoid: "npm:3.3.8" nodemailer: "npm:6.9.16" oembed-providers: "npm:1.0.20241022" - openai: "npm:4.68.4" + openai: "npm:4.76.2" prettier: "npm:3.4.2" rimraf: "npm:6.0.1" ts-json-schema-generator: "npm:1.5.1" @@ -37544,9 +37544,9 @@ __metadata: languageName: node linkType: hard -"openai@npm:4.68.4": - version: 4.68.4 - resolution: "openai@npm:4.68.4" +"openai@npm:4.76.2, openai@npm:^4.38.0": + version: 4.76.2 + resolution: "openai@npm:4.76.2" dependencies: "@types/node": "npm:^18.11.18" "@types/node-fetch": "npm:^2.6.4" @@ -37562,29 +37562,7 @@ __metadata: optional: true bin: openai: bin/cli - checksum: 10c0/4f81795d0847ad145815299fc4f6448f084f9db43ede651776ca636d4907ff9a07de9379b9feea5e54a2d96e95ee9bcc74c3284e13376bf80684be74e0041479 - languageName: node - linkType: hard - -"openai@npm:^4.38.0": - version: 4.73.1 - resolution: "openai@npm:4.73.1" - dependencies: - "@types/node": "npm:^18.11.18" - "@types/node-fetch": "npm:^2.6.4" - abort-controller: "npm:^3.0.0" - agentkeepalive: "npm:^4.2.1" - form-data-encoder: "npm:1.7.2" - formdata-node: "npm:^4.3.2" - node-fetch: "npm:^2.6.7" - peerDependencies: - zod: ^3.23.8 - peerDependenciesMeta: - zod: - optional: true - bin: - openai: bin/cli - checksum: 10c0/556b5ba76846fb6d0bacff1b708ec009034cf92f107d84f1d7962625a0d74bf63e7cdfa48b10faf279d6a2c1d3aaf7c68a23b88aa61539a6ba6a9ef8dda7fd35 + checksum: 10c0/d78af0c2dd64ad24a2ce92deb92656b742b8120012e554fd562095f237ce06d84764217e040b437f955c6f26b7675f9321862a8937c8537f28ed6ead4b674559 languageName: node linkType: hard