This commit is contained in:
2025-07-22 16:43:10 +08:00
parent a90dce06f3
commit 52bae0735f
36 changed files with 10224 additions and 1658 deletions
+40
View File
@@ -0,0 +1,40 @@
import { _decorator, Component, EditBox, Node } from "cc";
import { DemoManager } from "./DemoManager";
import { ChatGPTService } from "./ChatGPTService";
const { ccclass, property } = _decorator;
@ccclass("ChatPanel")
export class ChatPanel extends Component {
manager: DemoManager = null;
@property(EditBox)
editBox: EditBox = null;
protected onEnable(): void {
if (!this.manager) this.manager = DemoManager.getInstance();
}
public async OnClickSend() {
const str = this.editBox.string;
if (!str || str == "") return;
console.log("post:" + str);
this.editBox.string = "";
DemoManager.getInstance().updateDialog(true, str);
let ret = await ChatGPTService.getInstance().Post({
model: "llama3.1:8b",
messages: [{ role: "user", content: str }],
temperature: 0.8,
});
const rep = ret.choices[0].message.content;
if (rep == null) {
console.warn("rep null");
}
if (this.manager) {
this.manager.updateDialog(false, rep);
}
console.log("ret:" + rep);
}
}