st-comp 0.0.249 → 0.0.251

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.
@@ -1,4 +1,5 @@
1
- "use strict";const l=require("./base-ef747d02.cjs"),q=require("./el-dialog-1b185570.cjs");require("./el-overlay-ea65cb05.cjs");const B=require("./el-button-974ff9e9.cjs"),x=require("./el-input-fa18ef84.cjs"),e=require("vue"),g=require("./dayjs.min-2c20abe6.cjs"),h=require("./index-33f80550.cjs"),T=require("./_plugin-vue_export-helper-f246444f.cjs"),k=require("./index-6ca95c8a.cjs"),V=require("./use-form-common-props-d3ed62c6.cjs");require("./index-28e03bad.cjs");require("./index-9780a537.cjs");require("./index-bb833443.cjs");require("./index-f1c702f6.cjs");require("./vnode-b906ae6d.cjs");require("./scroll-b108dabd.cjs");require("./use-global-config-c80f33a4.cjs");require("./index-37b8d3c6.cjs");require("./index-eea0bcb3.cjs");require("./typescript-b63f8e83.cjs");require("./index-7dce9f59.cjs");require("./config-provider-2ae47cc8.cjs");const z=l.buildProps({size:{type:[Number,String],values:V.componentSizes,default:"",validator:s=>l.isNumber(s)},shape:{type:String,values:["circle","square"],default:"circle"},icon:{type:V.iconPropType},src:{type:String,default:""},alt:String,srcSet:String,fit:{type:l.definePropType(String),default:"cover"}}),A={error:s=>s instanceof Event},C=e.defineComponent({name:"ElAvatar"}),I=e.defineComponent({...C,props:z,emits:A,setup(s,{emit:_}){const c=s,a=l.useNamespace("avatar"),o=e.ref(!1),n=e.computed(()=>{const{size:t,icon:y,shape:d}=c,r=[a.b()];return l.isString(t)&&r.push(a.m(t)),y&&r.push(a.m("icon")),d&&r.push(a.m(d)),r}),p=e.computed(()=>{const{size:t}=c;return l.isNumber(t)?a.cssVarBlock({size:l.addUnit(t)||""}):void 0}),m=e.computed(()=>({objectFit:c.fit}));e.watch(()=>c.src,()=>o.value=!1);function f(t){o.value=!0,_("error",t)}return(t,y)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(e.unref(n)),style:e.normalizeStyle(e.unref(p))},[(t.src||t.srcSet)&&!o.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.src,alt:t.alt,srcset:t.srcSet,style:e.normalizeStyle(e.unref(m)),onError:f},null,44,["src","alt","srcset"])):t.icon?(e.openBlock(),e.createBlock(e.unref(h.ElIcon),{key:1},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon)))]),_:1})):e.renderSlot(t.$slots,"default",{key:2})],6))}});var H=l._export_sfc(I,[["__file","avatar.vue"]]);const $=l.withInstall(H);const j=async({appId:s,apiKey:_,value:c})=>{var a;try{const o=await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${s}/completion`,{method:"POST",headers:{Authorization:`Bearer ${_}`,"Content-Type":"application/json"},body:JSON.stringify({input:{prompt:c},parameters:{incremental_output:!1}})});if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);const n=await o.json();return(a=n==null?void 0:n.output)==null?void 0:a.text}catch(o){throw o.name==="AbortError"?new Error("请求超时"):o}};const N=s=>(e.pushScopeId("data-v-3b75cb12"),s=s(),e.popScopeId(),s),P={class:"chat-container"},L={class:"avatar"},D={class:"message-content"},K={class:"message-text"},M={class:"message-time"},R={key:0,class:"message-item assistant"},F={class:"avatar"},O=N(()=>e.createElementVNode("div",{class:"message-content"},[e.createElementVNode("div",{class:"typing-indicator"},[e.createElementVNode("span"),e.createElementVNode("span"),e.createElementVNode("span")])],-1)),U={class:"input-area"},J={class:"input-actions"},G=N(()=>e.createElementVNode("div",{class:"input-hint"},[e.createElementVNode("span",null,"Ctrl + Enter 发送")],-1)),Q={__name:"index",emits:["callBack"],setup(s,{expose:_,emit:c}){const a=c,o=e.ref(!1),n=e.ref(!1),p=e.ref(!1),m=e.ref(null),f=e.ref([{role:"assistant",time:g.dayjs().format("HH:mm"),content:`你好呀!我是你的品种池AI助手,会根据您的自然语言去进行品种的条件查询
1
+ "use strict";const u=require("./base-ef747d02.cjs"),I=require("./el-dialog-1b185570.cjs");require("./el-overlay-ea65cb05.cjs");const C=require("./el-button-974ff9e9.cjs"),z=require("./el-input-fa18ef84.cjs"),e=require("vue"),N=require("./dayjs.min-2c20abe6.cjs"),S=require("./index-33f80550.cjs"),T=require("./_plugin-vue_export-helper-f246444f.cjs"),q=require("./index-6ca95c8a.cjs"),b=require("./use-form-common-props-d3ed62c6.cjs");require("./index-28e03bad.cjs");require("./index-9780a537.cjs");require("./index-bb833443.cjs");require("./index-f1c702f6.cjs");require("./vnode-b906ae6d.cjs");require("./scroll-b108dabd.cjs");require("./use-global-config-c80f33a4.cjs");require("./index-37b8d3c6.cjs");require("./index-eea0bcb3.cjs");require("./typescript-b63f8e83.cjs");require("./index-7dce9f59.cjs");require("./config-provider-2ae47cc8.cjs");const H=u.buildProps({size:{type:[Number,String],values:b.componentSizes,default:"",validator:s=>u.isNumber(s)},shape:{type:String,values:["circle","square"],default:"circle"},icon:{type:b.iconPropType},src:{type:String,default:""},alt:String,srcSet:String,fit:{type:u.definePropType(String),default:"cover"}}),M={error:s=>s instanceof Event},j=e.defineComponent({name:"ElAvatar"}),R=e.defineComponent({...j,props:H,emits:M,setup(s,{emit:g}){const d=s,a=u.useNamespace("avatar"),p=e.ref(!1),r=e.computed(()=>{const{size:t,icon:l,shape:o}=d,n=[a.b()];return u.isString(t)&&n.push(a.m(t)),l&&n.push(a.m("icon")),o&&n.push(a.m(o)),n}),i=e.computed(()=>{const{size:t}=d;return u.isNumber(t)?a.cssVarBlock({size:u.addUnit(t)||""}):void 0}),m=e.computed(()=>({objectFit:d.fit}));e.watch(()=>d.src,()=>p.value=!1);function f(t){p.value=!0,g("error",t)}return(t,l)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(e.unref(r)),style:e.normalizeStyle(e.unref(i))},[(t.src||t.srcSet)&&!p.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.src,alt:t.alt,srcset:t.srcSet,style:e.normalizeStyle(e.unref(m)),onError:f},null,44,["src","alt","srcset"])):t.icon?(e.openBlock(),e.createBlock(e.unref(S.ElIcon),{key:1},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.icon)))]),_:1})):e.renderSlot(t.$slots,"default",{key:2})],6))}});var $=u._export_sfc(R,[["__file","avatar.vue"]]);const D=u.withInstall($);const L=async({appId:s,apiKey:g,value:d,callback:a})=>{var p;try{const r=await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${s}/completion`,{method:"POST",body:JSON.stringify({input:{prompt:d},parameters:{incremental_output:"true"},debug:{}}),headers:{Authorization:`Bearer ${g}`,"Content-Type":"application/json","X-DashScope-SSE":"enable"}});if(!r.ok||!r.body)throw new Error("请求失败");const i=r.body.getReader(),m=new TextDecoder;for(;;){const{done:f,value:t}=await i.read();if(f&&a){a("finish","");break}try{const l=m.decode(t,{stream:!0}),o=JSON.parse(l.split(`
2
+ `)[3].substr(5)),n=(p=o==null?void 0:o.output)==null?void 0:p.text;n&&a&&a("message",n)}catch{}}}catch(r){console.error(r)}};const x=s=>(e.pushScopeId("data-v-46407344"),s=s(),e.popScopeId(),s),P={class:"chat-container"},K={class:"avatar"},F={class:"message-content"},O={class:"message-text"},J={class:"message-time"},U={key:0,class:"message-item assistant"},X={class:"avatar"},G=x(()=>e.createElementVNode("div",{class:"message-content"},[e.createElementVNode("div",{class:"typing-indicator"},[e.createElementVNode("span"),e.createElementVNode("span"),e.createElementVNode("span")])],-1)),Q={class:"input-area"},W={class:"input-actions"},Y=x(()=>e.createElementVNode("div",{class:"input-hint"},[e.createElementVNode("span",null,"Ctrl + Enter 发送")],-1)),Z={__name:"index",props:{defaultMessage:{type:String,default:`你好呀!我是你的品种池AI助手,会根据您的自然语言去进行品种的条件查询
2
3
 
3
4
  示例:
4
- 帮我查找A股,总市值1000亿,流通股本大于等于1000万`}]),t=e.ref(""),y=async()=>{const r=t.value.trim();if(!r)return k.ElMessage.warning("请输入消息内容");if(n.value)return;f.value.push({role:"user",time:g.dayjs().format("HH:mm"),content:r}),t.value="",await d(),n.value=!0,p.value=!0;let i="{}";try{i=await j({appId:"9e54d112acfe4531bd1fc4fee8827fef",apiKey:"sk-d995eb26a4334bdeb2ccb4cbfaf51de8",value:r}),f.value.push({role:"assistant",time:g.dayjs().format("HH:mm"),content:i}),await d()}catch(v){k.ElMessage.error(`AI响应异常: ${v}`),console.error("AI响应异常:",v)}finally{n.value=!1,p.value=!1}a("callBack",JSON.parse(i))},d=async()=>{await e.nextTick(),m.value&&(m.value.scrollTop=m.value.scrollHeight)};return e.watch(()=>f.value,()=>{d()},{deep:!0}),_({open:r=>{o.value=!0,e.nextTick(()=>{d()})}}),(r,i)=>{const v=$,E=x.ElInput,w=B.ElButton,S=q.ElDialog;return e.openBlock(),e.createBlock(S,{class:"ai-dialog",modelValue:o.value,"onUpdate:modelValue":i[1]||(i[1]=u=>o.value=u),title:"✨ 品种池参数解析AI助手",width:"500px",center:"",draggable:"",overflow:"",modal:!1,"modal-penetrable":!0},{default:e.withCtx(()=>[e.createElementVNode("div",P,[e.createElementVNode("div",{ref_key:"messageListRef",ref:m,class:"message-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(u,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:e.normalizeClass(["message-item",u.role])},[e.createElementVNode("div",L,[e.createVNode(v,{size:32,icon:u.role==="user"?e.unref(h.user_filled_default):e.unref(h.service_default)},null,8,["icon"])]),e.createElementVNode("div",D,[e.createElementVNode("div",K,e.toDisplayString(u.content),1),e.createElementVNode("div",M,e.toDisplayString(u.time),1)])],2))),128)),p.value?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("div",F,[e.createVNode(v,{size:32,icon:e.unref(h.service_default)},null,8,["icon"])]),O])):e.createCommentVNode("",!0)],512),e.createElementVNode("div",U,[e.createVNode(E,{class:"message-input",modelValue:t.value,"onUpdate:modelValue":i[0]||(i[0]=u=>t.value=u),type:"textarea",rows:4,autosize:{minRows:2,maxRows:4},placeholder:"输入您想查询的品种条件...",onKeydown:e.withKeys(e.withModifiers(y,["ctrl"]),["enter"])},null,8,["modelValue","onKeydown"]),e.createElementVNode("div",J,[G,e.createVNode(w,{class:"send-btn",type:"primary",icon:e.unref(h.promotion_default),loading:n.value,onClick:y,round:""},{default:e.withCtx(()=>[e.createTextVNode(" 发送 ")]),_:1},8,["icon","loading"])])])])]),_:1},8,["modelValue"])}}},W=T._export_sfc(Q,[["__scopeId","data-v-3b75cb12"]]),X={install(s){s.component("st-varietyAiHelper",W)}};module.exports=X;
5
+ 帮我查A股科创板下品种转价差上证50并且总市值大于1千万, 按照总市值升序进行排序`}},emits:["callBack"],setup(s,{expose:g,emit:d}){const a=d,p=s,r=e.ref(!1),i=e.ref(!1),m=e.ref(!1),f=e.ref(null),t=e.ref([]),l=e.ref(""),o=e.ref(null),n=e.ref(-1),w=async()=>{const E=l.value.trim();if(!E)return q.ElMessage.warning("请输入消息内容");if(i.value)return;t.value.push({role:"user",time:N.dayjs().format("HH:mm"),content:E}),l.value="",await y();const _={role:"assistant",time:N.dayjs().format("HH:mm"),content:""};t.value.push(_),n.value=t.value.length-1,o.value=_,await y(),i.value=!0,m.value=!0;let v="";try{await L({appId:"9e54d112acfe4531bd1fc4fee8827fef",apiKey:"sk-d995eb26a4334bdeb2ccb4cbfaf51de8",value:E,callback:(V,h)=>{if(V==="message")v+=h,o.value&&(o.value.content=v,y());else if(V==="finish"){m.value=!1,i.value=!1,console.log(v);try{const c=JSON.parse(v);a("callBack",c)}catch{a("callBack",v)}o.value=null,n.value=-1}}})}catch(k){q.ElMessage.error(`AI响应异常: ${k}`),console.error("AI响应异常:",k),n.value!==-1&&(t.value.splice(n.value,1),o.value=null,n.value=-1),t.value.push({role:"assistant",time:N.dayjs().format("HH:mm"),content:"抱歉,AI服务响应异常,请稍后重试。"}),await y(),i.value=!1,m.value=!1}},y=async()=>{await e.nextTick(),f.value&&(f.value.scrollTop=f.value.scrollHeight)};return e.onMounted(()=>{t.value.push({role:"assistant",time:N.dayjs().format("HH:mm"),content:p.defaultMessage})}),e.watch(()=>t.value,()=>{y()},{deep:!0}),g({open:E=>{r.value=!0,e.nextTick(()=>{y()})}}),(E,_)=>{const v=D,k=z.ElInput,B=C.ElButton,V=I.ElDialog;return e.openBlock(),e.createBlock(V,{class:"ai-dialog",modelValue:r.value,"onUpdate:modelValue":_[1]||(_[1]=h=>r.value=h),title:"✨ 品种池参数解析AI助手",width:"500px",center:"",draggable:"",overflow:"",modal:!1,"modal-penetrable":!0},{default:e.withCtx(()=>{var h;return[e.createElementVNode("div",P,[e.createElementVNode("div",{ref_key:"messageListRef",ref:f,class:"message-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,(c,A)=>(e.openBlock(),e.createElementBlock("div",{key:A,class:e.normalizeClass(["message-item",c.role])},[c.content?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",K,[e.createVNode(v,{size:32,icon:c.role==="user"?e.unref(S.user_filled_default):e.unref(S.service_default)},null,8,["icon"])]),e.createElementVNode("div",F,[e.createElementVNode("div",O,e.toDisplayString(c.content),1),e.createElementVNode("div",J,e.toDisplayString(c.time),1)])],64)):e.createCommentVNode("",!0)],2))),128)),m.value&&!((h=o.value)!=null&&h.content)?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("div",X,[e.createVNode(v,{size:32,icon:e.unref(S.service_default)},null,8,["icon"])]),G])):e.createCommentVNode("",!0)],512),e.createElementVNode("div",Q,[e.createVNode(k,{class:"message-input",modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=c=>l.value=c),type:"textarea",rows:4,autosize:{minRows:2,maxRows:4},placeholder:"输入您想查询的品种条件...",onKeydown:e.withKeys(e.withModifiers(w,["ctrl"]),["enter"])},null,8,["modelValue","onKeydown"]),e.createElementVNode("div",W,[Y,e.createVNode(B,{class:"send-btn",type:"primary",icon:e.unref(S.promotion_default),loading:i.value,onClick:w,round:""},{default:e.withCtx(()=>[e.createTextVNode(" 发送 ")]),_:1},8,["icon","loading"])])])])]}),_:1},8,["modelValue"])}}},ee=T._export_sfc(Z,[["__scopeId","data-v-46407344"]]),te={install(s){s.component("st-varietyAiHelper",ee)}};module.exports=te;
@@ -1,14 +1,14 @@
1
- import { b as j, p as H, e as M, u as D, c as O, n as U, _ as F, w as J } from "./base-29f73b05.js";
2
- import { E as q } from "./el-dialog-eedcfd3e.js";
1
+ import { b as F, p as P, e as q, u as X, c as G, n as Q, _ as W, w as Y } from "./base-29f73b05.js";
2
+ import { E as Z } from "./el-dialog-eedcfd3e.js";
3
3
  import "./el-overlay-1ee0338d.js";
