@matechat/core 1.6.0 → 1.7.0-alpha.1
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/Bubble/index.css +1 -1
- package/Input/index.js +120 -112
- package/Locale/index.js +25 -19
- package/MarkdownCard/MermaidService-cIIuQ-0H.js +103 -0
- package/MarkdownCard/index.css +1 -1
- package/MarkdownCard/index.js +427 -245
- package/README.md +5 -9
- package/package.json +1 -1
- package/MarkdownCard/MermaidService-BAyBWx9t.js +0 -48
package/README.md
CHANGED
|
@@ -302,16 +302,14 @@ $ npm install openai
|
|
|
302
302
|
```js
|
|
303
303
|
import OpenAI from 'openai';
|
|
304
304
|
|
|
305
|
-
const client =
|
|
306
|
-
|
|
307
|
-
client.value = new OpenAI({
|
|
305
|
+
const client = new OpenAI({
|
|
308
306
|
apiKey: '', // 模型APIKey
|
|
309
307
|
baseURL: '', // 模型API地址
|
|
310
308
|
dangerouslyAllowBrowser: true,
|
|
311
309
|
});
|
|
312
310
|
|
|
313
311
|
const fetchData = (ques) => {
|
|
314
|
-
const completion = await client.
|
|
312
|
+
const completion = await client.chat.completions.create({
|
|
315
313
|
model: 'my-model', // 替换为自己的model名称
|
|
316
314
|
messages: [
|
|
317
315
|
{ role: 'user', content: ques },
|
|
@@ -354,9 +352,7 @@ const onSubmit = (evt) => {
|
|
|
354
352
|
```ts
|
|
355
353
|
import OpenAI from 'openai';
|
|
356
354
|
|
|
357
|
-
const client =
|
|
358
|
-
|
|
359
|
-
client.value = new OpenAI({
|
|
355
|
+
const client = new OpenAI({
|
|
360
356
|
apiKey: '', // 模型APIKey
|
|
361
357
|
baseURL: '', // 模型API地址
|
|
362
358
|
dangerouslyAllowBrowser: true,
|
|
@@ -383,7 +379,7 @@ const fetchData = async (ques) => {
|
|
|
383
379
|
id: '',
|
|
384
380
|
loading: true,
|
|
385
381
|
});
|
|
386
|
-
const completion = await client.
|
|
382
|
+
const completion = await client.chat.completions.create({
|
|
387
383
|
model: 'my-model', // 替换为自己的model名称
|
|
388
384
|
messages: [{ role: 'user', content: ques }],
|
|
389
385
|
stream: true, // 为 true 则开启接口的流式返回
|
|
@@ -423,7 +419,7 @@ MateChat 在不断的演进中,你可在这里了解我们的计划:[MateCha
|
|
|
423
419
|
|
|
424
420
|
## 谁在使用
|
|
425
421
|
|
|
426
|
-
[CodeArts
|
|
422
|
+
[华为云CodeArts智能助手](https://www.huaweicloud.com/product/codeartside/snap.html)
|
|
427
423
|
|
|
428
424
|
[InsCode AI IDE](https://inscode.csdn.net/)
|
|
429
425
|
|
package/package.json
CHANGED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
class n {
|
|
2
|
-
constructor(i = {}) {
|
|
3
|
-
this.config = i, this.mermaidInstance = null, this.isLoading = !1, this.lastValidResult = "";
|
|
4
|
-
}
|
|
5
|
-
async loadMermaid() {
|
|
6
|
-
if (this.mermaidInstance)
|
|
7
|
-
return this.mermaidInstance;
|
|
8
|
-
if (this.isLoading)
|
|
9
|
-
return new Promise((i) => {
|
|
10
|
-
const t = () => {
|
|
11
|
-
this.mermaidInstance ? i(this.mermaidInstance) : setTimeout(t, 50);
|
|
12
|
-
};
|
|
13
|
-
t();
|
|
14
|
-
});
|
|
15
|
-
this.isLoading = !0;
|
|
16
|
-
try {
|
|
17
|
-
const { default: i } = await import("mermaid");
|
|
18
|
-
return i.initialize({
|
|
19
|
-
theme: this.config.theme || "default",
|
|
20
|
-
startOnLoad: !1,
|
|
21
|
-
suppressErrorRendering: !0,
|
|
22
|
-
...this.config
|
|
23
|
-
}), this.mermaidInstance = i, i;
|
|
24
|
-
} catch (i) {
|
|
25
|
-
throw console.error("Failed to load mermaid:", i), new Error("Failed to load mermaid library");
|
|
26
|
-
} finally {
|
|
27
|
-
this.isLoading = !1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async renderMermaid(i, t = "light") {
|
|
31
|
-
try {
|
|
32
|
-
const e = await this.loadMermaid();
|
|
33
|
-
this.config.theme !== t && (this.config.theme = t, e.initialize({
|
|
34
|
-
startOnLoad: !1,
|
|
35
|
-
suppressErrorRendering: !0,
|
|
36
|
-
theme: t === "dark" ? "dark" : "default",
|
|
37
|
-
...this.config
|
|
38
|
-
}));
|
|
39
|
-
const a = `mc_mermaid_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, { svg: r } = await e.render(a, i);
|
|
40
|
-
return this.lastValidResult = r, r;
|
|
41
|
-
} catch {
|
|
42
|
-
return this.lastValidResult;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
n as MermaidService
|
|
48
|
-
};
|