update

上级 e523b5ea
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
"preview": "vite preview --port 4173" "preview": "vite preview --port 4173"
}, },
"dependencies": { "dependencies": {
"axios": "^1.4.0",
"guess": "^1.0.2", "guess": "^1.0.2",
"view-ui-plus": "^1.3.9", "view-ui-plus": "^1.3.9",
"vue": "^3.2.37" "vue": "^3.2.37"
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
</div> </div>
</template> </template>
<script> <script>
import axios from 'axios';
const token = 'Bearer ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SjBkQ0k2TkN3aVlYVmtJam9pWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVWlMQ0pzZFNJNklrbHVjME52WkdVaUxDSmxlSEFpT2pFMk9EVTFORGczT1Rrc0luVnlJam95TENKcWRHa2lPaUpCVUVsZlZFOUxSVTVmWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVXROQ0o5LmlyLTJYa1A4dFhNaFVldnlzTFhkUlJsY1VBV0ZiaWE5em9ZdGN6VlpleFk='; const token = 'Bearer ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKSVV6STFOaUo5LmV5SjBkQ0k2TkN3aVlYVmtJam9pWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVWlMQ0pzZFNJNklrbHVjME52WkdVaUxDSmxlSEFpT2pFMk9EVTFORGczT1Rrc0luVnlJam95TENKcWRHa2lPaUpCVUVsZlZFOUxSVTVmWXpkbU16WTVOMlpqTldaak5EVmpNR0l5WldFNE5UVTNaRFkxTnpnM1lXVXROQ0o5LmlyLTJYa1A4dFhNaFVldnlzTFhkUlJsY1VBV0ZiaWE5em9ZdGN6VlpleFk=';
const api = 'https://api.ai100.ai/ai/api/ai/chat'; const api = 'https://api.ai100.ai/ai/api/ai/chat';
...@@ -34,44 +36,41 @@ ...@@ -34,44 +36,41 @@
return { return {
question: '', question: '',
loading: false, loading: false,
dialogs: [ dialogs: []
{
role: 'me',
text: '你好'
},
{
role: 'ai',
text: '你也好'
}
]
} }
}, },
methods: { methods: {
async handleSend () { handleSend () {
if (this.loading || this.question === '') return; if (this.loading || this.question === '') return;
this.loading = true; this.loading = true;
// todo
const response = await fetch(api, this.getParams());
console.log(response)
},
getParams () {
const headers = {
"Accept": "*/*",
"Authorization": token,
"Content-Type": "application/json"
}
const payload = { const question = this.question;
prompt: ' ', this.question = '';
question: this.question,
stream: false
}
return { this.dialogs.push({
method: 'POST', role: 'me',
headers, text: question
body: JSON.stringify(payload) });
}
axios.post(api,
{
prompt: '',
question,
stream: false
},
{
headers: {
Accept: '*/*',
Authorization: token
}
}
)
.then(({ data: res }) => {
console.log(res);
})
.finally(() => {
this.loading = false;
});
}, },
handleNewChat () { handleNewChat () {
this.dialogs = []; this.dialogs = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册