@digipair/skill-openai 0.1.7 → 0.1.10

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/index.cjs2.js CHANGED
@@ -61194,22 +61194,6 @@ function jsonSchemaToZod(schema) {
61194
61194
  }
61195
61195
  }
61196
61196
  let OpenAIService = class OpenAIService {
61197
- extractJsonFromOutput(message) {
61198
- const text = message.content;
61199
- // Define the regular expression pattern to match JSON blocks
61200
- const pattern = RegExp("```json\\s*((.|\\n)*?)\\s*```", "gs");
61201
- // Find all non-overlapping matches of the pattern in the string
61202
- const matches = pattern.exec(text);
61203
- if (matches && matches[1]) {
61204
- try {
61205
- return JSON.parse(matches[1].trim());
61206
- } catch (error) {
61207
- throw new Error(`Failed to parse: ${matches[1]}`);
61208
- }
61209
- } else {
61210
- throw new Error(`No JSON found in: ${message}`);
61211
- }
61212
- }
61213
61197
  async basic(params, _pins, _context) {
61214
61198
  const { modelName = 'gpt-3.5-turbo', temperature = 0, baseURL = OPENAI_SERVER, apiKey = OPENAI_API_KEY, prompt, schema } = params;
61215
61199
  const model = new OpenAI({
@@ -61229,7 +61213,7 @@ let OpenAIService = class OpenAIService {
61229
61213
  } else {
61230
61214
  const parser = new StructuredOutputParser(jsonSchemaToZod(schema));
61231
61215
  chain = RunnableSequence.from([
61232
- PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}`, {
61216
+ PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}\n\nJSON:`, {
61233
61217
  partialVariables: {
61234
61218
  format_instructions: parser.getFormatInstructions()
61235
61219
  }
package/index.esm2.js CHANGED
@@ -61192,22 +61192,6 @@ function jsonSchemaToZod(schema) {
61192
61192
  }
61193
61193
  }
61194
61194
  let OpenAIService = class OpenAIService {
61195
- extractJsonFromOutput(message) {
61196
- const text = message.content;
61197
- // Define the regular expression pattern to match JSON blocks
61198
- const pattern = RegExp("```json\\s*((.|\\n)*?)\\s*```", "gs");
61199
- // Find all non-overlapping matches of the pattern in the string
61200
- const matches = pattern.exec(text);
61201
- if (matches && matches[1]) {
61202
- try {
61203
- return JSON.parse(matches[1].trim());
61204
- } catch (error) {
61205
- throw new Error(`Failed to parse: ${matches[1]}`);
61206
- }
61207
- } else {
61208
- throw new Error(`No JSON found in: ${message}`);
61209
- }
61210
- }
61211
61195
  async basic(params, _pins, _context) {
61212
61196
  const { modelName = 'gpt-3.5-turbo', temperature = 0, baseURL = OPENAI_SERVER, apiKey = OPENAI_API_KEY, prompt, schema } = params;
61213
61197
  const model = new OpenAI({
@@ -61227,7 +61211,7 @@ let OpenAIService = class OpenAIService {
61227
61211
  } else {
61228
61212
  const parser = new StructuredOutputParser(jsonSchemaToZod(schema));
61229
61213
  chain = RunnableSequence.from([
61230
- PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}`, {
61214
+ PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}\n\nJSON:`, {
61231
61215
  partialVariables: {
61232
61216
  format_instructions: parser.getFormatInstructions()
61233
61217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-openai",
3
- "version": "0.1.7",
3
+ "version": "0.1.10",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
File without changes