SanHQin 10 months ago
parent
commit
c133199cd8

+ 1 - 0
src/assets/icon/course/left.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1720597362700" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5331" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><path d="M330.666667 512a35.84 35.84 0 0 0 11.52 26.453333l235.52 220.586667a35.84 35.84 0 1 0 49.066666-52.48L419.413333 512l207.36-194.56a35.84 35.84 0 1 0-49.066666-52.48L341.333333 484.266667a35.84 35.84 0 0 0-10.666666 27.733333zM512 0a512 512 0 1 0 512 512A512 512 0 0 0 512 0z m0 72.106667a439.466667 439.466667 0 0 1 170.666667 844.373333A439.466667 439.466667 0 0 1 200.533333 200.533333a438.613333 438.613333 0 0 1 311.04-128z" fill="#000000" p-id="5332"></path></svg>

+ 1 - 0
src/assets/icon/course/yes.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1720596520120" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4306" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><path d="M511.999994 0C229.205543 0 0.020822 229.226376 0.020822 512.020827c0 282.752797 229.184721 511.979173 511.979173 511.979173s511.979173-229.226376 511.979173-511.979173C1023.979167 229.226376 794.794446 0 511.999994 0zM815.371918 318.95082l-346.651263 461.201969c-10.830249 14.370907-27.32555 23.409999-45.27877 24.742952-1.582882 0.124964-3.12411 0.166619-4.665338 0.166619-16.328682 0-32.074198-6.373185-43.779197-17.911565l-192.903389-189.44604c-24.617988-24.20144-24.992881-63.731847-0.791441-88.349835 24.20144-24.659643 63.731847-24.951226 88.349835-0.833096l142.042875 139.501932 303.788472-404.2182c20.744091-27.575479 59.899605-33.115568 87.516739-12.413131C830.534266 252.219827 836.116009 291.375341 815.371918 318.95082z" fill="#1afa29" p-id="4307"></path></svg>

+ 425 - 14
src/components/classRoomHelper/component/searchArea.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="search">
-    <div class="s_top" ref="chatRef">
+    <div class="s_top" ref="chatRef" v-if="cardType==0">
       <div class="s_t_chat" v-for="(item, index) in chatList" :key="index">
         <div
           class="s_t_c_user"
@@ -29,7 +29,8 @@
           "
         >
           <div class="s_t_c_a_left">
-            <span>Ai</span>
+						<img style="border-radius: 100%;" v-if="item.filename" :src="item.filename">
+            <span v-else>Ai</span>
           </div>
           <div class="s_t_c_a_right">
             <div
@@ -189,7 +190,7 @@
         </div>
       </div>
     </div>
-    <div class="s_bottom">
+    <div class="s_bottom" v-if="cardType==0">
       <div class="s_b_btnAreaTop">
         <div class="s_b_bat_left">
           <el-tooltip
@@ -252,6 +253,15 @@
 					<img src="../../../assets/icon/course/sRio2.png" style="margin-right: 5px;" alt="" v-else> -->
           搜索视频
         </div>
+<!-- 
+				<div class="s_b_ba-item" @click.stop="choiceRole()">
+            <img
+              style="width: 20px;"
+              src="../../../assets/icon/course/role.png"
+              alt=""
+            />
+            选择智能体
+          </div> -->
         <!-- <div class="s_b_ba-item" @click="clear()" v-if="!openAtBox">
           清空聊天记录
         </div>
@@ -581,6 +591,110 @@
         </div>
       </div>
     </div>
