liyongli před 2 roky
rodič
revize
b8bb0c8f8a
3 změnil soubory, kde provedl 30 přidání a 7 odebrání
  1. 9 0
      src/api/chatGpt.js
  2. 11 3
      src/config/index.js
  3. 10 4
      src/view/chatGptChat/index.vue

+ 9 - 0
src/api/chatGpt.js

@@ -0,0 +1,9 @@
+import ajax from '@/utils/request.js';
+export function ChartGpt(data) {
+  return ajax({
+    url: 'completions',
+    method: 'POST',
+    urlType: 'chat',
+    data,
+  });
+}

+ 11 - 3
src/config/index.js

@@ -1,9 +1,17 @@
-export default {
-  base: {
+const base = {
     ajax: "https://topic.smcic.net/operate/world-cup/",
 	// slikRoad: "http://172.17.17.201:9000/operate/",
 	slikRoad: "https://topic.smcic.net/operate/",
     authorization: "https://bytedance.sxtvs.net/",
+    chat:"http://8.210.89.70/",
     default: ""
-  },
+}
+
+if(process.env.VUE_APP_ENV==="Dev"){
+    base.chat= "http://192.168.255.30"
+}
+
+
+export default {
+  base,
 };

+ 10 - 4
src/view/chatGptChat/index.vue

@@ -5,9 +5,7 @@
       <div class="cahtText">你好!</div>
     </div>
     <div class="chat chatRight">
-      <div class="cahtText">
-        你好!
-      </div>
+      <div class="cahtText">你好!</div>
       <van-image width="35px" height="35px" fit="contain" :src="user" />
     </div>
     <van-field
@@ -30,6 +28,8 @@
 import robot from '../../assets/img/chat/robot_2.png';
 import user from '../../assets/img/chat/user.png';
 import { ref } from 'vue';
+
+import { ChartGpt } from '@/api/chatGpt';
 // import { onMounted, reactive } from "vue";
 // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
 /**
@@ -40,7 +40,13 @@ import { ref } from 'vue';
 console.log(window.$originData);
 const inputText = ref('');
 function saveText() {
+  if (!inputText.value) return;
   console.log(inputText.value);
+  ChartGpt({
+    prompt: inputText.value,
+  }).then(r => {
+    console.log(r);
+  });
 }
 </script>
 <style lang="scss">
@@ -60,7 +66,7 @@ function saveText() {
     left: 0;
     .van-field__control {
       background-color: #ffffff;
-      padding: .4em;
+      padding: 0.4em;
     }
   }