@matechat/core 0.0.2-alpha.1 → 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 +20 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ createApp(App).use(DevUI).use(MateChat).mount('#app');
|
|
|
56
56
|
|
|
57
57
|
```html
|
|
58
58
|
<template>
|
|
59
|
-
<McBubble :avatarConfig="{ name: 'matechat' }">
|
|
59
|
+
<McBubble :conent="'Hello, MateChat'" :avatarConfig="{ name: 'matechat' }"></McBubble>
|
|
60
60
|
</template>
|
|
61
61
|
```
|
|
62
62
|
|
|
@@ -115,10 +115,7 @@ createApp(App).use(DevUI).use(MateChat).mount('#app');
|
|
|
115
115
|
shape="circle"
|
|
116
116
|
title="新建对话"
|
|
117
117
|
size="sm"
|
|
118
|
-
@click="
|
|
119
|
-
startPage = true;
|
|
120
|
-
messages = [];
|
|
121
|
-
"
|
|
118
|
+
@click="newConversation"
|
|
122
119
|
/>
|
|
123
120
|
</div>
|
|
124
121
|
<McLayoutSender>
|
|
@@ -205,7 +202,13 @@ const messages = ref<any[]>([
|
|
|
205
202
|
},
|
|
206
203
|
]);
|
|
207
204
|
|
|
205
|
+
const newConversation = () => {
|
|
206
|
+
startPage.value = true;
|
|
207
|
+
messages.value = [];
|
|
208
|
+
}
|
|
209
|
+
|
|
208
210
|
const onSubmit = (evt) => {
|
|
211
|
+
inputValue.value='';
|
|
209
212
|
startPage.value = false;
|
|
210
213
|
// 用户发送消息
|
|
211
214
|
messages.value.push({
|
|
@@ -308,7 +311,7 @@ client.value = new OpenAI({
|
|
|
308
311
|
|
|
309
312
|
const fetchData = (ques) => {
|
|
310
313
|
const completion = await client.value!.chat.completions.create({
|
|
311
|
-
model: 'my-model', //
|
|
314
|
+
model: 'my-model', // 替换为自己的model名称
|
|
312
315
|
messages: [
|
|
313
316
|
{ role: 'user', content: ques },
|
|
314
317
|
],
|
|
@@ -325,8 +328,10 @@ const fetchData = (ques) => {
|
|
|
325
328
|
那么参考以上步骤,【快速开始】中示例可调整下代码。
|
|
326
329
|
|
|
327
330
|
将以下代码:
|
|
331
|
+
|
|
328
332
|
```ts
|
|
329
333
|
const onSubmit = (evt) => {
|
|
334
|
+
inputValue.value = '';
|
|
330
335
|
startPage.value = false;
|
|
331
336
|
// 用户发送消息
|
|
332
337
|
messages.value.push({
|
|
@@ -340,9 +345,11 @@ const onSubmit = (evt) => {
|
|
|
340
345
|
content: evt,
|
|
341
346
|
});
|
|
342
347
|
}, 200);
|
|
348
|
+
};
|
|
343
349
|
```
|
|
344
350
|
|
|
345
351
|
修改为:
|
|
352
|
+
|
|
346
353
|
```ts
|
|
347
354
|
import OpenAI from 'openai';
|
|
348
355
|
|
|
@@ -355,13 +362,15 @@ client.value = new OpenAI({
|
|
|
355
362
|
});
|
|
356
363
|
|
|
357
364
|
const onSubmit = (evt) => {
|
|
365
|
+
inputValue.value = '';
|
|
366
|
+
startPage.value = false;
|
|
358
367
|
// 用户发送消息
|
|
359
368
|
messages.value.push({
|
|
360
369
|
from: 'user',
|
|
361
370
|
content: evt,
|
|
362
371
|
avatarConfig: { name: 'user' },
|
|
363
372
|
});
|
|
364
|
-
|
|
373
|
+
|
|
365
374
|
fetchData(evt);
|
|
366
375
|
};
|
|
367
376
|
|
|
@@ -374,7 +383,7 @@ const fetchData = async (ques) => {
|
|
|
374
383
|
loading: true,
|
|
375
384
|
});
|
|
376
385
|
const completion = await client.value!.chat.completions.create({
|
|
377
|
-
model: 'my-model', //
|
|
386
|
+
model: 'my-model', // 替换为自己的model名称
|
|
378
387
|
messages: [{ role: 'user', content: ques }],
|
|
379
388
|
stream: true, // 为 true 则开启接口的流式返回
|
|
380
389
|
});
|
|
@@ -387,7 +396,8 @@ const fetchData = async (ques) => {
|
|
|
387
396
|
}
|
|
388
397
|
};
|
|
389
398
|
```
|
|
390
|
-
|
|
399
|
+
|
|
400
|
+
完成模型API地址与APIKey填充后,即拥有了一个对接大模型的简单应用。如果你想要参考更完整的页面示例,可参考[演示场景](https://matechat.gitcode.com/playground/playground.html)。
|
|
391
401
|
|
|
392
402
|
## 📝 提出意见&建议
|
|
393
403
|
|
|
@@ -420,4 +430,4 @@ MateChat 在不断的演进中,你可在这里了解我们的计划:[MateCha
|
|
|
420
430
|
|
|
421
431
|
## 联系方式
|
|
422
432
|
|
|
423
|
-
欢迎加入我们的开源社区,关注DevUI微信公众号:DevUI
|
|
433
|
+
欢迎加入我们的开源社区,关注DevUI微信公众号:DevUI
|
package/package.json
CHANGED