@wzh-/ai-chat-example 1.1.2 → 1.1.3
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/dist/_virtual/_plugin-vue_export-helper.js +1 -1
- package/dist/assets/xiao-mian.js +1 -1
- package/dist/components/ChatConversation/ChatConversation.js +1 -1
- package/dist/components/ChatConversation/ChatConversation.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/ChatConversation/index.js +1 -1
- package/dist/components/ChatPromptInput/ChatPromptInput.js +1 -1
- package/dist/components/ChatPromptInput/ChatPromptInput.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/ChatPromptInput/index.js +1 -1
- package/dist/composables/useChat.js +1 -1
- package/dist/composables/useStickToBottom.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/style.d.ts +5 -0
- package/package.json +92 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import e from"./ChatConversation.vue_vue_type_script_setup_true_lang.js";/* empty css */import _ from"../../_virtual/_plugin-vue_export-helper.js";var t=_(e,[["__scopeId","data-v-d99ca689"]]);export{t as default};
|
package/dist/components/ChatConversation/ChatConversation.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import t from"../../assets/xiao-mian.js";import{Fragment as e,computed as l,createBlock as s,createCommentVNode as a,createElementBlock as n,createElementVNode as o,createVNode as u,defineComponent as r,normalizeClass as i,openBlock as c,renderList as p,renderSlot as d,resolveComponent as f,toDisplayString as m,unref as y,withCtx as g}from"vue";var v={class:"flex-1 overflow-hidden mb-3"},k={class:"mt-10 w-full h-full"},x={class:"flex w-full flex-col justify-center items-center"},C=["src"],h={class:"mt-5.5"},_={class:"input-value-box gap-2"},T=["onClick"],b=["alt","src"],S={key:1},w={key:3},B=r({__name:"ChatConversation",props:{messages:{},status:{},defaultInputs:{}},emits:["submit"],setup(r,{emit:B}){const I=r,N=B,R=l(()=>I.messages),V=l(()=>I.status),$=I.defaultInputs||["请帮我查询订单进度。","请帮我查询工序进度。","请帮我查询员工本月登记情况。","请帮我查询款式生产完成情况。"],j=t=>{N("submit",{text:t,files:[]})};function M(t,e){const l=R.value[R.value.length-1],s=R.value[t];if(!l||s?.id!==l.id)return!1;const a=s?.parts?.length>0&&e===s?.parts?.length-1;return"streaming"===V.value&&a}function W(t){return t.startsWith("tool-")}return(l,r)=>{const B=f("MessageResponse"),I=f("ReasoningTrigger"),N=f("ReasoningContent"),V=f("Reasoning"),z=f("Source"),E=f("SourcesContent"),O=f("Sources"),A=f("CodeBlock"),D=f("ToolHeader"),F=f("ToolInput"),H=f("ToolOutput"),J=f("ToolContent"),L=f("Tool"),q=f("MessageContent"),G=f("Message"),K=f("ConversationContent"),P=f("ConversationScrollButton"),Q=f("Conversation");return c(),n("div",v,[u(Q,{class:"relative size-full"},{default:g(()=>[u(K,null,{default:g(()=>[R.value.length?(c(!0),n(e,{key:1},p(R.value,(t,l)=>(c(),s(G,{key:t.id,from:t.role},{default:g(()=>[u(q,{class:i(0===l?"mt-0":"")},{default:g(()=>[(c(!0),n(e,null,p(t.parts,(o,r)=>{return c(),n(e,{key:`${t.id}-${o.type}-${r}`},["text"===o.type?(c(),s(B,{key:0,content:o.text},null,8,["content"])):"reasoning"===o.type?(c(),s(V,{key:1,class:"w-full","is-streaming":M(l,r)},{default:g(()=>[u(I),u(N,{content:o.text},null,8,["content"])]),_:2},1032,["is-streaming"])):"file"===o.type?(c(),n(e,{key:2},[o.mediaType.startsWith("image/")?(c(),n("img",{key:0,alt:o.filename,src:o.url},null,8,b)):(c(),n("div",S,m(o.filename),1))],64)):"source-document"===o.type?(c(),n("div",w,m(o.title),1)):"source-url"===o.type?(c(),s(O,{key:4},{default:g(()=>[u(E,null,{default:g(()=>[u(z,{href:o.url,title:o.title??o.url},null,8,["href","title"])]),_:2},1024)]),_:2},1024)):"step-start"===o.type?(c(),n(e,{key:5},[],64)):(i=o.type,i.startsWith("data-")?(c(),s(A,{key:6,code:JSON.stringify(o.data??{},null,2),language:"json"},null,8,["code"])):"dynamic-tool"===o.type?(c(),s(L,{key:7,"default-open":""},{default:g(()=>[u(D,{state:o.state,title:o.toolName,type:"tool-dynamic-tool"},null,8,["state","title"]),u(J,null,{default:g(()=>[u(F,{input:o.input},null,8,["input"]),u(H,{output:o.output,"error-text":o.errorText},null,8,["output","error-text"])]),_:2},1024)]),_:2},1024)):W(o.type)?(c(),s(L,{key:8,class:"w-full","default-open":!1},{default:g(()=>[u(D,{state:o.state,type:o.type},null,8,["state","type"]),u(J,null,{default:g(()=>[u(F,{input:o.input},null,8,["input"]),u(H,{output:o.output,"error-text":o.errorText},null,8,["output","error-text"])]),_:2},1024)]),_:2},1024)):a("",!0))],64);var i}),128))]),_:2},1032,["class"])]),_:2},1032,["from"]))),128)):d(l.$slots,"empty-message",{key:0,selectInputValue:j},()=>[o("div",k,[o("div",x,[o("img",{src:y(t),alt:"图标",class:"xiao-mian"},null,8,C),r[0]||(r[0]=o("div",{class:"text-box"},"你好,我是AI助手-小棉",-1))]),o("div",h,[r[1]||(r[1]=o("div",{class:"text-[#999] mb-2"},"试一试~",-1)),o("div",_,[(c(!0),n(e,null,p(y($),t=>(c(),n("div",{class:"item",key:t,onClick:e=>j(t)},m(t),9,T))),128))])])])],!0)]),_:3}),u(P,{class:"bg-[#fff]"})]),_:3})])}}});export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import o from"./ChatConversation.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import e from"../../_virtual/_plugin-vue_export-helper.js";import t from"./ChatPromptInput.vue_vue_type_script_setup_true_lang.js";/* empty css */var _=e(t,[["__scopeId","data-v-00e9ba09"]]);export{_ as default};
|
package/dist/components/ChatPromptInput/ChatPromptInput.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{computed as t,createBlock as e,createElementVNode as o,createVNode as a,defineComponent as p,openBlock as s,resolveComponent as u,withCtx as l}from"vue";var n={class:"flex w-full prompt-input-content-box"},m=p({__name:"ChatPromptInput",props:{status:{},uploadImages:{type:Function},onSubmit:{type:Function},stop:{type:Function}},emits:["submit"],setup(p,{emit:m}){const r=p,i=t(()=>r.status),c=t=>r.onSubmit?.(t);return(t,m)=>{const r=u("PromptInputAttachment"),d=u("PromptInputAttachments"),f=u("PromptInputTextarea"),I=u("PromptInputBody"),P=u("PromptInputSubmit"),x=u("PromptInputFooter"),b=u("PromptInput"),h=u("PromptInputProvider");return s(),e(h,{onSubmit:c,uploadImages:p.uploadImages},{default:l(()=>[a(b,{multiple:"","global-drop":""},{default:l(()=>[a(d,{class:"mb-3"},{default:l(({file:t})=>[a(r,{file:t},null,8,["file"])]),_:1}),o("div",n,[a(I,{class:"flex-1 flex overflow-hidden"},{default:l(()=>[a(f,{placeholder:"请输入发送内容~",class:"flex-1 chat-input-textarea"})]),_:1}),a(x,{class:"shrink-0"},{default:l(()=>[a(P,{status:i.value,stop:p.stop},null,8,["status","stop"])]),_:1})])]),_:1})]),_:1},8,["uploadImages"])}}});export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import t from"./ChatPromptInput.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{scrollToBottom as s}from"./useStickToBottom.js";import{computed as e}from"vue";import{Chat as t}from"@ai-sdk/vue";import{DefaultChatTransport as a,generateId as o}from"ai";const r=(r,i)=>{const m=new t({transport:new a({api:r,headers:{Authorization:i},prepareSendMessagesRequest:({messages:s,id:e})=>({body:{message:s[s.length-1],id:e}})}),onError:s=>{m.messages.push({role:"assistant",parts:[{type:"text",text:s.message}],id:o()})}}),n=e(()=>m.messages),u=e(()=>m.status);return{chat:m,messages:n,status:u,handleSubmit:e=>{if(["submitted","streaming"].includes(u.value))return Promise.reject();const t=!!e.text,a=e.files?.length>0;(t||a)&&(m.sendMessage(e),s.value?.())},stop:()=>{m.stop()}}};export{r as useChat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import"vue-stick-to-bottom";const o=ref();export{o as scrollToBottom};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import t from"./components/ChatConversation/ChatConversation.js";import"./components/ChatConversation/index.js";import o from"./components/ChatPromptInput/ChatPromptInput.js";import"./components/ChatPromptInput/index.js";import{useChat as s}from"./composables/useChat.js";/* empty css */export{t as ChatConversation,o as ChatPromptInputProvider,s as useChat};
|
package/package.json
CHANGED
|
@@ -1,66 +1,92 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wzh-/ai-chat-example",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"vue
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"vue-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@wzh-/ai-chat-example",
|
|
3
|
+
"description": "@wzh-/ai-chat-example",
|
|
4
|
+
"private": false,
|
|
5
|
+
"version": "1.1.3",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "./dist/js/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./dist/index.css": {
|
|
15
|
+
"import": "./dist/style.css",
|
|
16
|
+
"types": "./dist/types/style.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "vite",
|
|
24
|
+
"build": "vue-tsc -b && vite build",
|
|
25
|
+
"preview": "vite preview"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"vue": "^3.2.0 || ^3.3.0 || ^3.4.0",
|
|
29
|
+
"@ai-sdk/vue": "*",
|
|
30
|
+
"@vue-flow/core": "*",
|
|
31
|
+
"@vueuse/core": "*",
|
|
32
|
+
"ai": "*",
|
|
33
|
+
"class-variance-authority": "*",
|
|
34
|
+
"clsx": "*",
|
|
35
|
+
"embla-carousel-vue": "*",
|
|
36
|
+
"lucide-vue-next": "*",
|
|
37
|
+
"motion-v": "*",
|
|
38
|
+
"nanoid": "*",
|
|
39
|
+
"reka-ui": "*",
|
|
40
|
+
"shiki": "*",
|
|
41
|
+
"streamdown-vue": "*",
|
|
42
|
+
"tailwind-merge": "*",
|
|
43
|
+
"tokenlens": "*",
|
|
44
|
+
"vue-stick-to-bottom": "*",
|
|
45
|
+
"zod": "*"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@ai-sdk/vue": "^3.0.1",
|
|
49
|
+
"@vue-flow/background": "^1.3.2",
|
|
50
|
+
"@vue-flow/controls": "^1.1.3",
|
|
51
|
+
"@vue-flow/core": "^1.48.0",
|
|
52
|
+
"@vue-flow/node-toolbar": "^1.1.1",
|
|
53
|
+
"@vueuse/core": "^14.1.0",
|
|
54
|
+
"ai": "^6.0.1",
|
|
55
|
+
"class-variance-authority": "^0.7.1",
|
|
56
|
+
"clsx": "^2.1.1",
|
|
57
|
+
"embla-carousel-vue": "^8.6.0",
|
|
58
|
+
"lucide-vue-next": "^0.561.0",
|
|
59
|
+
"motion-v": "^1.7.4",
|
|
60
|
+
"nanoid": "^5.1.6",
|
|
61
|
+
"reka-ui": "^2.6.1",
|
|
62
|
+
"shiki": "^3.20.0",
|
|
63
|
+
"streamdown-vue": "^1.0.29",
|
|
64
|
+
"tailwind-merge": "^3.4.0",
|
|
65
|
+
"tokenlens": "^1.3.1",
|
|
66
|
+
"vue": "^3.5.24",
|
|
67
|
+
"vue-stick-to-bottom": "^0.1.0",
|
|
68
|
+
"zod": "^4.2.1"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/node": "^24.10.1",
|
|
72
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
73
|
+
"@vue/tsconfig": "^0.8.1",
|
|
74
|
+
"autoprefixer": "^10.4.23",
|
|
75
|
+
"postcss": "^8.5.6",
|
|
76
|
+
"tailwindcss": "3",
|
|
77
|
+
"tw-animate-css": "^1.4.0",
|
|
78
|
+
"unplugin-auto-import": "^20.3.0",
|
|
79
|
+
"typescript": "~5.9.3",
|
|
80
|
+
"unplugin-vue-components": "^30.0.0",
|
|
81
|
+
"vite": "npm:rolldown-vite@7.2.5",
|
|
82
|
+
"vite-plugin-dts": "^4.5.4",
|
|
83
|
+
"vite-tsconfig-paths": "^6.0.1",
|
|
84
|
+
"vue-tsc": "^3.1.4"
|
|
85
|
+
},
|
|
86
|
+
"pnpm": {
|
|
87
|
+
"overrides": {
|
|
88
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac"
|
|
92
|
+
}
|