mcp-meilisearch 1.3.5 → 1.3.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAiBD,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IACjD,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,MAAM,CAAyC;IACvD,OAAO,CAAC,cAAc,CAIb;IAET;;;OAGG;IACH,OAAO;IAEP;;;OAGG;WACW,WAAW,IAAI,SAAS;IAOtC;;;;;;OAMG;IACH,UAAU,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,qBAAgC,EAC1C,KAAK,CAAC,EAAE,MAAM,GACb,IAAI;IA4BP;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIxC,iBAAiB,IAAI,OAAO;IAI5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAax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1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;;OAKG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;YAwBnB,kBAAkB;YAiClB,uBAAuB;CAiCtC"}
@@ -1,7 +1,7 @@
1
1
  import { OpenAI } from "openai";
2
2
  import systemPrompt from "../prompts/system.js";
3
- import { InferenceClient } from "@huggingface/inference";
4
3
  import { markdownToJson } from "./response-handler.js";
4
+ import { InferenceClient } from "@huggingface/inference";
5
5
  /**
6
6
  * AI Inference Service
7
7
  *
@@ -117,39 +117,30 @@ export class AIService {
117
117
  async processQuery(query, specificTools) {
118
118
  if (!this.ensureInitialized())
119
119
  return null;
120
- try {
121
- const mentionedTools = this.extractToolNames(query);
122
- const toolsToUse = specificTools || (mentionedTools.length ? mentionedTools : undefined);
123
- const tools = this.getToolDefinitions(toolsToUse);
124
- const systemPrompt = this.systemPrompt.replace("MCP_TOOLS", JSON.stringify(tools, null, 2));
125
- const messages = [
126
- { role: "system", content: systemPrompt },
127
- { role: "user", content: query },
128
- ];
129
- if (this.provider === "huggingface") {
130
- return this.processHuggingFaceQuery(tools, messages);
131
- }
132
- return this.processOpenAIQuery(tools, messages);
133
- }
134
- catch (error) {
135
- if (error instanceof Error) {
136
- throw new Error(error.message);
137
- }
138
- throw error;
120
+ const mentionedTools = this.extractToolNames(query);
121
+ const toolsToUse = specificTools || (mentionedTools.length ? mentionedTools : undefined);
122
+ const tools = this.getToolDefinitions(toolsToUse);
123
+ const systemPrompt = this.systemPrompt.replace("MCP_TOOLS", JSON.stringify(tools, null, 2));
124
+ const messages = [
125
+ { role: "system", content: systemPrompt },
126
+ { role: "user", content: query },
127
+ ];
128
+ if (this.provider === "huggingface") {
129
+ return this.processHuggingFaceQuery(tools, messages);
139
130
  }
131
+ return this.processOpenAIQuery(tools, messages);
140
132
  }
141
133
  async processOpenAIQuery(tools, messages) {
142
134
  const client = this.client;
143
- const response = await client.chat.completions
144
- .create({
135
+ const response = await client.chat.completions.create({
145
136
  tools,
146
137
  messages,
147
138
  model: this.model,
148
- })
149
- .catch((error) => {
150
- console.error("Error in OpenAI API call:", error);
151
- return null;
152
139
  });
140
+ if ("error" in response) {
141
+ console.error("Error in OpenAI API call:", response);
142
+ return null;
143
+ }
153
144
  if (!response?.choices.length)
154
145
  return null;
155
146
  const message = response.choices[0].message;
@@ -166,17 +157,16 @@ export class AIService {
166
157
  }
167
158
  async processHuggingFaceQuery(tools, messages) {
168
159
  const client = this.client;
169
- const response = await client
170
- .chatCompletion({
160
+ const response = await client.chatCompletion({
171
161
  tools,
172
162
  messages,
173
163
  max_tokens: 512,
174
164
  model: this.model,
175
- })
176
- .catch((error) => {
177
- console.error("Error in HugginFace API call:", error);
178
- return null;
179
165
  });
166
+ if ("error" in response) {
167
+ console.error("Error in HugginFace call:", response);
168
+ return null;
169
+ }
180
170
  if (!response?.choices.length)
181
171
  return null;
182
172
  const message = response.choices[0].message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-meilisearch",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Model Context Protocol (MCP) implementation for Meilisearch",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",