@digipair/skill-ollama 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
@@ -45757,22 +45757,6 @@ function jsonSchemaToZod(schema) {
45757
45757
  }
45758
45758
  }
45759
45759
  let OllamaService = class OllamaService {
45760
- extractJsonFromOutput(message) {
45761
- const text = message.content;
45762
- // Define the regular expression pattern to match JSON blocks
45763
- const pattern = RegExp("```json\\s*((.|\\n)*?)\\s*```", "gs");
45764
- // Find all non-overlapping matches of the pattern in the string
45765
- const matches = pattern.exec(text);
45766
- if (matches && matches[1]) {
45767
- try {
45768
- return JSON.parse(matches[1].trim());
45769
- } catch (error) {
45770
- throw new Error(`Failed to parse: ${matches[1]}`);
45771
- }
45772
- } else {
45773
- throw new Error(`No JSON found in: ${message}`);
45774
- }
45775
- }
45776
45760
  async basic(params, _pins, _context) {
45777
45761
  const { modelName = 'mistral', temperature = 0, baseUrl = OLLAMA_SERVER, prompt, schema } = params;
45778
45762
  const model = new Ollama({
@@ -45789,7 +45773,7 @@ let OllamaService = class OllamaService {
45789
45773
  } else {
45790
45774
  const parser = new StructuredOutputParser(jsonSchemaToZod(schema));
45791
45775
  chain = RunnableSequence.from([
45792
- PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}`, {
45776
+ PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}\n\nJSON:`, {
45793
45777
  partialVariables: {
45794
45778
  format_instructions: parser.getFormatInstructions()
45795
45779
  }
@@ -45821,7 +45805,7 @@ let OllamaService = class OllamaService {
45821
45805
  } else {
45822
45806
  const parser = new StructuredOutputParser(jsonSchemaToZod(schema));
45823
45807
  chain = RunnableSequence.from([
45824
- PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}`, {
45808
+ PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}\n\nJSON:`, {
45825
45809
  partialVariables: {
45826
45810
  format_instructions: parser.getFormatInstructions()
45827
45811
  }
package/index.esm2.js CHANGED
@@ -45755,22 +45755,6 @@ function jsonSchemaToZod(schema) {
45755
45755
  }
45756
45756
  }
45757
45757
  let OllamaService = class OllamaService {
45758
- extractJsonFromOutput(message) {
45759
- const text = message.content;
45760
- // Define the regular expression pattern to match JSON blocks
45761
- const pattern = RegExp("```json\\s*((.|\\n)*?)\\s*```", "gs");
45762
- // Find all non-overlapping matches of the pattern in the string
45763
- const matches = pattern.exec(text);
45764
- if (matches && matches[1]) {
45765
- try {
45766
- return JSON.parse(matches[1].trim());
45767
- } catch (error) {
45768
- throw new Error(`Failed to parse: ${matches[1]}`);
45769
- }
45770
- } else {
45771
- throw new Error(`No JSON found in: ${message}`);
45772
- }
45773
- }
45774
45758
  async basic(params, _pins, _context) {
45775
45759
  const { modelName = 'mistral', temperature = 0, baseUrl = OLLAMA_SERVER, prompt, schema } = params;
45776
45760
  const model = new Ollama({
@@ -45787,7 +45771,7 @@ let OllamaService = class OllamaService {
45787
45771
  } else {
45788
45772
  const parser = new StructuredOutputParser(jsonSchemaToZod(schema));
45789
45773
  chain = RunnableSequence.from([
45790
- PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}`, {
45774
+ PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}\n\nJSON:`, {
45791
45775
  partialVariables: {
45792
45776
  format_instructions: parser.getFormatInstructions()
45793
45777
  }
@@ -45819,7 +45803,7 @@ let OllamaService = class OllamaService {
45819
45803
  } else {
45820
45804
  const parser = new StructuredOutputParser(jsonSchemaToZod(schema));
45821
45805
  chain = RunnableSequence.from([
45822
- PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}`, {
45806
+ PromptTemplate.fromTemplate(`Answer the users question as best as possible.\n{format_instructions}\n${prompt != null ? prompt : '{prompt}'}\n\nJSON:`, {
45823
45807
  partialVariables: {
45824
45808
  format_instructions: parser.getFormatInstructions()
45825
45809
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-ollama",
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