main
2 1 year ago
parent 05932c110f
commit 143c787fc5
  1. 38
      src/pages/lingyunge/demo.vue

@ -1,7 +1,7 @@
<template>
<view class="pdd">
<div class="text">
{{ text }}
{{ history }}
</div>
<input type="text" v-model="value" />
<button @click="queryClick">点击发送</button>
@ -16,9 +16,9 @@ export default {
return {
text: "",
value: "",
messages: [],
};
},
computed: {},
onShow() {},
/**
@ -36,8 +36,20 @@ export default {
return result;
}
*/
computed: {
history() {
return this.messages.filter(
(msg) => msg.message !== "Hi there! How can I help?"
);
},
},
methods: {
async query(data) {
async query() {
const _this = this;
const data = {
question: _this.value,
history: _this.history,
};
axios
.post(`/api/v1/prediction/cf4f7471-7301-4bd6-aaa3-87c16e615b84`, data, {
headers: {
@ -47,16 +59,22 @@ export default {
},
})
.then((response) => {
console.log(response.data.text);
// {
// "message": "Hello, how can I assist you?",
// "type": "apiMessage" | "userMessage"
// },
this.messages.push({
message: this.value,
type: "userMessage",
});
this.messages.push({
message: response.data.text,
type: "apiMessage",
});
});
},
queryClick() {
const _this = this;
this.query({
question: _this.value,
}).then((response) => {
console.log(response);
});
this.query();
},
},
};

Loading…
Cancel
Save