talemate/talemate_frontend/src/components/AIClient.vue
veguAI d768713630
Prep 0.17.0 (#48)
* improve windows install script to check for compatible python versions, also work with multi version python installs

* bunch of llm prompt templates

* first gamestate directing impl

* lower similarity threshold when checking for repetition in llm responses

* tweaks to narrate after dialog prompt
tweaks to extract character sheet prompt

* set_context cmd

* Xwin MoE

* thematic generator for randomized content stimuli

* add a memory query to extract character sheet

* direct-scene prompt tweaks

* conversation prompt tweaks

* inline character creation from gameplay instruction template
expose thematic generator to prompt templates

* Mixtral
Synthia-MoE

* display prompt and response side by side

* improve ensure_dialogue_format

* prompt tweaks

* prevent double passive narration in one round
improvements to persist character logic

* SlimOrca
OpenBuddy

* prompt tweaks

* runpod status check wrapped in asyncio

* generate_json_list creator agent action

* limit conversation retries to 2
fix issue where REPETITION signal trigger would get sent with the prompt

* smaller agent tweaks

* thematic generator personality list
thematic generator generate from sets of lists

* adjust tests

* mistral prompt adjustment

* director: update content context

* prompt adjustments

* nous-hermes-2-yi
dolphin-2.2-yo
dolphin-2.6-mixtral

* status messages

* determine character goals
generate json lists

* fix error when chromadb add was called before db was ready (wait until the db is fully initiazed)

* only strip extra spaces off of prompt
textgenwebui: half temperature on -yi- models

* prompt tweaks

* more thematic generators

* direct scene without character should just run the scene instructions if they exist

* as_question_answer for query_scene

* context_history revamp

* Aurora-Nights
MixtgralOrochi
dolphin-2.7-mixtral
nous-hermas-2-solar

* remove old context_history calls

* mv world_state.py to subdir
FlatDolphinMaid
Goliath
Norobara
Nous-Capybara

* world state manager first progress

* context db manager

* fix issue with some clients not remembering context length settings after talemate restart

* Sensualize-Solar

* improve RAG prompt

* conversation agent use [ as a stopping string since the new reinforcement messages use that

* new method for RAG during conversation

* mixtral_11bx2_moe

* option to reset context db from manager ui

* fix context db cleanup if scene is closed without saving

* didnt mean to commit that

* hide internal meta tags

* keep track of manual context entries in scene save file so it can be rebuilt.

* auto save
auto progress
quick settings hotbar options

* manual mode
actor dialogue tools
refactor toolbar

* narrate directed progress
reorganiza narration tools into one cmd module

* 0.17.0

* Mixtral_34Bx2
Sensualize-Mixtral
openchat

* fix save-as action

* fix issue where too little context was joined in via RAG

* context pins implementation

* show active pins in world state component

* pin condition eval and world state agent action config

* Open_Gpt4

* summarization prompt improvements
system prompt for summarization

* guidance prompt for time passage narration

* fix rerun for generic / unhandled messages

* prompt fixes

* summarization methods

* prompt adjustments

* world tools to hot bar
ux tweaks

* bagel-dpo

* context state reinforcements support different insertion methods now (sequential, all context or conversation specific context)

* first progress on world state reinforcement templating

* Kunoichi

* tweaks to update reinforcements prompt

* world state templates progress

* world state templates integration into main ux

* fix issue where openai client wouldn't accept context length override

* dont reconfigure client if no arguments are provided

* pin condition prompt fixes
world state apply template comman label set

* world information / lore entries and reinforcement

* show world entry states reinforcers in ux

* gitignore

* dynamic scenario generation progress

* dynamic scenario experiment

* gitignore

* need to emit world state even if we dont run it during scene init

* summarize and pin action

* poetry relock

* template question / attribute cannot be empty

* fix issue with summarize and pin not respecting selected line

* keep reinforcement messages in history, but keep the same one from stacking up

* narrate query prompt more natural sounding response

* manage pins from world entry editor

* pin_only tag

* ts aware summarize and pin
pin text rendered to context with time label
context reuse session id (this fixes issue of editing context entry and not saving the scene causing removal of context entry next time scene is loaded)

* UX to add character state from template within the worldstate manager UX

* move divider

* handle agent emit error
fix issue with state reinforcer validation

* layout fixes in world state character panel
physical health template added to example config

* fix pin_only undefined error in world entry editor

* laser-dolphin
Noromaid-v0.4-Mixtral-Instruct

* show state templates for world and players in favorite list
fix applying world state template

* refresh world entry list on state creation

* changing a state from non-sequential to sequential should queue it as due

* quicksettings to bar

* fix error during memory db delete

* status messages during scene load

* removing a sequential state reinforcement should remove the reinforcement messages

* Nous-Hermes-2-Mixtral

* fix sync issue when editing character details through contextdb

* immutable save property

* enable director

* update example config

* enable director when loading a scene file that has instructions

* fix more openai client funkyness with context size and losing model

* iq dyn scenario prompt fixes

* delay client save so that dragging the ctx slider doesnt send off a million requests
default openai ctx to 8k

* input disabled while clients active

* declare event

* narrate query prompt tweaks

* fixes to dialogue cleanup that would cause messages after : to be cut off.

* init git repo if not exist

* pull current branch

* add 12 hours as option

* world-state persist deactivated

* install npm packages

* fix typo

* prompt tweaks

* new screenshots and features updated

* update screenshot
2024-01-19 11:47:38 +02:00

234 lines
No EOL
7.8 KiB
Vue

<template>
<div v-if="isConnected()">
<v-list v-for="(client, index) in state.clients" :key="index">
<v-list-item>
<v-divider v-if="index !== 0" class="mb-3"></v-divider>
<v-list-item-title>
<v-progress-circular v-if="client.status === 'busy'" indeterminate color="primary"
size="14"></v-progress-circular>
<v-icon v-else-if="client.status == 'warning'" color="orange" size="14">mdi-checkbox-blank-circle</v-icon>
<v-icon v-else-if="client.status == 'error'" color="red" size="14">mdi-checkbox-blank-circle</v-icon>
<v-icon v-else-if="client.status == 'disabled'" color="grey-darken-2" size="14">mdi-checkbox-blank-circle</v-icon>
<v-icon v-else color="green" size="14">mdi-checkbox-blank-circle</v-icon>
{{ client.name }}
</v-list-item-title>
<v-list-item-subtitle class="text-caption">
{{ client.model_name }}
</v-list-item-subtitle>
<v-list-item-subtitle class="text-caption">
{{ client.type }}
<v-chip label size="x-small" variant="outlined" class="ml-1">ctx {{ client.max_token_length }}</v-chip>
</v-list-item-subtitle>
<div density="compact">
<v-slider
hide-details
v-model="client.max_token_length"
:min="1024"
:max="128000"
:step="512"
@update:modelValue="saveClientDelayed(client)"
@click.stop
density="compact"
></v-slider>
</div>
<v-list-item-subtitle class="text-center">
<v-tooltip text="No LLM prompt template for this model. Using default. Templates can be added in ./templates/llm-prompt" v-if="client.status === 'idle' && client.data && !client.data.has_prompt_template" max-width="200">
<template v-slot:activator="{ props }">
<v-icon x-size="14" class="mr-1" v-bind="props" color="orange">mdi-alert</v-icon>
</template>
</v-tooltip>
<v-tooltip text="Edit client">
<template v-slot:activator="{ props }">
<v-btn size="x-small" class="mr-1" v-bind="props" variant="tonal" density="comfortable" rounded="sm" @click.stop="editClient(index)" icon="mdi-cogs"></v-btn>
</template>
</v-tooltip>
<v-tooltip text="Assign to all agents">
<template v-slot:activator="{ props }">
<v-btn size="x-small" class="mr-1" v-bind="props" variant="tonal" density="comfortable" rounded="sm" @click.stop="assignClientToAllAgents(index)" icon="mdi-transit-connection-variant"></v-btn>
</template>
</v-tooltip>
<v-tooltip text="Delete client">
<template v-slot:activator="{ props }">
<v-btn size="x-small" class="mr-1" v-bind="props" variant="tonal" density="comfortable" rounded="sm" @click.stop="deleteClient(index)" icon="mdi-close-thick"></v-btn>
</template>
</v-tooltip>
</v-list-item-subtitle>
</v-list-item>
</v-list>
<ClientModal :dialog="state.dialog" :formTitle="state.formTitle" @save="saveClient" @error="propagateError" @update:dialog="updateDialog"></ClientModal>
<v-alert type="warning" variant="tonal" v-if="state.clients.length === 0">You have no LLM clients configured. Add one.</v-alert>
<v-btn @click="openModal" prepend-icon="mdi-plus-box">Add client</v-btn>
</div>
</template>
<script>
import ClientModal from './ClientModal.vue';
export default {
components: {
ClientModal,
},
data() {
return {
saveDelayTimeout: null,
clientStatusCheck: null,
state: {
clients: [],
dialog: false,
currentClient: {
name: '',
type: '',
apiUrl: '',
model_name: '',
max_token_length: 4096,
data: {
has_prompt_template: false,
}
}, // Add a new field to store the model name
formTitle: ''
}
}
},
inject: [
'getWebsocket',
'registerMessageHandler',
'isConnected',
'getAgents',
],
provide() {
return {
state: this.state
};
},
methods: {
configurationRequired() {
if(this.state.clients.length === 0) {
return true;
}
// cycle through clients and check if any are status 'error' or 'warning'
for (let i = 0; i < this.state.clients.length; i++) {
if (this.state.clients[i].status === 'error' || this.state.clients[i].status === 'warning') {
return true;
}
}
return false;
},
getActive() {
return this.state.clients.find(a => a.status === 'busy');
},
openModal() {
this.state.currentClient = {
name: 'TextGenWebUI',
type: 'textgenwebui',
apiUrl: 'http://localhost:5000',
model_name: '',
max_token_length: 4096,
data: {
has_prompt_template: false,
}
};
this.state.formTitle = 'Add Client';
this.state.dialog = true;
},
propagateError(error) {
this.$emit('error', error);
},
saveClientDelayed(client) {
client.dirty = true;
if (this.saveDelayTimeout) {
clearTimeout(this.saveDelayTimeout);
}
this.saveDelayTimeout = setTimeout(() => {
this.saveClient(client);
client.dirty = false;
}, 500);
},
saveClient(client) {
const index = this.state.clients.findIndex(c => c.name === client.name);
if (index === -1) {
this.state.clients.push(client);
} else {
this.state.clients[index] = client;
}
console.log("Saving client", client)
this.state.dialog = false; // Close the dialog after saving the client
this.$emit('clients-updated', this.state.clients);
},
editClient(index) {
this.state.currentClient = { ...this.state.clients[index] };
this.state.formTitle = 'Edit AI Client';
this.state.dialog = true;
},
deleteClient(index) {
if (window.confirm('Are you sure you want to delete this client?')) {
this.state.clients.splice(index, 1);
this.$emit('clients-updated', this.state.clients);
}
},
assignClientToAllAgents(index) {
let agents = this.getAgents();
let client = this.state.clients[index];
this.saveClient(client);
for (let i = 0; i < agents.length; i++) {
agents[i].client = client.name;
console.log("Assigning client", client.name, "to agent", agents[i].name);
}
this.$emit('client-assigned', agents);
},
updateDialog(newVal) {
this.state.dialog = newVal;
},
handleMessage(data) {
// Handle client_status message type
if (data.type === 'client_status') {
// Find the client with the given name
const client = this.state.clients.find(client => client.name === data.name);
if (client && !client.dirty) {
// Update the model name of the client
client.model_name = data.model_name;
client.type = data.message;
client.status = data.status;
client.max_token_length = data.max_token_length;
client.apiUrl = data.apiUrl;
client.data = data.data;
} else if(!client) {
console.log("Adding new client", data);
this.state.clients.push({
name: data.name,
model_name: data.model_name,
type: data.message,
status: data.status,
max_token_length: data.max_token_length,
apiUrl: data.apiUrl,
data: data.data,
});
// sort the clients by name
this.state.clients.sort((a, b) => (a.name > b.name) ? 1 : -1);
}
return;
}
}
},
created() {
this.registerMessageHandler(this.handleMessage);
},
}
</script>