@saltcorn/large-language-model 1.0.4 → 1.0.5

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/generate.js CHANGED
@@ -620,13 +620,17 @@ const getCompletionOpenAICompatible = async (
620
620
  }
621
621
  if (responses_api) {
622
622
  delete body.tool_choice;
623
- for (const tool of body.tools || []) {
624
- if (tool.type !== "function" || !tool.function) continue;
625
- tool.name = tool.function.name;
626
- tool.description = tool.function.description;
627
- tool.parameters = tool.function.parameters;
628
- if (tool.function.required) tool.required = tool.function.required;
629
- delete tool.function;
623
+ if (body.tools) {
624
+ const newtools = JSON.parse(JSON.stringify(body.tools))
625
+ for (const tool of newtools) {
626
+ if (tool.type !== "function" || !tool.function) continue;
627
+ tool.name = tool.function.name;
628
+ tool.description = tool.function.description;
629
+ tool.parameters = tool.function.parameters;
630
+ if (tool.function.required) tool.required = tool.function.required;
631
+ delete tool.function;
632
+ }
633
+ body.tools = newtools
630
634
  }
631
635
  if (body.response_format?.type === "json_schema" && !body.text) {
632
636
  body.text = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -21,7 +21,7 @@
21
21
  "jest": "^29.7.0"
22
22
  },
23
23
  "scripts": {
24
- "test": "jest tests --runInBand"
24
+ "test": "jest tests --runInBand --verbose"
25
25
  },
26
26
  "author": "Tom Nielsen",
27
27
  "license": "MIT",
package/tests/llm.test.js CHANGED
@@ -97,7 +97,7 @@ for (const nameconfig of require("./configs")) {
97
97
  });
98
98
  it("uses tools", async () => {
99
99
  const answer = await getState().functions.llm_generate.run(
100
- "Generate a list of EU capitals in a structured format using the provided tool",
100
+ "Generate a list of all the EU capitals in a structured format using the provided tool",
101
101
  cities_tool,
102
102
  );
103
103
  expect(typeof answer).toBe("object");
@@ -131,7 +131,7 @@ for (const nameconfig of require("./configs")) {
131
131
  it("tool use sequence", async () => {
132
132
  const chat = [];
133
133
  const answer = await getState().functions.llm_generate.run(
134
- "Generate a list of EU capitals in a structured format using the provided tool",
134
+ "Generate a list of all the EU capitals in a structured format using the provided tool",
135
135
  {
136
136
  chat,
137
137
  appendToChat: true,
@@ -166,7 +166,7 @@ for (const nameconfig of require("./configs")) {
166
166
  });
167
167
  it("uses response_format", async () => {
168
168
  const answer = await getState().functions.llm_generate.run(
169
- "Generate a list of EU capitals in JSON format",
169
+ "Generate a list of all the EU capitals in JSON format",
170
170
  {
171
171
  response_format: {
172
172
  type: "json_schema",
@@ -178,7 +178,6 @@ for (const nameconfig of require("./configs")) {
178
178
  },
179
179
  );
180
180
  expect(typeof answer).toBe("string");
181
- console.log("answer", answer);
182
181
 
183
182
  const json_answer = JSON.parse(answer);
184
183