+
+		<div class="choiceTopArea" v-if="cardType == 1">
+      <div class="choiceTop">
+        <div class="choiceRoleHeader">
+          <div>切换角色:</div>
+          <span>您希望以下哪个角色回答您的问题,请选择:</span>
+        </div>
+        <div class="choiceSelect">
+          <el-button
+            class="option"
+            :style="{
+              background: sortOption == 0 ? '#36A9FC' : '',
+              color: sortOption == 0 ? '#fff' : ''
+            }"
+            @click="optBtn(0)"
+            plain
+            >我的</el-button
+          >
+          <el-button
+            class="option"
+            :style="{
+              background: sortOption == 1 ? '#36A9FC' : '',
+              color: sortOption == 1 ? '#fff' : ''
+            }"
+            @click="optBtn(1)"
+            plain
+            >社区</el-button
+          >
+        </div>
+        <div
+          class="characterBlock"
+          v-if="sortOption == 0"
+          v-for="(item, index) in roleList"
+          :key="item.id"
+          @click.stop="choseRole(item)"
+        >
+          <div class="imgLeft">
+            <div class="img">
+              <img style="width: 100%;height: 100%;" :src="item.avatar" />
+            </div>
+          </div>
+          <div class="txtRight">
+            <div class="bir">{{ item.assistantName }}</div>
+            <div
+              :style="{
+                color: '#fff',
+                display:
+                  choseRoleItem.assistant_id == item.assistant_id
+                    ? 'block'
+                    : 'none'
+              }"
+            >
+              已选择
+            </div>
+          </div>
+        </div>
+        <div
+          class="characterBlock"
+          v-if="sortOption == 1"
+          v-for="(item, index) in roleList2"
+          :key="item.id"
+          @click.stop="choseRole(item)"
+        >
+          <div class="imgLeft">
+            <div class="img">
+              <img
+                style="width: 100%;height: 100%;"
+                :src="
+                  item.headUrl
+                    ? item.headUrl
+                    : require('../../../assets/icon/course/ai.png')
+                "
+              />
+            </div>
+          </div>
+          <div class="txtRight">
+            <div class="bir">{{ item.assistantName }}</div>
+            <div
+              :style="{
+                color: '#fff',
+                display:
+                  choseRoleItem.assistant_id == item.assistant_id
+                    ? 'block'
+                    : 'none'
+              }"
+            >
+              已选择
+            </div>
+          </div>
+        </div>
+      </div>
+      <div class="choiceBottom">
+        <el-button class="cb_btn" size="mini" @click="noChangeRole()"
+          >取消</el-button
+        >
+        <el-button
+          class="cb_btn"
+          size="mini"
+          type="primary"
+          @click="changeRole()"
+          >确定</el-button
+        >
+      </div>
+    </div>
     <iframe
       allow="camera *; microphone *;display-capture;midi;encrypted-media;"
       src="https://beta.cloud.cocorobo.cn/browser/public/index.html"
@@ -699,7 +813,11 @@ export default {
       tools: JSON.parse(converter(JSON.stringify(tools))),
       aiTalkList: [],
       aiIsTalk: false,
-      aiTalkUid: ""
+      aiTalkUid: "",
+			choseRoleItem: {},
+			cardType:0,
+			roleList:[],
+			sortOption: 0, //切换角色 0我的 1 社区
     };
   },
   computed: {
@@ -990,7 +1108,6 @@ export default {
         loading: true
       });
       this.scrollBottom();
