@saltcorn/large-language-model 0.9.8 → 0.9.9

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.
Files changed (2) hide show
  1. package/generate.js +16 -1
  2. package/package.json +1 -1
package/generate.js CHANGED
@@ -211,6 +211,21 @@ const getCompletionAISDK = async (
211
211
  model_obj = openai(use_model_name);
212
212
  break;
213
213
  }
214
+ const modifyChat = (chat) => {
215
+ const f = (c) => {
216
+ if (c.type === "image_url")
217
+ return {
218
+ type: "image",
219
+ image: c.image_url?.url || c.image?.url || c.image_url || c.image,
220
+ };
221
+ else return c;
222
+ };
223
+ return {
224
+ ...chat,
225
+ ...(Array.isArray(chat.content) ? { content: chat.content.map(f) } : {}),
226
+ };
227
+ };
228
+ const newChat = chat.map(modifyChat);
214
229
 
215
230
  const body = {
216
231
  ...rest,
@@ -220,7 +235,7 @@ const getCompletionAISDK = async (
220
235
  role: "system",
221
236
  content: systemPrompt || "You are a helpful assistant.",
222
237
  },
223
- ...chat,
238
+ ...newChat,
224
239
  ...(prompt ? [{ role: "user", content: prompt }] : []),
225
240
  ],
226
241
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {