OpenAI integration: listModels returns the response.data instead of response.data.data

This commit is contained in:
Matt Aitken
2023-07-04 18:33:27 +01:00
parent f160b34b34
commit 12803536fa
3 changed files with 12 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/openai": patch
---
listModels returns the response.data instead of response.data.data
+5 -3
View File
@@ -22,9 +22,11 @@ new Job(client, {
run: async (payload, io, ctx) => {
const models = await io.openai.listModels("list-models");
await io.openai.retrieveModel("get-model", {
model: models[0].id,
});
if (models.data.length > 0) {
await io.openai.retrieveModel("get-model", {
model: models.data[0].id,
});
}
await io.openai.backgroundCreateChatCompletion(
"background-chat-completion",
+2 -2
View File
@@ -51,7 +51,7 @@ export const retrieveModel: AuthenticatedTask<
type ListModelsResponseData = Awaited<
ReturnType<OpenAIClientType["listModels"]>
>["data"]["data"];
>["data"];
export const listModels: AuthenticatedTask<
OpenAIClientType,
@@ -59,7 +59,7 @@ export const listModels: AuthenticatedTask<
Prettify<ListModelsResponseData>
> = {
run: async (params, client) => {
return client.listModels().then((res) => res.data.data);
return client.listModels().then((res) => res.data);
},
init: (params) => {
return {