4
- import { E as G } from "./el-button-e2c63c08.js";
5
- import { E as Q } from "./el-input-d47281da.js";
6
- import { defineComponent as N, ref as d, computed as S, watch as C, openBlock as p, createElementBlock as w, normalizeClass as $, unref as u, normalizeStyle as x, createBlock as k, withCtx as T, resolveDynamicComponent as W, renderSlot as X, nextTick as I, createElementVNode as t, Fragment as Y, renderList as Z, createVNode as b, toDisplayString as z, createCommentVNode as ee, withKeys as te, withModifiers as se, createTextVNode as ae, pushScopeId as oe, popScopeId as ne } from "vue";
7
- import { d as E } from "./dayjs.min-8313b006.js";
8
- import { E as re, u as ie, s as V, p as le } from "./index-c2b9bbfd.js";
9
- import { _ as ce } from "./_plugin-vue_export-helper-dad06003.js";
10
- import { E as B } from "./index-f30561d3.js";
11
- import { k as pe, i as ue } from "./use-form-common-props-cb0ca65c.js";
4
+ import { E as ee } from "./el-button-e2c63c08.js";
5
+ import { E as te } from "./el-input-d47281da.js";
6
+ import { defineComponent as j, ref as u, computed as z, watch as D, openBlock as p, createElementBlock as w, normalizeClass as O, unref as h, normalizeStyle as N, createBlock as T, withCtx as V, resolveDynamicComponent as se, renderSlot as ae, onMounted as oe, nextTick as C, createElementVNode as t, Fragment as M, renderList as ne, createVNode as I, toDisplayString as R, createCommentVNode as L, withKeys as re, withModifiers as ie, createTextVNode as le, pushScopeId as ce, popScopeId as ue } from "vue";
7
+ import { d as x } from "./dayjs.min-8313b006.js";
8
+ import { E as pe, u as de, s as $, p as me } from "./index-c2b9bbfd.js";
9
+ import { _ as ve } from "./_plugin-vue_export-helper-dad06003.js";
10
+ import { E as K } from "./index-f30561d3.js";
11
+ import { k as fe, i as _e } from "./use-form-common-props-cb0ca65c.js";
12
12
  import "./index-0f79095c.js";
