Commit b4ffd1fa by liimin

chatgpt

1 parent eda0ab59
......@@ -140,6 +140,17 @@ const activityPage = params => {
sign: true
})
}
const gpt = async params => {
const response = await fetch('http://192.168.1.134:8090/ai/chat', {
body: JSON.stringify({ content: params }),
headers: {
'content-type': 'application/json'
},
method: 'POST'
})
return response.json()
// return new Http({ request: { timeout: 3000 } }).post('http://192.168.1.134:8090/ai/chat', { data: params })
}
export default {
getCrowdList,
getCrowdDetails,
......@@ -152,5 +163,6 @@ export default {
editCrowdGroup,
deleteCrowdGroup,
queryCrowdGroupDetailsByCrowdGroupId,
activityPage
activityPage,
gpt
}
......@@ -3,7 +3,7 @@
<div class="container" id="container">
<div>
<div class="title">创建人群</div>
<div class="info-box" >
<div class="info-box">
<div class="gl-form-page">
<el-form class="create-form" :model="crowdForm" :rules="crowdRules" ref="crowdForm">
<div class="el-form-line">
......@@ -27,6 +27,22 @@
</el-form-item>
</div>
</el-form>
<el-form ref="orderform" :model="orderform" class="order-form">
<div class="order">
<el-form-item label="输入内容">
<el-input type="textarea" v-model="orderform.order" rows="3" :clearable="true"></el-input>
</el-form-item>
<el-form-item>
<el-button size="small" @click="handleResetOrder">重置</el-button>
<el-button type="primary" size="small" @click="handleOrder">确定</el-button>
</el-form-item>
</div>
<div class="result">
<el-form-item label="解析结果">
<el-input type="textarea" v-model="orderform.result" rows="3"></el-input>
</el-form-item>
</div>
</el-form>
</div>
<div class="label-wrap">
<div :class="{ 'fixed-box': true, is_fixed: isFixed, is_pb: isDom }" id="boxFixed">
......@@ -99,7 +115,7 @@
<span slot="labelUnitList" slot-scope="scope">
<div class="allTagsWrap flex">
<template v-for="(item, index) in scope.scope.labelUnitList">
<span :class="['label', 'color-3', 'white-hide', 'mt10', item.checked ? 'isChecked' : '']" :key="index" @click="selectTag(item, index)">
<span :class="['label', 'color-3', 'white-hide', 'mt10', item.checked ? 'isChecked' : '']" v-if="true" :key="`test_${index}`" @click="selectTag(item, index)">
{{ item.labelName }}
<template v-if="item.checked">
<img src="@/assets/clientDetail/select-icon.png" class="select-icon" alt />
......@@ -153,7 +169,7 @@
<div class="crowd-logic-label-group-name font-14 color-3">{{ logicTag.groupName }}:</div>
<div class="flex">
<template v-for="(tag, id) in logicTag.labelUnitList">
<div class="crowd-logic-tag color-6 font-14" :key="id">{{ tag.labelName }}</div>
<div class="crowd-logic-tag color-6 font-14" v-if="true" :key="id">{{ tag.labelName }}</div>
<template v-if="id < logicTag.labelUnitList.length - 1">
<div class="color-3 perhaps" :key="id">或</div>
</template>
......@@ -182,6 +198,9 @@ export default {
isReload: true,
dialogRuleVisible: false,
dialogLogicVisible: false,
orderform: {
order: ''
},
crowdForm: {
crowdName: '',
crowdDesc: ''
......@@ -242,6 +261,7 @@ export default {
this.getGroupList()
//获取标签列表
this.getLabelList()
// this.searchForm.labelName = '基盘客户'
//获取标签数据
this.getLabelData()
},
......@@ -459,17 +479,20 @@ export default {
'req.labelName': this.searchForm.labelName,
...this.page
}
this.$apis.crowdManage.getLabelTreeList(params).then(res => {
if (res.code == 0) {
res.data.groupUnitList.forEach(item => {
item.labelUnitList.forEach(label => {
label.checked = false
return new Promise((resolve, reject) => {
this.$apis.crowdManage.getLabelTreeList(params).then(res => {
if (res.code == 0) {
;(res.data.groupUnitList || []).forEach(item => {
item.labelUnitList.forEach(label => {
label.checked = false
})
})
})
this.tableData = res.data.groupUnitList
this.tableTotal = res.data.total
this.getHistoryLabel()
}
this.tableData = res.data.groupUnitList || []
this.tableTotal = res.data.total
this.getHistoryLabel()
}
resolve()
})
})
},
//已选择标签状态保存
......@@ -491,7 +514,6 @@ export default {
}
},
//选择标签
selectTag(data) {
this.tableData.forEach(item => {
......@@ -504,7 +526,6 @@ export default {
})
},
// 添加已选标签
selectedLabelFn(groupData, data) {
this.addClick = true
......@@ -597,7 +618,7 @@ export default {
this.getLabelData()
},
//重置表格
resetTable() {
async resetTable() {
this.searchForm = {
groupName: '',
labelName: ''
......@@ -608,7 +629,7 @@ export default {
}
this.$refs.crowdManage.page[this.pageConf.pageSize] = 10
this.$refs.crowdManage.page[this.pageConf.pageNum] = 1
this.getLabelData()
await this.getLabelData()
},
handleCancel() {
this.$router.push(`/crowdManage/index?selectTab=2`)
......@@ -665,6 +686,79 @@ export default {
return str.substr(0, subLen)
}
return str
},
async handleOrder() {
await this.handleResetOrder()
console.log(this.tableData)
const tagsAll = this.tableData.reduce((tags, next) => {
tags += next.labelUnitList.map(({ labelName }) => labelName).join(',')
return tags + ','
}, '')
console.log(tagsAll)
// 取值范围是:"${tagsAll}"输出json格式`
// 帮我创建一个人群名为测试群,描述为test,未加企微的客户。
// 帮我创建一个人群名为名车群,描述为名车车主群。去年和今年3月到4月间购车的奥迪和宝马车主。
// 帮我创建一个人群名为名车群,描述为名车车主群。去年和今年3月到4月间购车的奥迪和宝马有试驾的车主。
// 帮我创建一个人群名为名车群,描述为名车车主群。近两年购车的奥迪和宝马的30岁以下的有保养记录和试驾记录的男性车主。
//,取值范围:"'2020年','2021年','2022年','2023年','2000年','2001年','2002年','2003年'";
//,取值范围:"'1月','2月','3月','4月','5月','6月','7月','8月',9月,10月,11月,12月";
//,取值范围为:"'有','无'"
//取值范围为:"'30岁以下','31-40岁','41-55岁'",
// 提取出购车月份,命名为buyMonth,例如5月,用数组输出;
// tags包括上面的购车年份,命名为buyYear,购车月份,命名为buyMonth,车型,命名为brand,是否保养,命名为maintain
const order = this.orderform.order
// const content = '帮我查询从2023-3-29日至2023-04-05日期间西安飞广州或者深圳的机票,从上面一句话中提取出发日期,命名为date,出发地,命名为start,目的地,命名为end,输出json格式。'
const content = `${order},忽略之前的提问,今年是2023年,针对上面这段文字,
提取出人群名称,命名为crowdName;
提取出人群描述,命名为crowdDesc;
提取出购车年份,命名为buyYear,例如20xx年,用数组输出;
提取品牌,命名为brand,用数组输出;
提取性别,命名为sex,用数组输出;
提取是否有保养记录,命名为maintain,用数组输出;
提取出年龄,命名为age,用数组输出;
提取出试驾记录,命名为drive,用数组输出;
所有提取字段取值范围是:"${tagsAll}"。
所有提取的字段未精确匹配到的不提取和输出。
输出json格式`
const result = await this.$apis.crowdManage.gpt(content)
this.orderform.result = JSON.stringify(result)
const { code, success, message, data } = result
const crowdName = data.crowdName
const crowdDesc = data.crowdDesc
if (code == '000000' && success) {
this.crowdForm = { crowdName, crowdDesc }
let arr = []
for (let k in data) {
let m = data[k]
if (m && m != null) {
if (Array.isArray(m)) {
arr = arr.concat(m)
} else {
arr.push(m)
}
}
}
console.log(arr)
this.handleTags(arr)
} else {
this.$message.error(message)
}
},
handleTags(tags = []) {
tags.forEach(async tag => {
this.searchForm.labelName = tag
await this.getLabelData()
if (this.tableData?.length && this.tableData[0].labelUnitList?.length) {
this.selectTag(this.tableData[0].labelUnitList[0])
}
})
},
async handleResetOrder() {
this.crowdForm = { crowdName: '', crowdDesc: '' }
this.selectedArray = []
this.orderform.result = ''
await this.resetTable()
}
},
destroyed() {
......@@ -893,6 +987,31 @@ export default {
}
}
}
.gl-form-page {
position: relative;
/deep/.order-form {
position: absolute;
top: -30px;
right: 300px;
display: flex;
justify-content: space-between;
flex-direction: column;
width: 500px;
.order {
display: flex;
align-items: end;
.el-form-item {
margin-bottom: 0 !important;
.el-button {
margin-left: 20px;
}
}
}
.el-form-item__label {
width: auto !important;
}
}
}
}
.footer-panel {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!