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) => {
|
run: async (payload, io, ctx) => {
|
||||||
const models = await io.openai.listModels("list-models");
|
const models = await io.openai.listModels("list-models");
|
||||||
|
|
||||||
await io.openai.retrieveModel("get-model", {
|
if (models.data.length > 0) {
|
||||||
model: models[0].id,
|
await io.openai.retrieveModel("get-model", {
|
||||||
});
|
model: models.data[0].id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await io.openai.backgroundCreateChatCompletion(
|
await io.openai.backgroundCreateChatCompletion(
|
||||||
"background-chat-completion",
|
"background-chat-completion",
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const retrieveModel: AuthenticatedTask<
|
|||||||
|
|
||||||
type ListModelsResponseData = Awaited<
|
type ListModelsResponseData = Awaited<
|
||||||
ReturnType<OpenAIClientType["listModels"]>
|
ReturnType<OpenAIClientType["listModels"]>
|
||||||
>["data"]["data"];
|
>["data"];
|
||||||
|
|
||||||
export const listModels: AuthenticatedTask<
|
export const listModels: AuthenticatedTask<
|
||||||
OpenAIClientType,
|
OpenAIClientType,
|
||||||
@@ -59,7 +59,7 @@ export const listModels: AuthenticatedTask<
|
|||||||
Prettify<ListModelsResponseData>
|
Prettify<ListModelsResponseData>
|
||||||
> = {
|
> = {
|
||||||
run: async (params, client) => {
|
run: async (params, client) => {
|
||||||
return client.listModels().then((res) => res.data.data);
|
return client.listModels().then((res) => res.data);
|
||||||
},
|
},
|
||||||
init: (params) => {
|
init: (params) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user