@micdrop/mistral 1.0.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.
- package/README.md +88 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +72 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @micdrop/mistral
|
|
2
|
+
|
|
3
|
+
Mistral AI implementation for [@micdrop/server](../server/README.md).
|
|
4
|
+
|
|
5
|
+
This package provides AI agent implementation using Mistral AI's API for conversational AI applications.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🤖 **Mistral Agent** - Mistral-powered conversational AI with:
|
|
10
|
+
- Streaming responses for real-time conversation
|
|
11
|
+
- Support for all Mistral AI models including Ministral, Mistral Large, and Pixtral
|
|
12
|
+
- Configurable model selection and API settings
|
|
13
|
+
- Seamless integration with MicdropServer
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @micdrop/mistral
|
|
19
|
+
# or
|
|
20
|
+
yarn add @micdrop/mistral
|
|
21
|
+
# or
|
|
22
|
+
pnpm add @micdrop/mistral
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Mistral Agent
|
|
26
|
+
|
|
27
|
+
### Usage
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { MistralAgent } from '@micdrop/mistral'
|
|
31
|
+
import { MicdropServer } from '@micdrop/server'
|
|
32
|
+
|
|
33
|
+
const agent = new MistralAgent({
|
|
34
|
+
apiKey: process.env.MISTRAL_API_KEY || '',
|
|
35
|
+
model: 'ministral-8b-latest', // Default model
|
|
36
|
+
systemPrompt: 'You are a helpful assistant',
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// Use with MicdropServer
|
|
40
|
+
new MicdropServer(socket, {
|
|
41
|
+
agent,
|
|
42
|
+
// ... other options
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Options
|
|
47
|
+
|
|
48
|
+
| Option | Type | Default | Description |
|
|
49
|
+
| -------------- | -------- | ----------------------- | ------------------------------------ |
|
|
50
|
+
| `apiKey` | `string` | Required | Your Mistral AI API key |
|
|
51
|
+
| `model` | `string` | `'ministral-8b-latest'` | Mistral AI model to use |
|
|
52
|
+
| `systemPrompt` | `string` | Required | System prompt for the agent |
|
|
53
|
+
| `settings` | `object` | `{}` | Additional Mistral AI API parameters |
|
|
54
|
+
|
|
55
|
+
### Available Models
|
|
56
|
+
|
|
57
|
+
Mistral AI offers several models you can choose from:
|
|
58
|
+
|
|
59
|
+
- **`ministral-8b-latest`** - Fast and efficient 8B parameter model (default)
|
|
60
|
+
- **`mistral-large-latest`** - Most capable model for complex tasks
|
|
61
|
+
- **`mistral-small-latest`** - Balanced performance and cost
|
|
62
|
+
- **`codestral-latest`** - Specialized for code generation
|
|
63
|
+
|
|
64
|
+
### Settings Object
|
|
65
|
+
|
|
66
|
+
The `settings` parameter accepts any additional options from the Mistral AI Chat Completions API:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const agent = new MistralAgent({
|
|
70
|
+
apiKey: process.env.MISTRAL_API_KEY || '',
|
|
71
|
+
systemPrompt: 'You are a helpful assistant',
|
|
72
|
+
settings: {
|
|
73
|
+
temperature: 0.7, // Controls randomness (0-1)
|
|
74
|
+
max_tokens: 1000, // Maximum tokens in response
|
|
75
|
+
top_p: 0.9, // Nucleus sampling parameter
|
|
76
|
+
random_seed: 42, // For reproducible outputs
|
|
77
|
+
safe_prompt: false, // Enable/disable safety filtering
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
|
85
|
+
|
|
86
|
+
## Author
|
|
87
|
+
|
|
88
|
+
Originally developed for [Raconte.ai](https://www.raconte.ai) and open sourced by [Lonestone](https://www.lonestone.io) ([GitHub](https://github.com/lonestone))
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AgentOptions, Agent } from '@micdrop/server';
|
|
2
|
+
import { ChatCompletionStreamRequest } from '@mistralai/mistralai/models/components';
|
|
3
|
+
import { PassThrough } from 'stream';
|
|
4
|
+
|
|
5
|
+
interface MistralAgentOptions extends AgentOptions {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
settings?: Omit<ChatCompletionStreamRequest, 'messages' | 'model'>;
|
|
9
|
+
}
|
|
10
|
+
declare class MistralAgent extends Agent<MistralAgentOptions> {
|
|
11
|
+
private mistral;
|
|
12
|
+
private cancelled;
|
|
13
|
+
private running;
|
|
14
|
+
constructor(options: MistralAgentOptions);
|
|
15
|
+
answer(): {
|
|
16
|
+
message: Promise<string>;
|
|
17
|
+
stream: PassThrough;
|
|
18
|
+
};
|
|
19
|
+
private generateAnswer;
|
|
20
|
+
cancel(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { MistralAgent, type MistralAgentOptions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AgentOptions, Agent } from '@micdrop/server';
|
|
2
|
+
import { ChatCompletionStreamRequest } from '@mistralai/mistralai/models/components';
|
|
3
|
+
import { PassThrough } from 'stream';
|
|
4
|
+
|
|
5
|
+
interface MistralAgentOptions extends AgentOptions {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
settings?: Omit<ChatCompletionStreamRequest, 'messages' | 'model'>;
|
|
9
|
+
}
|
|
10
|
+
declare class MistralAgent extends Agent<MistralAgentOptions> {
|
|
11
|
+
private mistral;
|
|
12
|
+
private cancelled;
|
|
13
|
+
private running;
|
|
14
|
+
constructor(options: MistralAgentOptions);
|
|
15
|
+
answer(): {
|
|
16
|
+
message: Promise<string>;
|
|
17
|
+
stream: PassThrough;
|
|
18
|
+
};
|
|
19
|
+
private generateAnswer;
|
|
20
|
+
cancel(): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { MistralAgent, type MistralAgentOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MistralAgent: () => MistralAgent
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/MistralAgent.ts
|
|
28
|
+
var import_server = require("@micdrop/server");
|
|
29
|
+
var import_mistralai = require("@mistralai/mistralai");
|
|
30
|
+
var import_stream = require("stream");
|
|
31
|
+
var DEFAULT_MODEL = "ministral-8b-latest";
|
|
32
|
+
var MistralAgent = class extends import_server.Agent {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
super(options);
|
|
35
|
+
this.cancelled = false;
|
|
36
|
+
this.running = false;
|
|
37
|
+
this.mistral = new import_mistralai.Mistral({ apiKey: options.apiKey });
|
|
38
|
+
}
|
|
39
|
+
answer() {
|
|
40
|
+
this.log("Start answering");
|
|
41
|
+
this.cancelled = false;
|
|
42
|
+
const stream = new import_stream.PassThrough();
|
|
43
|
+
const textPromise = this.createTextPromise();
|
|
44
|
+
this.generateAnswer(stream, textPromise);
|
|
45
|
+
return { message: textPromise.promise, stream };
|
|
46
|
+
}
|
|
47
|
+
async generateAnswer(stream, textPromise) {
|
|
48
|
+
this.running = true;
|
|
49
|
+
this.cancelled = false;
|
|
50
|
+
if (this.conversation.length === 1) {
|
|
51
|
+
this.conversation.push({
|
|
52
|
+
role: "user",
|
|
53
|
+
content: ""
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const result = await this.mistral.chat.stream({
|
|
58
|
+
model: this.options.model || DEFAULT_MODEL,
|
|
59
|
+
messages: this.conversation.map((message) => ({
|
|
60
|
+
role: message.role,
|
|
61
|
+
content: message.content
|
|
62
|
+
})),
|
|
63
|
+
...this.options.settings
|
|
64
|
+
});
|
|
65
|
+
let fullAnswer = "";
|
|
66
|
+
for await (const event of result) {
|
|
67
|
+
if (this.cancelled) return;
|
|
68
|
+
const chunk = event.data.choices[0].delta.content;
|
|
69
|
+
if (typeof chunk === "string") {
|
|
70
|
+
this.log(`Answer chunk: "${chunk}"`);
|
|
71
|
+
stream.write(chunk);
|
|
72
|
+
fullAnswer += chunk;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
this.addAssistantMessage(fullAnswer);
|
|
76
|
+
textPromise.resolve(fullAnswer);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error("[MistralAgent] Error:", error);
|
|
79
|
+
textPromise.reject(error);
|
|
80
|
+
stream.emit("error", error);
|
|
81
|
+
} finally {
|
|
82
|
+
if (stream.writable) {
|
|
83
|
+
stream.end();
|
|
84
|
+
}
|
|
85
|
+
this.running = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
cancel() {
|
|
89
|
+
if (!this.running) return;
|
|
90
|
+
this.log("Cancel");
|
|
91
|
+
this.cancelled = true;
|
|
92
|
+
this.running = false;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
MistralAgent
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/MistralAgent.ts"],"sourcesContent":["export * from './MistralAgent'\n","import { Agent, AgentOptions, TextPromise } from '@micdrop/server'\nimport { Mistral } from '@mistralai/mistralai'\nimport { ChatCompletionStreamRequest } from '@mistralai/mistralai/models/components'\nimport { PassThrough, Writable } from 'stream'\n\nexport interface MistralAgentOptions extends AgentOptions {\n apiKey: string\n model?: string\n settings?: Omit<ChatCompletionStreamRequest, 'messages' | 'model'>\n}\n\nconst DEFAULT_MODEL = 'ministral-8b-latest'\n\nexport class MistralAgent extends Agent<MistralAgentOptions> {\n private mistral: Mistral\n private cancelled: boolean = false\n private running: boolean = false\n\n constructor(options: MistralAgentOptions) {\n super(options)\n this.mistral = new Mistral({ apiKey: options.apiKey })\n }\n\n answer() {\n this.log('Start answering')\n this.cancelled = false\n const stream = new PassThrough()\n const textPromise = this.createTextPromise()\n this.generateAnswer(stream, textPromise)\n return { message: textPromise.promise, stream }\n }\n\n private async generateAnswer(stream: Writable, textPromise: TextPromise) {\n this.running = true\n this.cancelled = false\n\n // Hack: Mistral needs a user message if there is only a system message\n if (this.conversation.length === 1) {\n this.conversation.push({\n role: 'user',\n content: '',\n })\n }\n\n try {\n const result = await this.mistral.chat.stream({\n model: this.options.model || DEFAULT_MODEL,\n messages: this.conversation.map((message) => ({\n role: message.role,\n content: message.content,\n })),\n ...this.options.settings,\n })\n\n // Get and stream chunks\n let fullAnswer = ''\n for await (const event of result) {\n if (this.cancelled) return\n const chunk = event.data.choices[0].delta.content\n if (typeof chunk === 'string') {\n this.log(`Answer chunk: \"${chunk}\"`)\n stream.write(chunk)\n fullAnswer += chunk\n }\n }\n\n // Add full answer to conversation\n this.addAssistantMessage(fullAnswer)\n textPromise.resolve(fullAnswer)\n } catch (error: any) {\n console.error('[MistralAgent] Error:', error)\n textPromise.reject(error)\n stream.emit('error', error)\n } finally {\n if (stream.writable) {\n stream.end()\n }\n this.running = false\n }\n }\n\n cancel() {\n if (!this.running) return\n this.log('Cancel')\n this.cancelled = true\n this.running = false\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAiD;AACjD,uBAAwB;AAExB,oBAAsC;AAQtC,IAAM,gBAAgB;AAEf,IAAM,eAAN,cAA2B,oBAA2B;AAAA,EAK3D,YAAY,SAA8B;AACxC,UAAM,OAAO;AAJf,SAAQ,YAAqB;AAC7B,SAAQ,UAAmB;AAIzB,SAAK,UAAU,IAAI,yBAAQ,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EACvD;AAAA,EAEA,SAAS;AACP,SAAK,IAAI,iBAAiB;AAC1B,SAAK,YAAY;AACjB,UAAM,SAAS,IAAI,0BAAY;AAC/B,UAAM,cAAc,KAAK,kBAAkB;AAC3C,SAAK,eAAe,QAAQ,WAAW;AACvC,WAAO,EAAE,SAAS,YAAY,SAAS,OAAO;AAAA,EAChD;AAAA,EAEA,MAAc,eAAe,QAAkB,aAA0B;AACvE,SAAK,UAAU;AACf,SAAK,YAAY;AAGjB,QAAI,KAAK,aAAa,WAAW,GAAG;AAClC,WAAK,aAAa,KAAK;AAAA,QACrB,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAEA,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,QAAQ,KAAK,OAAO;AAAA,QAC5C,OAAO,KAAK,QAAQ,SAAS;AAAA,QAC7B,UAAU,KAAK,aAAa,IAAI,CAAC,aAAa;AAAA,UAC5C,MAAM,QAAQ;AAAA,UACd,SAAS,QAAQ;AAAA,QACnB,EAAE;AAAA,QACF,GAAG,KAAK,QAAQ;AAAA,MAClB,CAAC;AAGD,UAAI,aAAa;AACjB,uBAAiB,SAAS,QAAQ;AAChC,YAAI,KAAK,UAAW;AACpB,cAAM,QAAQ,MAAM,KAAK,QAAQ,CAAC,EAAE,MAAM;AAC1C,YAAI,OAAO,UAAU,UAAU;AAC7B,eAAK,IAAI,kBAAkB,KAAK,GAAG;AACnC,iBAAO,MAAM,KAAK;AAClB,wBAAc;AAAA,QAChB;AAAA,MACF;AAGA,WAAK,oBAAoB,UAAU;AACnC,kBAAY,QAAQ,UAAU;AAAA,IAChC,SAAS,OAAY;AACnB,cAAQ,MAAM,yBAAyB,KAAK;AAC5C,kBAAY,OAAO,KAAK;AACxB,aAAO,KAAK,SAAS,KAAK;AAAA,IAC5B,UAAE;AACA,UAAI,OAAO,UAAU;AACnB,eAAO,IAAI;AAAA,MACb;AACA,WAAK,UAAU;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,SAAS;AACP,QAAI,CAAC,KAAK,QAAS;AACnB,SAAK,IAAI,QAAQ;AACjB,SAAK,YAAY;AACjB,SAAK,UAAU;AAAA,EACjB;AACF;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/MistralAgent.ts
|
|
2
|
+
import { Agent } from "@micdrop/server";
|
|
3
|
+
import { Mistral } from "@mistralai/mistralai";
|
|
4
|
+
import { PassThrough } from "stream";
|
|
5
|
+
var DEFAULT_MODEL = "ministral-8b-latest";
|
|
6
|
+
var MistralAgent = class extends Agent {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
9
|
+
this.cancelled = false;
|
|
10
|
+
this.running = false;
|
|
11
|
+
this.mistral = new Mistral({ apiKey: options.apiKey });
|
|
12
|
+
}
|
|
13
|
+
answer() {
|
|
14
|
+
this.log("Start answering");
|
|
15
|
+
this.cancelled = false;
|
|
16
|
+
const stream = new PassThrough();
|
|
17
|
+
const textPromise = this.createTextPromise();
|
|
18
|
+
this.generateAnswer(stream, textPromise);
|
|
19
|
+
return { message: textPromise.promise, stream };
|
|
20
|
+
}
|
|
21
|
+
async generateAnswer(stream, textPromise) {
|
|
22
|
+
this.running = true;
|
|
23
|
+
this.cancelled = false;
|
|
24
|
+
if (this.conversation.length === 1) {
|
|
25
|
+
this.conversation.push({
|
|
26
|
+
role: "user",
|
|
27
|
+
content: ""
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const result = await this.mistral.chat.stream({
|
|
32
|
+
model: this.options.model || DEFAULT_MODEL,
|
|
33
|
+
messages: this.conversation.map((message) => ({
|
|
34
|
+
role: message.role,
|
|
35
|
+
content: message.content
|
|
36
|
+
})),
|
|
37
|
+
...this.options.settings
|
|
38
|
+
});
|
|
39
|
+
let fullAnswer = "";
|
|
40
|
+
for await (const event of result) {
|
|
41
|
+
if (this.cancelled) return;
|
|
42
|
+
const chunk = event.data.choices[0].delta.content;
|
|
43
|
+
if (typeof chunk === "string") {
|
|
44
|
+
this.log(`Answer chunk: "${chunk}"`);
|
|
45
|
+
stream.write(chunk);
|
|
46
|
+
fullAnswer += chunk;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
this.addAssistantMessage(fullAnswer);
|
|
50
|
+
textPromise.resolve(fullAnswer);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error("[MistralAgent] Error:", error);
|
|
53
|
+
textPromise.reject(error);
|
|
54
|
+
stream.emit("error", error);
|
|
55
|
+
} finally {
|
|
56
|
+
if (stream.writable) {
|
|
57
|
+
stream.end();
|
|
58
|
+
}
|
|
59
|
+
this.running = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
cancel() {
|
|
63
|
+
if (!this.running) return;
|
|
64
|
+
this.log("Cancel");
|
|
65
|
+
this.cancelled = true;
|
|
66
|
+
this.running = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
MistralAgent
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/MistralAgent.ts"],"sourcesContent":["import { Agent, AgentOptions, TextPromise } from '@micdrop/server'\nimport { Mistral } from '@mistralai/mistralai'\nimport { ChatCompletionStreamRequest } from '@mistralai/mistralai/models/components'\nimport { PassThrough, Writable } from 'stream'\n\nexport interface MistralAgentOptions extends AgentOptions {\n apiKey: string\n model?: string\n settings?: Omit<ChatCompletionStreamRequest, 'messages' | 'model'>\n}\n\nconst DEFAULT_MODEL = 'ministral-8b-latest'\n\nexport class MistralAgent extends Agent<MistralAgentOptions> {\n private mistral: Mistral\n private cancelled: boolean = false\n private running: boolean = false\n\n constructor(options: MistralAgentOptions) {\n super(options)\n this.mistral = new Mistral({ apiKey: options.apiKey })\n }\n\n answer() {\n this.log('Start answering')\n this.cancelled = false\n const stream = new PassThrough()\n const textPromise = this.createTextPromise()\n this.generateAnswer(stream, textPromise)\n return { message: textPromise.promise, stream }\n }\n\n private async generateAnswer(stream: Writable, textPromise: TextPromise) {\n this.running = true\n this.cancelled = false\n\n // Hack: Mistral needs a user message if there is only a system message\n if (this.conversation.length === 1) {\n this.conversation.push({\n role: 'user',\n content: '',\n })\n }\n\n try {\n const result = await this.mistral.chat.stream({\n model: this.options.model || DEFAULT_MODEL,\n messages: this.conversation.map((message) => ({\n role: message.role,\n content: message.content,\n })),\n ...this.options.settings,\n })\n\n // Get and stream chunks\n let fullAnswer = ''\n for await (const event of result) {\n if (this.cancelled) return\n const chunk = event.data.choices[0].delta.content\n if (typeof chunk === 'string') {\n this.log(`Answer chunk: \"${chunk}\"`)\n stream.write(chunk)\n fullAnswer += chunk\n }\n }\n\n // Add full answer to conversation\n this.addAssistantMessage(fullAnswer)\n textPromise.resolve(fullAnswer)\n } catch (error: any) {\n console.error('[MistralAgent] Error:', error)\n textPromise.reject(error)\n stream.emit('error', error)\n } finally {\n if (stream.writable) {\n stream.end()\n }\n this.running = false\n }\n }\n\n cancel() {\n if (!this.running) return\n this.log('Cancel')\n this.cancelled = true\n this.running = false\n }\n}\n"],"mappings":";AAAA,SAAS,aAAwC;AACjD,SAAS,eAAe;AAExB,SAAS,mBAA6B;AAQtC,IAAM,gBAAgB;AAEf,IAAM,eAAN,cAA2B,MAA2B;AAAA,EAK3D,YAAY,SAA8B;AACxC,UAAM,OAAO;AAJf,SAAQ,YAAqB;AAC7B,SAAQ,UAAmB;AAIzB,SAAK,UAAU,IAAI,QAAQ,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EACvD;AAAA,EAEA,SAAS;AACP,SAAK,IAAI,iBAAiB;AAC1B,SAAK,YAAY;AACjB,UAAM,SAAS,IAAI,YAAY;AAC/B,UAAM,cAAc,KAAK,kBAAkB;AAC3C,SAAK,eAAe,QAAQ,WAAW;AACvC,WAAO,EAAE,SAAS,YAAY,SAAS,OAAO;AAAA,EAChD;AAAA,EAEA,MAAc,eAAe,QAAkB,aAA0B;AACvE,SAAK,UAAU;AACf,SAAK,YAAY;AAGjB,QAAI,KAAK,aAAa,WAAW,GAAG;AAClC,WAAK,aAAa,KAAK;AAAA,QACrB,MAAM;AAAA,QACN,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAEA,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,QAAQ,KAAK,OAAO;AAAA,QAC5C,OAAO,KAAK,QAAQ,SAAS;AAAA,QAC7B,UAAU,KAAK,aAAa,IAAI,CAAC,aAAa;AAAA,UAC5C,MAAM,QAAQ;AAAA,UACd,SAAS,QAAQ;AAAA,QACnB,EAAE;AAAA,QACF,GAAG,KAAK,QAAQ;AAAA,MAClB,CAAC;AAGD,UAAI,aAAa;AACjB,uBAAiB,SAAS,QAAQ;AAChC,YAAI,KAAK,UAAW;AACpB,cAAM,QAAQ,MAAM,KAAK,QAAQ,CAAC,EAAE,MAAM;AAC1C,YAAI,OAAO,UAAU,UAAU;AAC7B,eAAK,IAAI,kBAAkB,KAAK,GAAG;AACnC,iBAAO,MAAM,KAAK;AAClB,wBAAc;AAAA,QAChB;AAAA,MACF;AAGA,WAAK,oBAAoB,UAAU;AACnC,kBAAY,QAAQ,UAAU;AAAA,IAChC,SAAS,OAAY;AACnB,cAAQ,MAAM,yBAAyB,KAAK;AAC5C,kBAAY,OAAO,KAAK;AACxB,aAAO,KAAK,SAAS,KAAK;AAAA,IAC5B,UAAE;AACA,UAAI,OAAO,UAAU;AACnB,eAAO,IAAI;AAAA,MACb;AACA,WAAK,UAAU;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,SAAS;AACP,QAAI,CAAC,KAAK,QAAS;AACnB,SAAK,IAAI,QAAQ;AACjB,SAAK,YAAY;AACjB,SAAK,UAAU;AAAA,EACjB;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@micdrop/mistral",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Mistral implementation for @micdrop/server",
|
|
5
|
+
"author": "Lonestone",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsup",
|
|
12
|
+
"dev": "tsup --watch",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/lonestone/micdrop.git",
|
|
23
|
+
"directory": "packages/mistral"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"microphone",
|
|
30
|
+
"audio",
|
|
31
|
+
"browser",
|
|
32
|
+
"voice",
|
|
33
|
+
"conversation",
|
|
34
|
+
"mistral",
|
|
35
|
+
"tts"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@mistralai/mistralai": "^1.7.3"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@micdrop/server": "*"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.13.4",
|
|
45
|
+
"tsup": "^8.3.6",
|
|
46
|
+
"typescript": "^5.7.3"
|
|
47
|
+
}
|
|
48
|
+
}
|