@pipedream/openai 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@ export default {
7
7
  ...common,
8
8
  key: "openai-analyze-image-content",
9
9
  name: "Analyze Image Content",
10
- description: "Send a message or question about an image and receive a response. [See the documentation](https://platform.openai.com/docs/api-reference/runs/createThreadAndRun)",
11
- version: "1.0.3",
10
+ description: "Send a message or question about an image and receive a response. [See the documentation](https://developers.openai.com/api/reference/resources/responses/methods/create)",
11
+ version: "1.1.0",
12
12
  annotations: {
13
13
  destructiveHint: false,
14
14
  openWorldHint: true,
@@ -46,44 +46,24 @@ export default {
46
46
  },
47
47
  },
48
48
  async run({ $ }) {
49
- const { id: assistantId } = await this.openai.createAssistant({
50
- $,
51
- data: {
52
- model: "gpt-4o", // replaced from "gpt-4-vision-preview" - see https://platform.openai.com/docs/deprecations
53
- },
54
- });
55
-
56
49
  const data = {
57
- assistant_id: assistantId,
58
- thread: {
59
- messages: [
60
- {
61
- role: "user",
62
- content: [
63
- {
64
- type: "text",
65
- text: this.message,
66
- },
67
- ],
68
- },
69
- ],
70
- },
71
- model: this.model,
72
- };
73
- if (this.imageUrl) {
74
- data.thread.messages[0].content.push({
75
- type: "image_url",
76
- image_url: {
77
- url: this.imageUrl,
50
+ model: "gpt-4o",
51
+ input: [
52
+ {
53
+ role: "user",
54
+ content: [
55
+ {
56
+ type: "input_text",
57
+ text: this.message,
58
+ },
59
+ ],
78
60
  },
79
- });
80
- }
61
+ ],
62
+ };
81
63
  if (this.imageFileId) {
82
- data.thread.messages[0].content.push({
83
- type: "image_file",
84
- image_file: {
85
- file_id: this.imageFileId,
86
- },
64
+ data.input[0].content.push({
65
+ type: "input_image",
66
+ file_id: this.imageFileId,
87
67
  });
88
68
  }
89
69
  if (this.filePath) {
@@ -104,37 +84,31 @@ export default {
104
84
  headers: fileData.getHeaders(),
105
85
  });
106
86
 
107
- data.thread.messages[0].content.push({
108
- type: "image_file",
109
- image_file: {
110
- file_id: id,
111
- },
87
+ data.input[0].content.push({
88
+ type: "input_image",
89
+ file_id: id,
112
90
  });
113
91
  }
114
92
 
115
- let run;
116
- run = await this.openai.createThreadAndRun({
93
+ const run = await this.openai.responses({
117
94
  $,
118
95
  data,
119
96
  });
120
- const runId = run.id;
121
- const threadId = run.thread_id;
122
-
123
- run = await this.pollRunUntilCompleted(run, threadId, runId, $);
124
97
 
125
- // get response;
126
- const { data: messages } = await this.openai.listMessages({
127
- $,
128
- threadId,
129
- params: {
130
- order: "desc",
131
- },
132
- });
133
- const response = messages[0].content[0].text.value;
134
- return {
135
- response,
136
- messages,
98
+ const returnData = {
137
99
  run,
100
+ messages: data.input,
138
101
  };
102
+
103
+ if (run.output.length) {
104
+ returnData.response = run.output[0].content[0].text;
105
+ returnData.messages.push({
106
+ role: run.output[0].role,
107
+ content: run.output[0].content,
108
+ });
109
+ }
110
+
111
+ $.export("$summary", "Successfully analyzed image content.");
112
+ return returnData;
139
113
  },
140
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/openai",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Pipedream OpenAI Components",
5
5
  "main": "openai.app.mjs",
6
6
  "keywords": [
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@pipedream/platform": "^3.1.0",
17
+ "@pipedream/platform": "^3.1.1",
18
18
  "bottleneck": "^2.19.5",
19
19
  "file-type": "^21.0.0",
20
20
  "form-data": "^4.0.4",