@openfn/language-chatgpt 1.0.0 → 1.0.2

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.
package/ast.json CHANGED
@@ -4,20 +4,25 @@
4
4
  "name": "prompt",
5
5
  "params": [
6
6
  "message",
7
- "model"
7
+ "opts"
8
8
  ],
9
9
  "docs": {
10
10
  "description": "Prompt the GPT chat interface to respond",
11
11
  "tags": [
12
12
  {
13
13
  "title": "example",
14
- "description": "prompt('Write a haiku about surfing.' model='gpt-4o');"
14
+ "description": "prompt('Write a haiku about surfing.');"
15
15
  },
16
16
  {
17
17
  "title": "public",
18
18
  "description": null,
19
19
  "type": null
20
20
  },
21
+ {
22
+ "title": "function",
23
+ "description": null,
24
+ "name": null
25
+ },
21
26
  {
22
27
  "title": "param",
23
28
  "description": "The prompt",
@@ -29,12 +34,12 @@
29
34
  },
30
35
  {
31
36
  "title": "param",
32
- "description": "The model (defaults to 'gpt-4o)",
37
+ "description": "Model, Reasoning Effort, Response Form and other parameters (https://platform.openai.com/docs/api-reference/chat/create)",
33
38
  "type": {
34
39
  "type": "NameExpression",
35
- "name": "string"
40
+ "name": "PromptOptions"
36
41
  },
37
- "name": "model"
42
+ "name": "options"
38
43
  },
39
44
  {
40
45
  "title": "returns",
@@ -46,7 +51,7 @@
46
51
  }
47
52
  ]
48
53
  },
49
- "valid": true
54
+ "valid": false
50
55
  }
51
56
  ],
52
57
  "exports": [],
package/dist/index.cjs CHANGED
@@ -64,6 +64,7 @@ __export(Adaptor_exports, {
64
64
  sourceValue: () => import_language_common2.sourceValue
65
65
  });
66
66
  var import_language_common = require("@openfn/language-common");
67
+ var import_util = require("@openfn/language-common/util");
67
68
  var import_openai = __toESM(require("openai"), 1);
68
69
  var import_language_common2 = require("@openfn/language-common");
69
70
  var client;
@@ -92,12 +93,20 @@ function execute(...operations) {
92
93
  });
93
94
  };
94
95
  }
95
- function prompt(message, model = "gpt-4o") {
96
+ function prompt(message, opts) {
96
97
  return async (state) => {
97
- const msg = await client.chat.completions.create({
98
- model,
99
- messages: [{ role: "user", content: message }]
100
- });
98
+ const [resolvedMessage, resolvedOpts] = (0, import_util.expandReferences)(
99
+ state,
100
+ message,
101
+ opts
102
+ );
103
+ const payload = {
104
+ model: "o3-mini-2025-01-31",
105
+ reasoning_effort: "low",
106
+ messages: [{ role: "user", content: resolvedMessage }],
107
+ ...resolvedOpts
108
+ };
109
+ const msg = await client.chat.completions.create(payload);
101
110
  return (0, import_language_common.composeNextState)(state, msg);
102
111
  };
103
112
  }
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ import {
27
27
  composeNextState,
28
28
  execute as commonExecute
29
29
  } from "@openfn/language-common";
30
+ import { expandReferences } from "@openfn/language-common/util";
30
31
  import OpenAI from "openai";
31
32
  import {
32
33
  dataPath,
@@ -67,12 +68,20 @@ function execute(...operations) {
67
68
  });
68
69
  };
69
70
  }
70
- function prompt(message, model = "gpt-4o") {
71
+ function prompt(message, opts) {
71
72
  return async (state) => {
72
- const msg = await client.chat.completions.create({
73
- model,
74
- messages: [{ role: "user", content: message }]
75
- });
73
+ const [resolvedMessage, resolvedOpts] = expandReferences(
74
+ state,
75
+ message,
76
+ opts
77
+ );
78
+ const payload = {
79
+ model: "o3-mini-2025-01-31",
80
+ reasoning_effort: "low",
81
+ messages: [{ role: "user", content: resolvedMessage }],
82
+ ...resolvedOpts
83
+ };
84
+ const msg = await client.chat.completions.create(payload);
76
85
  return composeNextState(state, msg);
77
86
  };
78
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-chatgpt",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "OpenFn chatgpt adaptor",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "openai": "^4.86.2",
24
- "@openfn/language-common": "2.3.0"
24
+ "@openfn/language-common": "2.3.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "assertion-error": "2.0.0",
@@ -16,11 +16,16 @@ export function execute(...operations: any[]): operation;
16
16
  /**
17
17
  * Prompt the GPT chat interface to respond
18
18
  * @example
19
- * prompt('Write a haiku about surfing.' model='gpt-4o');
19
+ * prompt('Write a haiku about surfing.');
20
20
  * @public
21
+ * @function
21
22
  * @param {string} message - The prompt
22
- * @param {string} model - The model (defaults to 'gpt-4o)
23
+ * @param {PromptOptions} options - Model, Reasoning Effort, Response Form and other parameters (https://platform.openai.com/docs/api-reference/chat/create)
23
24
  * @returns {operation}
24
25
  */
25
- export function prompt(message: string, model?: string): operation;
26
+ export function prompt(message: string, opts: any): operation;
27
+ /**
28
+ * Options provided to Chat Completions Create (https://platform.openai.com/docs/api-reference/chat/create)
29
+ */
30
+ export type PromptOptions = any;
26
31
  export { dataPath, dataValue, dateFns, cursor, each, field, fields, fn, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";