react-mcp-chatbot 0.0.5 → 0.0.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.
package/README.md CHANGED
@@ -72,7 +72,7 @@
72
72
  <li>🌗 Dark & Light themes</li>
73
73
  <li>📐 Highly customizable</li>
74
74
  <li>📝 Markdown responses (tables, lists, code)</li>
75
- <li>⚡ Ollama / Groq / OpenAI / Gemini</li>
75
+ <li>⚡ Ollama / Groq / OpenAI / Gemini / Deepseek</li>
76
76
  <li>🛠 Optional & validated tool parameters</li>
77
77
  </ul>
78
78
 
package/dist/index.d.ts CHANGED
@@ -46,7 +46,12 @@ type GeminiAgentProps = BaseAgentProps & BaseUIProps & {
46
46
  apiKey: string;
47
47
  providerURL?: never;
48
48
  };
49
- type MCPAgentProps = OllamaAgentProps | GroqAgentProps | OpenaiAgentProps | GeminiAgentProps;
49
+ type DeepSeekAgentProps = BaseAgentProps & BaseUIProps & {
50
+ provider: "deepseek";
51
+ apiKey: string;
52
+ providerURL?: never;
53
+ };
54
+ type MCPAgentProps = OllamaAgentProps | GroqAgentProps | OpenaiAgentProps | GeminiAgentProps | DeepSeekAgentProps;
50
55
 
51
56
  declare function MCPAgent(props: MCPAgentProps): react_jsx_runtime.JSX.Element;
52
57
 
package/dist/index.js CHANGED
@@ -477,6 +477,96 @@ Context rules:
477
477
  }
478
478
  };
479
479
 
480
+ // src/agents/deepseekAgent.ts
481
+ var DeepSeekAgent = class extends Agent {
482
+ apiKey;
483
+ constructor(apiKey, model = "deepseek-chat", providerURL = "https://api.deepseek.com/v1", tools = []) {
484
+ super(model, providerURL, tools);
485
+ this.apiKey = apiKey;
486
+ }
487
+ async decideTool(message) {
488
+ if (this.tools.length === 0) return { tool: null };
489
+ const res = await fetch(`${this.url}/chat/completions`, {
490
+ method: "POST",
491
+ headers: {
492
+ "Content-Type": "application/json",
493
+ Authorization: `Bearer ${this.apiKey}`
494
+ },
495
+ body: JSON.stringify({
496
+ model: this.model,
497
+ temperature: 0,
498
+ messages: [
499
+ {
500
+ role: "system",
501
+ content: "You select tools and arguments. Respond ONLY with valid JSON."
502
+ },
503
+ {
504
+ role: "user",
505
+ content: buildToolDecisionPrompt(this.tools, message)
506
+ }
507
+ ]
508
+ })
509
+ });
510
+ const data = await res.json();
511
+ const content = data.choices?.[0]?.message?.content;
512
+ try {
513
+ return JSON.parse(content);
514
+ } catch {
515
+ return { tool: null };
516
+ }
517
+ }
518
+ async ask(message) {
519
+ let toolContext = "";
520
+ const decision = await this.decideTool(message);
521
+ if (decision.tool) {
522
+ const tool = this.tools.find((t) => t.name === decision.tool);
523
+ if (tool) {
524
+ const result = await tool.call(decision.arguments);
525
+ toolContext = `
526
+ Tool used: ${tool.name}
527
+ Result (partial):
528
+ \`\`\`json
529
+ ${JSON.stringify(result, null, 2).slice(0, 4e3)}
530
+ \`\`\`
531
+ `;
532
+ }
533
+ }
534
+ const finalPrompt = `
535
+ User request:
536
+ ${message}
537
+
538
+ ${toolContext}
539
+
540
+ Respond in clean, well-formatted Markdown.
541
+ Use lists, tables, and headings where appropriate.
542
+ Do NOT mention tools or APIs explicitly.
543
+
544
+ Context rules:
545
+ - Respond ONLY using the information provided in the context.
546
+ - Do NOT generate or assume any information not present in the context.
547
+ - If the answer cannot be found in the context, respond exactly:
548
+ "No relevant information was found."
549
+ `;
550
+ const res = await fetch(`${this.url}/chat/completions`, {
551
+ method: "POST",
552
+ headers: {
553
+ "Content-Type": "application/json",
554
+ Authorization: `Bearer ${this.apiKey}`
555
+ },
556
+ body: JSON.stringify({
557
+ model: this.model,
558
+ temperature: 0,
559
+ messages: [
560
+ { role: "system", content: MARKDOWN_SYSTEM_PROMPT },
561
+ { role: "user", content: finalPrompt }
562
+ ]
563
+ })
564
+ });
565
+ const data = await res.json();
566
+ return data.choices?.[0]?.message?.content ?? "";
567
+ }
568
+ };
569
+
480
570
  // src/MCPAgent.tsx
481
571
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
482
572
  var MARKDOWN_SYSTEM_PROMPT = `
@@ -551,6 +641,13 @@ function MCPAgent(props) {
551
641
  void 0,
552
642
  props.tools
553
643
  );
644
+ } else if (props.provider === "deepseek") {
645
+ return new DeepSeekAgent(
646
+ props.apiKey,
647
+ props.model,
648
+ void 0,
649
+ props.tools
650
+ );
554
651
  }
555
652
  return new GroqAgent(
556
653
  props.apiKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-mcp-chatbot",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A React MCP-style AI chatbot component with tool calling and backend integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",