13
13
  import "./index-8391a3df.js";
14
14
  import "./index-de24705f.js";
@@ -21,12 +21,12 @@ import "./index-657047bb.js";
21
21
  import "./typescript-7ae59c4c.js";
22
22
  import "./index-c71e37dc.js";
23
23
  import "./config-provider-7860903c.js";
24
- const me = j({
24
+ const he = F({
25
25
  size: {
26
26
  type: [Number, String],
27
- values: pe,
27
+ values: fe,
28
28
  default: "",
29
- validator: (a) => H(a)
29
+ validator: (s) => P(s)
30
30
  },
31
31
  shape: {
32
32
  type: String,
@@ -34,7 +34,7 @@ const me = j({
34
34
  default: "circle"
35
35
  },
36
36
  icon: {
37
- type: ue
37
+ type: _e
38
38
  },
39
39
  src: {
40
40
  type: String,
@@ -43,149 +43,191 @@ const me = j({
43
43
  alt: String,
44
44
  srcSet: String,
45
45
  fit: {
46
- type: M(String),
46
+ type: q(String),
47
47
  default: "cover"
48
48
  }
49
- }), de = {
50
- error: (a) => a instanceof Event
51
- }, fe = N({
49
+ }), ye = {
50
+ error: (s) => s instanceof Event
51
+ }, ge = j({
52
52
  name: "ElAvatar"
53
- }), ve = /* @__PURE__ */ N({
54
- ...fe,
55
- props: me,
56
- emits: de,
57
- setup(a, { emit: h }) {
58
- const i = a, o = D("avatar"), s = d(!1), n = S(() => {
59
- const { size: e, icon: g, shape: m } = i, r = [o.b()];
60
- return O(e) && r.push(o.m(e)), g && r.push(o.m("icon")), m && r.push(o.m(m)), r;
61
- }), f = S(() => {
62
- const { size: e } = i;
63
- return H(e) ? o.cssVarBlock({
64
- size: U(e) || ""
53
+ }), Se = /* @__PURE__ */ j({
54
+ ...ge,
55
+ props: he,
56
+ emits: ye,
57
+ setup(s, { emit: b }) {
58
+ const d = s, a = X("avatar"), m = u(!1), r = z(() => {
59
+ const { size: e, icon: i, shape: o } = d, n = [a.b()];
60
+ return G(e) && n.push(a.m(e)), i && n.push(a.m("icon")), o && n.push(a.m(o)), n;
61
+ }), c = z(() => {
62
+ const { size: e } = d;
63
+ return P(e) ? a.cssVarBlock({
64
+ size: Q(e) || ""
65
65
  }) : void 0;
66
- }), v = S(() => ({
67
- objectFit: i.fit
66
+ }), v = z(() => ({
67
+ objectFit: d.fit
68
68
  }));
69
- C(() => i.src, () => s.value = !1);
70
- function _(e) {
71
- s.value = !0, h("error", e);
69
+ D(() => d.src, () => m.value = !1);
70
+ function f(e) {
71
+ m.value = !0, b("error", e);
72
72
  }
73
- return (e, g) => (p(), w("span", {
74
- class: $(u(n)),
75
- style: x(u(f))
73
+ return (e, i) => (p(), w("span", {
74
+ class: O(h(r)),
75
+ style: N(h(c))
76
76
  }, [
77
- (e.src || e.srcSet) && !s.value ? (p(), w("img", {
77
+ (e.src || e.srcSet) && !m.value ? (p(), w("img", {
78
78
  key: 0,
79
79
  src: e.src,
80
80
  alt: e.alt,
81
81
  srcset: e.srcSet,
82
- style: x(u(v)),
83
- onError: _
84
- }, null, 44, ["src", "alt", "srcset"])) : e.icon ? (p(), k(u(re), { key: 1 }, {
85
- default: T(() => [
86
- (p(), k(W(e.icon)))
82
+ style: N(h(v)),
83
+ onError: f
84
+ }, null, 44, ["src", "alt", "srcset"])) : e.icon ? (p(), T(h(pe), { key: 1 }, {
85
+ default: V(() => [
86
+ (p(), T(se(e.icon)))
87
87
  ]),
88
88
  _: 1
89
- })) : X(e.$slots, "default", { key: 2 })
89
+ })) : ae(e.$slots, "default", { key: 2 })
90
90
  ], 6));
91
91
  }
92
92
  });
93
- var _e = /* @__PURE__ */ F(ve, [["__file", "avatar.vue"]]);
94
- const ye = J(_e);
95
- const he = async ({ appId: a, apiKey: h, value: i }) => {
96
- var o;
93
+ var we = /* @__PURE__ */ W(Se, [["__file", "avatar.vue"]]);
94
+ const be = Y(we);
95
+ const Ee = async ({ appId: s, apiKey: b, value: d, callback: a }) => {
96
+ var m;
97
97
  try {
98
- const s = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${a}/completion`, {
98
+ const r = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${s}/completion`, {
99
99
  method: "POST",
100
- headers: {
101
- Authorization: `Bearer ${h}`,
102
- "Content-Type": "application/json"
103
- },
104
100
  body: JSON.stringify({
105
- input: { prompt: i },
101
+ input: { prompt: d },
106
102
  parameters: {
107
- incremental_output: !1
108
- // 非流式
109
- }
110
- })
103
+ incremental_output: "true"
104
+ // 流式返回
105
+ },
106
+ debug: {}
107
+ }),
108
+ headers: {
109
+ Authorization: `Bearer ${b}`,
110
+ "Content-Type": "application/json",
111
+ "X-DashScope-SSE": "enable"
112
+ // 流式输出
113
+ }
111
114
  });
112
- if (!s.ok)
113
- throw new Error(`HTTP ${s.status}: ${s.statusText}`);
114
- const n = await s.json();
115
- return (o = n == null ? void 0 : n.output) == null ? void 0 : o.text;
116
- } catch (s) {
117
- throw s.name === "AbortError" ? new Error("请求超时") : s;
115
+ if (!r.ok || !r.body)
116
+ throw new Error("请求失败");
117
+ const c = r.body.getReader(), v = new TextDecoder();
118
+ for (; ; ) {
119
+ const { done: f, value: e } = await c.read();
120
+ if (f && a) {
121
+ a("finish", "");
122
+ break;
123
+ }
124
+ try {
125
+ const i = v.decode(e, { stream: !0 }), o = JSON.parse(i.split(`
126
+ `)[3].substr(5)), n = (m = o == null ? void 0 : o.output) == null ? void 0 : m.text;
127
+ n && a && a("message", n);
128
+ } catch {
129
+ }
130
+ }
131
+ } catch (r) {
132
+ console.error(r);
118
133
  }
119
134
  };
120
- const L = (a) => (oe("data-v-3b75cb12"), a = a(), ne(), a), ge = { class: "chat-container" }, we = { class: "avatar" }, be = { class: "message-content" }, Se = { class: "message-text" }, Ee = { class: "message-time" }, ke = {
135
+ const J = (s) => (ce("data-v-46407344"), s = s(), ue(), s), ke = { class: "chat-container" }, Ae = { class: "avatar" }, Ie = { class: "message-content" }, xe = { class: "message-text" }, ze = { class: "message-time" }, Te = {
121
136
  key: 0,
122
137
  class: "message-item assistant"
123
- }, Te = { class: "avatar" }, Ae = /* @__PURE__ */ L(() => /* @__PURE__ */ t("div", { class: "message-content" }, [
138
+ }, Ve = { class: "avatar" }, Be = /* @__PURE__ */ J(() => /* @__PURE__ */ t("div", { class: "message-content" }, [
124
139
  /* @__PURE__ */ t("div", { class: "typing-indicator" }, [
125
140
  /* @__PURE__ */ t("span"),
126
141
  /* @__PURE__ */ t("span"),
127
142
  /* @__PURE__ */ t("span")
128
143
  ])
129
- ], -1)), xe = { class: "input-area" }, Ie = { class: "input-actions" }, ze = /* @__PURE__ */ L(() => /* @__PURE__ */ t("div", { class: "input-hint" }, [
144
+ ], -1)), He = { class: "input-area" }, Ne = { class: "input-actions" }, Ce = /* @__PURE__ */ J(() => /* @__PURE__ */ t("div", { class: "input-hint" }, [
130
145
  /* @__PURE__ */ t("span", null, "Ctrl + Enter 发送")
131
- ], -1)), Ve = {
146
+ ], -1)), Me = {
132
147
  __name: "index",
133
- emits: ["callBack"],
134
- setup(a, { expose: h, emit: i }) {
135
- const o = i, s = d(!1), n = d(!1), f = d(!1), v = d(null), _ = d([
136
- {
137
- role: "assistant",
138
- time: E().format("HH:mm"),
139
- content: `你好呀!我是你的品种池AI助手,会根据您的自然语言去进行品种的条件查询
148
+ props: {
149
+ defaultMessage: {
150
+ type: String,
151
+ default: `你好呀!我是你的品种池AI助手,会根据您的自然语言去进行品种的条件查询
140
152
 
141
153
  示例:
142
- 帮我查找A股,总市值1000亿,流通股本大于等于1000万`
143
- }
144
- ]), e = d(""), g = async () => {
145
- const r = e.value.trim();
146
- if (!r)
147
- return B.warning("请输入消息内容");
148
- if (n.value)
154
+ 帮我查A股科创板下品种转价差上证50并且总市值大于1千万, 按照总市值升序进行排序`
155
+ }
156
+ },
157
+ emits: ["callBack"],
158
+ setup(s, { expose: b, emit: d }) {
159
+ const a = d, m = s, r = u(!1), c = u(!1), v = u(!1), f = u(null), e = u([]), i = u(""), o = u(null), n = u(-1), B = async () => {
160
+ const E = i.value.trim();
161
+ if (!E)
162
+ return K.warning("请输入消息内容");
163
+ if (c.value)
149
164
  return;
150
- _.value.push({
165
+ e.value.push({
151
166
  role: "user",
152
- time: E().format("HH:mm"),
153
- content: r
154
- }), e.value = "", await m(), n.value = !0, f.value = !0;
155
- let l = "{}";
167
+ time: x().format("HH:mm"),
168
+ content: E
169
+ }), i.value = "", await g();
170
+ const y = {
171
+ role: "assistant",
172
+ time: x().format("HH:mm"),
173
+ content: ""
174
+ };
175
+ e.value.push(y), n.value = e.value.length - 1, o.value = y, await g(), c.value = !0, v.value = !0;
176
+ let _ = "";
156
177
  try {
157
- l = await he({ appId: "9e54d112acfe4531bd1fc4fee8827fef", apiKey: "sk-d995eb26a4334bdeb2ccb4cbfaf51de8", value: r }), _.value.push({
178
+ await Ee({
179
+ appId: "9e54d112acfe4531bd1fc4fee8827fef",
180
+ apiKey: "sk-d995eb26a4334bdeb2ccb4cbfaf51de8",
181
+ value: E,
182
+ callback: (A, S) => {
183
+ if (A === "message")
184
+ _ += S, o.value && (o.value.content = _, g());
185
+ else if (A === "finish") {
186
+ v.value = !1, c.value = !1, console.log(_);
187
+ try {
188
+ const l = JSON.parse(_);
189
+ a("callBack", l);
190
+ } catch {
191
+ a("callBack", _);
192
+ }
193
+ o.value = null, n.value = -1;
194
+ }
195
+ }
196
+ });
197
+ } catch (k) {
198
+ K.error(`AI响应异常: ${k}`), console.error("AI响应异常:", k), n.value !== -1 && (e.value.splice(n.value, 1), o.value = null, n.value = -1), e.value.push({
158
199
  role: "assistant",
159
- time: E().format("HH:mm"),
160
- content: l
161
- }), await m();
162
- } catch (y) {
163
- B.error(`AI响应异常: ${y}`), console.error("AI响应异常:", y);
164
- } finally {
165
- n.value = !1, f.value = !1;
200
+ time: x().format("HH:mm"),
201
+ content: "抱歉,AI服务响应异常,请稍后重试。"
202
+ }), await g(), c.value = !1, v.value = !1;
166
203
  }
167
- o("callBack", JSON.parse(l));
168
- }, m = async () => {
169
- await I(), v.value && (v.value.scrollTop = v.value.scrollHeight);
204
+ }, g = async () => {
205
+ await C(), f.value && (f.value.scrollTop = f.value.scrollHeight);
170
206
  };
171
- return C(
172
- () => _.value,
207
+ return oe(() => {
208
+ e.value.push({
209
+ role: "assistant",
210
+ time: x().format("HH:mm"),
211
+ content: m.defaultMessage
212
+ });
213
+ }), D(
214
+ () => e.value,
173
215
  () => {
174
- m();
216
+ g();
175
217
  },
176
218
  { deep: !0 }
177
- ), h({
178
- open: (r) => {
179
- s.value = !0, I(() => {
180
- m();
219
+ ), b({
220
+ open: (E) => {
221
+ r.value = !0, C(() => {
222
+ g();
181
223
  });
182
224
  }
183
- }), (r, l) => {
184
- const y = ye, A = Q, P = G, K = q;
185
- return p(), k(K, {
225
+ }), (E, y) => {
226
+ const _ = be, k = te, H = ee, A = Z;
227
+ return p(), T(A, {
186
228
  class: "ai-dialog",
187
- modelValue: s.value,
188
- "onUpdate:modelValue": l[1] || (l[1] = (c) => s.value = c),
229
+ modelValue: r.value,
230
+ "onUpdate:modelValue": y[1] || (y[1] = (S) => r.value = S),
189
231
  title: "✨ 品种池参数解析AI助手",
190
232
  width: "500px",
191
233
  center: "",
@@ -194,77 +236,82 @@ const L = (a) => (oe("data-v-3b75cb12"), a = a(), ne(), a), ge = { class: "chat-
194
236
  modal: !1,
195
237
  "modal-penetrable": !0
196
238
  }, {
197
- default: T(() => [
198
- t("div", ge, [
199
- t("div", {
200
- ref_key: "messageListRef",
201
- ref: v,
202
- class: "message-list"
203
- }, [
204
- (p(!0), w(Y, null, Z(_.value, (c, R) => (p(), w("div", {
205
- key: R,
206
- class: $(["message-item", c.role])
239
+ default: V(() => {
240
+ var S;
241
+ return [
242
+ t("div", ke, [
243
+ t("div", {
244
+ ref_key: "messageListRef",
245
+ ref: f,
246
+ class: "message-list"
207
247
  }, [
208
- t("div", we, [
209
- b(y, {
210
- size: 32,
211
- icon: c.role === "user" ? u(ie) : u(V)
212
- }, null, 8, ["icon"])
213
- ]),
214
- t("div", be, [
215
- t("div", Se, z(c.content), 1),
216
- t("div", Ee, z(c.time), 1)
217
- ])
218
- ], 2))), 128)),
219
- f.value ? (p(), w("div", ke, [
220
- t("div", Te, [
221
- b(y, {
222
- size: 32,
223
- icon: u(V)
224
- }, null, 8, ["icon"])
225
- ]),
226
- Ae
227
- ])) : ee("", !0)
228
- ], 512),
229
- t("div", xe, [
230
- b(A, {
231
- class: "message-input",
232
- modelValue: e.value,
233
- "onUpdate:modelValue": l[0] || (l[0] = (c) => e.value = c),
234
- type: "textarea",
235
- rows: 4,
236
- autosize: { minRows: 2, maxRows: 4 },
237
- placeholder: "输入您想查询的品种条件...",
238
- onKeydown: te(se(g, ["ctrl"]), ["enter"])
239
- }, null, 8, ["modelValue", "onKeydown"]),
240
- t("div", Ie, [
241
- ze,
242
- b(P, {
243
- class: "send-btn",
244
- type: "primary",
245
- icon: u(le),
246
- loading: n.value,
247
- onClick: g,
248
- round: ""
249
- }, {
250
- default: T(() => [
251
- ae(" 发送 ")
248
+ (p(!0), w(M, null, ne(e.value, (l, U) => (p(), w("div", {
249
+ key: U,
250
+ class: O(["message-item", l.role])
251
+ }, [
252
+ l.content ? (p(), w(M, { key: 0 }, [
253
+ t("div", Ae, [
254
+ I(_, {
255
+ size: 32,
256
+ icon: l.role === "user" ? h(de) : h($)
257
+ }, null, 8, ["icon"])
258
+ ]),
259
+ t("div", Ie, [
260
+ t("div", xe, R(l.content), 1),
261
+ t("div", ze, R(l.time), 1)
262
+ ])
263
+ ], 64)) : L("", !0)
264
+ ], 2))), 128)),
265
+ v.value && !((S = o.value) != null && S.content) ? (p(), w("div", Te, [
266
+ t("div", Ve, [
267
+ I(_, {
268
+ size: 32,
269
+ icon: h($)
270
+ }, null, 8, ["icon"])
252
271
  ]),
253
- _: 1
254
- }, 8, ["icon", "loading"])
272
+ Be
273
+ ])) : L("", !0)
274
+ ], 512),
275
+ t("div", He, [
276
+ I(k, {
277
+ class: "message-input",
278
+ modelValue: i.value,
279
+ "onUpdate:modelValue": y[0] || (y[0] = (l) => i.value = l),
280
+ type: "textarea",
281
+ rows: 4,
282
+ autosize: { minRows: 2, maxRows: 4 },
283
+ placeholder: "输入您想查询的品种条件...",
284
+ onKeydown: re(ie(B, ["ctrl"]), ["enter"])
285
+ }, null, 8, ["modelValue", "onKeydown"]),
286
+ t("div", Ne, [
287
+ Ce,
288
+ I(H, {
289
+ class: "send-btn",
290
+ type: "primary",
291
+ icon: h(me),
292
+ loading: c.value,
293
+ onClick: B,
294
+ round: ""
295
+ }, {
296
+ default: V(() => [
297
+ le(" 发送 ")
298
+ ]),
299
+ _: 1
300
+ }, 8, ["icon", "loading"])
301
+ ])
255
302
  ])
256
303
  ])
257
- ])
258
- ]),
304
+ ];
305
+ }),
259
306
  _: 1
260
307
  }, 8, ["modelValue"]);
261
308
  };
262
309
  }
263
- }, Be = /* @__PURE__ */ ce(Ve, [["__scopeId", "data-v-3b75cb12"]]), tt = {
264
- install(a) {
265
- a.component("st-varietyAiHelper", Be);
310
+ }, Re = /* @__PURE__ */ ve(Me, [["__scopeId", "data-v-46407344"]]), rt = {
311
+ install(s) {
312
+ s.component("st-varietyAiHelper", Re);
266
313
  }
267
314
  };
268
315
  export {
269
- tt as default
316
+ rt as default
270
317
  };
package/es/aiTools.js CHANGED
@@ -1,11 +1,4 @@
1
- /**
2
- * 发送非流式请求到百炼 AI 应用
3
- * @param {Object} options
4
- * @param {string} options.appId - 应用ID
5
- * @param {string} options.apiKey - API Key
6
- * @param {string} options.value - 用户输入
7
- * @returns {Promise<string>} 返回 AI 输出的完整文本(JSON 字符串)
8
- */
1
+ // 非流式返回
9
2
  export const sendToBaiLianAppNonStreaming = async ({ appId, apiKey, value }) => {
10
3
  try {
11
4
  const response = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${appId}/completion`, {
@@ -34,3 +27,43 @@ export const sendToBaiLianAppNonStreaming = async ({ appId, apiKey, value }) =>
34
27
  throw error;
35
28
  }
36
29
  };
30
+ // 流式返回
31
+ export const sendToBaiLianAppStreaming = async ({ appId, apiKey, value, callback }) => {
32
+ try {
33
+ const res = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${appId}/completion`, {
34
+ method: "POST",
35
+ body: JSON.stringify({
36
+ input: { prompt: value },
37
+ parameters: {
38
+ incremental_output: "true", // 流式返回
39
+ },
40
+ debug: {},
41
+ }),
42
+ headers: {
43
+ Authorization: `Bearer ${apiKey}`,
44
+ "Content-Type": "application/json",
45
+ "X-DashScope-SSE": "enable", // 流式输出
46
+ },
47
+ });
48
+ if (!res.ok || !res.body) throw new Error("请求失败");
49
+
50
+ const reader = res.body.getReader();
51
+ const decoder = new TextDecoder();
52
+
53
+ while (true) {
54
+ const { done, value } = await reader.read();
55
+ if (done && callback) {
56
+ callback("finish", "");
57
+ break;
58
+ }
59
+ try {
60
+ const data = decoder.decode(value, { stream: true });
61
+ const resData = JSON.parse(data.split("\n")[3].substr(5));
62
+ const resText = resData?.output?.text;
63
+ if (resText && callback) callback("message", resText);
64
+ } catch (error) {}
65
+ }
66
+ } catch (error) {
67
+ console.error(error);
68
+ }
69
+ };