1234567891011121314151617181920212223242526272829 |
- import { Component,OnInit } from '@angular/core';
- import { AlertController } from '@ionic/angular';
- // 引用FmodeChatCompletion类
- import { TestChatCompletion, TestChatMessage } from './class-chat-completion';
- @Component({
- selector: 'app-tab2',
- templateUrl: './tab2.page.html',
- styleUrls: ['./tab2.page.scss'],
- })
- export class Tab2Page implements OnInit {
- messages: { sender: string, text: string }[] = [];
- newMessage: string = '';
- messageList:Array<TestChatMessage> = []
- userInput:string = ""
- completion:TestChatCompletion
- constructor(private alertController: AlertController) {this.completion = new TestChatCompletion(this.messageList)}
- ngOnInit() {}
- //ai对话
- sendMessage(){
- this.messageList.push({
- role:"user",
- content: this.userInput
- })
- this.userInput = ""
- this.completion.createCompletionByStream()
- }
- }
|