[feat] peer characters
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user