@saltcorn/large-language-model 0.3.3 → 0.3.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.
Files changed (2) hide show
  1. package/generate.js +9 -2
  2. package/package.json +1 -1
package/generate.js CHANGED
@@ -100,7 +100,7 @@ const getCompletion = async (config, opts) => {
100
100
 
101
101
  const getCompletionOpenAICompatible = async (
102
102
  { chatCompleteEndpoint, bearer, model },
103
- { systemPrompt, prompt, temperature, chat = [], ...rest }
103
+ { systemPrompt, prompt, temperature, debugResult, chat = [], ...rest }
104
104
  ) => {
105
105
  const headers = {
106
106
  "Content-Type": "application/json",
@@ -127,8 +127,15 @@ const getCompletionOpenAICompatible = async (
127
127
  body: JSON.stringify(body),
128
128
  });
129
129
  const results = await rawResponse.json();
130
+ if (debugResult)
131
+ console.log("OpenAI response", JSON.stringify(results, null, 2));
130
132
 
131
- return results?.choices?.[0]?.message?.content;
133
+ return (
134
+ results?.choices?.[0]?.message?.content ||
135
+ (results?.choices?.[0]?.message?.tool_calls
136
+ ? { tool_calls: results?.choices?.[0]?.message?.tool_calls }
137
+ : null)
138
+ );
132
139
  };
133
140
 
134
141
  const getEmbeddingOpenAICompatible = async (config, { prompt, model }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/large-language-model",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Large language models and functionality for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {