[feat] peer characters

This commit is contained in:
kwaroran
2023-11-22 19:57:35 +09:00
parent 72540db94f
commit b53e369d7b
2 changed files with 11 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ import { additionalInformations } from "./embedding/addinfo";
import { cipherChat, decipherChat } from "./cipherChat";
import { getInlayImage, supportsInlayImage } from "../image";
import { getGenerationModelString } from "./models/modelString";
import { sendPeerChar } from "../sync/multiuser";
export interface OpenAIChat{
role: 'system'|'user'|'assistant'|'function'
@@ -976,6 +977,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
}
}
sendPeerChar()
if(req.special){
if(req.special.emotion){
let charemotions = get(CharEmotion)

View File

@@ -14,6 +14,7 @@ async function importPeerJS(){
let conn:DataConnection
let peer:Peer
let connections:DataConnection[] = []
let connectionOpen = false
export async function createMultiuserRoom(){
//create a room with webrtc
@@ -69,7 +70,7 @@ export async function createMultiuserRoom(){
await sleep(100)
}
connectionOpen = true
alertNormal("Room ID: " + roomId)
return
}
@@ -98,9 +99,10 @@ export async function joinMultiuserRoom(){
alertWait("Waiting for peerserver to connect...")
let open = false
conn = peer.connect(roomId);
conn.on('open', function() {
alertWait("Waiting for host to accept connection")
conn = peer.connect(roomId);
open = true
conn.send({
type: 'request-char'
@@ -142,6 +144,7 @@ export async function joinMultiuserRoom(){
return
}
}
connectionOpen = true
alertNormal("Connected")
});
@@ -149,6 +152,9 @@ export async function joinMultiuserRoom(){
export function sendPeerChar(){
if(!connectionOpen){
return
}
if(!conn){
// host user
for(const connection of connections){