OpenAI integration: listModels returns the response.data instead of response.data.data
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/openai": patch
|
||||
---
|
||||
|
||||
listModels returns the response.data instead of response.data.data
|
||||
@@ -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",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user