@memberjunction/ai-mistral 5.0.0 → 5.2.0

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/README.md +114 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @memberjunction/ai-mistral
2
+
3
+ MemberJunction AI provider for Mistral AI. This package provides both LLM and embedding capabilities using Mistral's models, implementing `BaseLLM` and `BaseEmbeddings` from `@memberjunction/ai`.
4
+
5
+ ## Architecture
6
+
7
+ ```mermaid
8
+ graph TD
9
+ A["MistralLLM<br/>(Provider)"] -->|extends| B["BaseLLM<br/>(@memberjunction/ai)"]
10
+ C["MistralEmbedding<br/>(Provider)"] -->|extends| D["BaseEmbeddings<br/>(@memberjunction/ai)"]
11
+ A -->|wraps| E["Mistral Client<br/>(@mistralai/mistralai)"]
12
+ C -->|wraps| E
13
+ A -->|provides| F["Chat Completions<br/>+ Streaming"]
14
+ C -->|provides| G["Text Embeddings"]
15
+ B -->|registered via| H["@RegisterClass"]
16
+ D -->|registered via| H
17
+
18
+ style A fill:#7c5295,stroke:#563a6b,color:#fff
19
+ style C fill:#7c5295,stroke:#563a6b,color:#fff
20
+ style B fill:#2d6a9f,stroke:#1a4971,color:#fff
21
+ style D fill:#2d6a9f,stroke:#1a4971,color:#fff
22
+ style E fill:#2d8659,stroke:#1a5c3a,color:#fff
23
+ style F fill:#b8762f,stroke:#8a5722,color:#fff
24
+ style G fill:#b8762f,stroke:#8a5722,color:#fff
25
+ style H fill:#b8762f,stroke:#8a5722,color:#fff
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - **Chat Completions**: Conversational AI with Mistral Large, Medium, Small, and open models
31
+ - **Streaming**: Real-time response streaming support
32
+ - **Text Embeddings**: Vector embeddings via Mistral's embedding models
33
+ - **Thinking/Reasoning**: Extraction of thinking content from reasoning models
34
+ - **JSON Mode**: Response format control for structured outputs
35
+ - **Multimodal Support**: Handling of image content in messages
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ npm install @memberjunction/ai-mistral
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### Chat Completion
46
+
47
+ ```typescript
48
+ import { MistralLLM } from '@memberjunction/ai-mistral';
49
+
50
+ const llm = new MistralLLM('your-mistral-api-key');
51
+
52
+ const result = await llm.ChatCompletion({
53
+ model: 'mistral-large-latest',
54
+ messages: [
55
+ { role: 'user', content: 'Explain transformers in machine learning.' }
56
+ ],
57
+ temperature: 0.7
58
+ });
59
+
60
+ if (result.success) {
61
+ console.log(result.data.choices[0].message.content);
62
+ }
63
+ ```
64
+
65
+ ### Streaming
66
+
67
+ ```typescript
68
+ const result = await llm.ChatCompletion({
69
+ model: 'mistral-small-latest',
70
+ messages: [{ role: 'user', content: 'Write a poem.' }],
71
+ streaming: true,
72
+ streamingCallbacks: {
73
+ OnContent: (content) => process.stdout.write(content),
74
+ OnComplete: () => console.log('\nDone!')
75
+ }
76
+ });
77
+ ```
78
+
79
+ ### Embeddings
80
+
81
+ ```typescript
82
+ import { MistralEmbedding } from '@memberjunction/ai-mistral';
83
+
84
+ const embedder = new MistralEmbedding('your-mistral-api-key');
85
+
86
+ const result = await embedder.EmbedText({
87
+ text: 'Sample text for embedding',
88
+ model: 'mistral-embed'
89
+ });
90
+
91
+ console.log(`Dimensions: ${result.vector.length}`);
92
+ ```
93
+
94
+ ## Supported Parameters
95
+
96
+ | Parameter | Supported | Notes |
97
+ |-----------|-----------|-------|
98
+ | temperature | Yes | Controls randomness |
99
+ | maxOutputTokens | Yes | Maximum response length |
100
+ | topP | Yes | Nucleus sampling |
101
+ | seed | Yes | Deterministic outputs |
102
+ | responseFormat | Yes | JSON mode support |
103
+ | streaming | Yes | Real-time streaming |
104
+
105
+ ## Class Registration
106
+
107
+ - `MistralLLM` -- Registered via `@RegisterClass(BaseLLM, 'MistralLLM')`
108
+ - `MistralEmbedding` -- Registered via `@RegisterClass(BaseEmbeddings, 'MistralEmbedding')`
109
+
110
+ ## Dependencies
111
+
112
+ - `@memberjunction/ai` - Core AI abstractions
113
+ - `@memberjunction/global` - Class registration
114
+ - `@mistralai/mistralai` - Official Mistral AI SDK
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-mistral",
3
3
  "type": "module",
4
- "version": "5.0.0",
4
+ "version": "5.2.0",
5
5
  "description": "MemberJunction Wrapper for Mistral AI's AI Models",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "typescript": "^5.9.3"
22
22
  },
23
23
  "dependencies": {
24
- "@memberjunction/ai": "5.0.0",
25
- "@memberjunction/global": "5.0.0",
24
+ "@memberjunction/ai": "5.2.0",
25
+ "@memberjunction/global": "5.2.0",
26
26
  "@mistralai/mistralai": "^1.14.0",
27
27
  "axios-retry": "4.5.0"
28
28
  },