-      console.log(this.sendType);
       if (this.sendType == 2 || _text.indexOf("视频") != -1) {
         return this.ajax
           .post(`https://gpt4.cocorobo.cn/get_network_search`, {
@@ -1021,9 +1138,11 @@ export default {
       } else if (this.sendType == 3) {
         this.text = "";
         let params = {
-          page: this.ppage,
-          pagesize: 1,
-          query: _text
+					n:1,
+					prompt:_text,
+					quality:"standard",
+					size:"1024x1024",
+					style:"natural"
         };
         // this.$message.info(_text);
         this.chatList.push({
@@ -1040,17 +1159,35 @@ export default {
           loading: true
         });
         this.ajax
-          .post("https://gpt.cocorobo.cn/search_image", params)
+          .post("https://gpt4.cocorobo.cn/getImage", params)
           .then(res => {
-            let data = res.data.FunctionResponse.result;
+            let data = res.data.FunctionResponse;
             // console.log('res',res.data.FunctionResponse.result);
-            this.chatList.find(i => i.uid == _uuid).aiContent = JSON.stringify(
-              data
-            );
+						let _result = [];
+						if(!data.image_url_list.length){
+							this.chatLoading = false;
+							this.chatList.pop();
+							this.chatList.pop();
+							return this.$message.error("生成图片失败")
+						}
+						data.image_url_list.forEach(i=>{
+							_result.push({
+								image:i
+							})
+						})
+
+            this.chatList.find(i => i.uid == _uuid).aiContent = JSON.stringify(_result);
             this.chatList.find(i => i.uid == _uuid).loading = false;
+						console.log(this.chatList.find(i => i.uid == _uuid).aiContent)
             this.chatLoading = false;
             this.insertChat(_uuid);
-          });
+						this.scrollBottom();
+          }).catch(e=>{
+						this.chatLoading = false;
+						this.chatList.pop();
+						this.chatList.pop();
+						this.$message.error("生成失败")
+					});
         return;
       } else if (this.sendType == 1 || _text.indexOf("图片") != -1) {
         // console.log("图片");
@@ -1083,6 +1220,8 @@ export default {
             this.chatList.find(i => i.uid == _uuid).aiContent = JSON.stringify(
               data
             );
+						console.log("👇")
+						console.log(this.chatList.find(i => i.uid == _uuid).aiContent)
             this.chatList.find(i => i.uid == _uuid).loading = false;
             this.chatLoading = false;
             this.insertChat(_uuid);
@@ -2448,6 +2587,89 @@ ${_wordData}
         this.aiTalk(0);
       }
 		},
+		choseRole(item) {
+      this.choseRoleItem = item;
+      console.log("选择角色", this.choseRoleItem);
+    },
+    noChangeRole() {
+      this.cardType = 0;
+      this.choseRoleItem = {};
+    },
+		changeRole() {
+      this.cardType = 0;
+      if (this.choseRoleItem.assistant_id) {
+        // this.chatList = [];
+        this.nowChatList = [];
+        let _uuid = uuidv4();
+        this.chatList.push({
+          role: "user",
+          content: `您好,${this.choseRoleItem.assistantName}`,
+          uid: _uuid,
+          AI: "AI",
+          aiContent: this.choseRoleItem.prologue
+            ? this.choseRoleItem.prologue
+            : "您好,有什么需要我帮忙的吗?",
+          oldContent: "",
+          isShowSynchronization: false,
+          filename: this.choseRoleItem.headUrl,
+          index: this.chatList.length,
+          is_mind_map: false,
+          loading: false
+        });
+
+        this.scrollBottom();
+      }
+    },
+		optBtn(val) {
+      this.sortOption = val;
+    },
+		getRoleList() {
+      this.roleList = [];
+      let params = {
+        userId: this.userid
+      };
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/get_ai_agent_assistant_list", params)
+        .then(res => {
+          let _data = res.data.FunctionResponse.result;
+          if (_data.length == 0) return;
+          if (_data) {
+            this.roleList = JSON.parse(_data);
+          }
+        })
+        .catch(e => {
+          console.log("获取角色列表失败");
+          this.roleList = [];
+        });
+    },
+    getPublicRoleList() {
+      this.roleList2 = [];
+      let params = {
+        userId: this.userid,
+        // organizeid: this.org,
+        organizeid: "45facc0a-1211-11ec-80ad-005056b86db5"
+      };
+      this.ajax
+        .post(
+          "https://gpt4.cocorobo.cn/get_ai_agent_assistant_share_list",
+          params
+        )
+        .then(res => {
+          let _data = res.data.FunctionResponse.result;
+          if (_data.length == 0) return;
+          if (_data) {
+            this.roleList2 = JSON.parse(_data);
+          }
+        })
+        .catch(e => {
+          this.roleList2 = [];
+          console.log("获取公共角色失败", e);
+        });
+    },
+		choiceRole() {
+      if (this.loading) return this.$message.info("请稍等");
+      this.cardType = 1;
+    },
   },
   mounted() {
     this.getChatList().then(_ => {
@@ -2458,6 +2680,8 @@ ${_wordData}
     this.sendType = 0;
     this.initTaskList();
     this.getWorkData();
+		this.getPublicRoleList();
+		this.getRoleList();
   }
 };
 </script>
@@ -3253,4 +3477,191 @@ ${_wordData}
   width: 100%;
   height: 100%;
 }
+
+.choiceTopArea{
+	width: 100%;
+	height: 100%
+}
+
+.choiceTop {
+  width: 100%;
+  height: 95%;
+  overflow-x: hidden;
+  box-sizing: border-box;
+  padding: 10px;
+}
+
+.choiceBottom {
+  width: 100%;
+  height: 5%;
+  display: flex;
+  align-items: center;
+  justify-content: flex-end;
+}
+
+.cb_btn {
+  margin: 0 10px;
+}
+
+.choiceRoleHeader {
+  width: 100%;
+  /* margin: 10px; */
+  margin-bottom: 20px;
+}
+
+.choiceRoleHeader > div {
+  font-size: 16px;
+  font-weight: bold;
+}
+
+.choiceRoleHeader > span {
+  font-size: 14px;
+}
+.choiceSelect {
+  width: 100%;
+  display: flex;
+  height: 35px;
+  justify-content: flex-start;
+  align-items: center;
+  margin: 15px 0;
+}
+.choiceSelect > .option {
+  width: 80px;
+  height: 100%;
+  border-radius: 5px;
+  margin-right: 10px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+}
+.filterSubjects {
+  margin: 10px;
+  width: 100%;
+  height: auto;
+}
+
+.fs_box {
+  width: 100%;
+  display: flex;
+  flex-wrap: wrap;
+  margin-top: 10px;
+}
+
+.fs_b_item {
+  width: auto;
+  height: 35px;
+  font-size: 14px;
+  box-sizing: border-box;
+  padding: 0 9px;
+  background-color: #f3f7fd;
+  border: solid 1px #f3f7fd;
+  border-radius: 5px;
+  margin-right: 8px;
+  margin-bottom: 8px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+}
+
+.fs_b_itemActive {
+  border: solid 1px #4d8ffc;
+  color: #4d8ffc;
+  background-color: #f3f7fd;
+}
+
+.roleList {
+  width: 100%;
+  height: auto;
+  margin: 10px;
+}
+
+.r_box {
+  width: 100%;
+  height: auto;
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.r_b_item {
+  height: 40px;
+  font-size: 14px;
+  display: flex;
+  /* justify-content: center; */
+  align-items: center;
+  background-color: #f0f2f5;
+  border-radius: 5px;
+  margin: 5px;
+  cursor: pointer;
+  box-sizing: border-box;
+  padding: 0 4px;
+  border: solid 1px #f0f2f5;
+}
+
+.r_b_itemActive {
+  box-sizing: border-box;
+  border: solid 1px #aeccfe;
+  color: #4d8ffb;
+}
+
+.r_b_item > img {
+  min-width: 24px;
+  min-height: 24px;
+  width: 24px;
+  height: 24px;
+  border-radius: 50%;
+  margin-right: 10px;
+  /* margin-left: 10px; */
+}
+
+.characterBlock {
+  display: flex;
+  background: rgba(54, 169, 252, 1);
+  width: 100%;
+  height: 80px;
+  margin: 0 auto;
+  border-radius: 10px;
+  margin-bottom: 15px;
+  cursor: pointer;
+}
+.characterBlock > .imgLeft {
+  width: 100px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.characterBlock > .imgLeft > .img {
+  width: 60px;
+  height: 60px;
+  overflow: hidden;
+  border-radius: 50%;
+}
+.characterBlock > .imgLeft > .img2 {
+  width: 70px;
+  height: 70px;
+  overflow: hidden;
+  border-radius: 50%;
+}
+.characterBlock > .txtRight {
+  flex: 1;
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+}
+.characterBlock > .txtRight > .bir {
+  width: 180px;
+  height: 35px;
+  display: flex;
+  align-items: center;
+  background-color: #fff;
+  border-radius: 10px;
+  box-sizing: border-box;
+  padding: 5px 10px;
+  box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
+  margin-right: 10px;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
 </style>

File diff suppressed because it is too large
+ 227 - 724
src/components/classRoomHelper/component/taskArea.vue


Some files were not shown because too many files changed in this diff