[feat] peer characters
This commit is contained in:
@@ -21,6 +21,7 @@ import { additionalInformations } from "./embedding/addinfo";
|
|||||||
import { cipherChat, decipherChat } from "./cipherChat";
|
import { cipherChat, decipherChat } from "./cipherChat";
|
||||||
import { getInlayImage, supportsInlayImage } from "../image";
|
import { getInlayImage, supportsInlayImage } from "../image";
|
||||||
import { getGenerationModelString } from "./models/modelString";
|
import { getGenerationModelString } from "./models/modelString";
|
||||||
|
import { sendPeerChar } from "../sync/multiuser";
|
||||||
|
|
||||||
export interface OpenAIChat{
|
export interface OpenAIChat{
|
||||||
role: 'system'|'user'|'assistant'|'function'
|
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){
|
||||||
if(req.special.emotion){
|
if(req.special.emotion){
|
||||||
let charemotions = get(CharEmotion)
|
let charemotions = get(CharEmotion)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ async function importPeerJS(){
|
|||||||
let conn:DataConnection
|
let conn:DataConnection
|
||||||
let peer:Peer
|
let peer:Peer
|
||||||
let connections:DataConnection[] = []
|
let connections:DataConnection[] = []
|
||||||
|
let connectionOpen = false
|
||||||
|
|
||||||
export async function createMultiuserRoom(){
|
export async function createMultiuserRoom(){
|
||||||
//create a room with webrtc
|
//create a room with webrtc
|
||||||
@@ -69,7 +70,7 @@ export async function createMultiuserRoom(){
|
|||||||
await sleep(100)
|
await sleep(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectionOpen = true
|
||||||
alertNormal("Room ID: " + roomId)
|
alertNormal("Room ID: " + roomId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -98,9 +99,10 @@ export async function joinMultiuserRoom(){
|
|||||||
alertWait("Waiting for peerserver to connect...")
|
alertWait("Waiting for peerserver to connect...")
|
||||||
|
|
||||||
let open = false
|
let open = false
|
||||||
|
conn = peer.connect(roomId);
|
||||||
|
|
||||||
conn.on('open', function() {
|
conn.on('open', function() {
|
||||||
alertWait("Waiting for host to accept connection")
|
alertWait("Waiting for host to accept connection")
|
||||||
conn = peer.connect(roomId);
|
|
||||||
open = true
|
open = true
|
||||||
conn.send({
|
conn.send({
|
||||||
type: 'request-char'
|
type: 'request-char'
|
||||||
@@ -142,6 +144,7 @@ export async function joinMultiuserRoom(){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
connectionOpen = true
|
||||||
alertNormal("Connected")
|
alertNormal("Connected")
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -149,6 +152,9 @@ export async function joinMultiuserRoom(){
|
|||||||
|
|
||||||
|
|
||||||
export function sendPeerChar(){
|
export function sendPeerChar(){
|
||||||
|
if(!connectionOpen){
|
||||||
|
return
|
||||||
|
}
|
||||||
if(!conn){
|
if(!conn){
|
||||||
// host user
|
// host user
|
||||||
for(const connection of connections){
|
for(const connection of connections){
|
||||||
|
|||||||
Reference in New Issue
Block a user