MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / createAndRun

Method createAndRun

integrations/openai/src/threads.ts:24–61  ·  view source on GitHub ↗

* Create a thread and run it in one task.

(
    key: IntegrationTaskKey,
    params: Prettify<OpenAI.Beta.ThreadCreateAndRunParams>,
    options: OpenAIRequestOptions = {}
  )

Source from the content-addressed store, hash-verified

22 * Create a thread and run it in one task.
23 */
24 async createAndRun(
25 key: IntegrationTaskKey,
26 params: Prettify<OpenAI.Beta.ThreadCreateAndRunParams>,
27 options: OpenAIRequestOptions = {}
28 ): Promise<OpenAI.Beta.Threads.Run> {
29 return this.runTask(
30 key,
31 async (client, task) => {
32 const { data, response } = await client.beta.threads
33 .createAndRun(params, {
34 idempotencyKey: task.idempotencyKey,
35 ...options,
36 })
37 .withResponse();
38
39 const outputProperties = [
40 ...(createTaskOutputProperties(undefined, response.headers) ?? []),
41 {
42 label: "threadId",
43 text: data.thread_id,
44 },
45 {
46 label: "runId",
47 text: data.id,
48 },
49 ];
50
51 task.outputProperties = outputProperties;
52
53 return data;
54 },
55 {
56 name: "Create Thread and Run",
57 params,
58 },
59 handleOpenAIError
60 );
61 }
62
63 /**
64 * Create a thread and runs it in one task, and only returns when the run is completed by polling in the background.

Callers 1

Calls 3

withResponseMethod · 0.80
runTaskMethod · 0.45

Tested by

no test coverage detected