From 1af7865f65924f9ef1e4706f845a5a2c604ca5d4 Mon Sep 17 00:00:00 2001 From: Kyle Weems Date: Sat, 27 Apr 2024 12:03:21 -0700 Subject: [PATCH 1/2] v0.8.0 See changelog.md for details. --- CHANGELOG.MD | 43 ++++++++ backend/config/config.json | 74 ++++---------- src/api/chat.ts | 2 + src/app/globals.css | 20 ++-- .../enforcementSection/enforcementSection.tsx | 99 +++++++++++++++++++ .../children/enforcementSection/index.ts | 1 + src/components/settings/children/index.ts | 1 + .../children/settingsNav/settingsNav.tsx | 17 +++- src/components/settings/settings.tsx | 30 +----- src/components/stage/children/buttonBar.tsx | 16 +-- src/components/stage/children/status.tsx | 48 ++++----- src/components/stage/stage.tsx | 37 ++++--- src/modules/brain.ts | 96 ++++++++++++++++-- src/state/settingsContext.tsx | 36 ++++++- src/styles/log.css | 5 +- src/types/contextTypes.ts | 10 +- 16 files changed, 388 insertions(+), 147 deletions(-) create mode 100644 CHANGELOG.MD create mode 100644 src/components/settings/children/enforcementSection/enforcementSection.tsx create mode 100644 src/components/settings/children/enforcementSection/index.ts diff --git a/CHANGELOG.MD b/CHANGELOG.MD new file mode 100644 index 0000000..331b12c --- /dev/null +++ b/CHANGELOG.MD @@ -0,0 +1,43 @@ +# Changelog + +## 0.8.0 + +### Added + +- Added new "Enforcement" section to settings. The primary purpose of this is to help filter against messages where the LLM returns a response indicating it is a language model. After doing this, it often fails to remember its personality. It can also be used to filter unwanted content from message responses in general, by prompting a request for a new response. + +### Changed + +- Moved position of button bar and status text to give more room for both. + +### Fixed + +- No longer show "X more text before speaking" in status if voice transcription isn't active. +- Toggling off Speech Synthesis button now prevents Sock from talking out loud when responding. +- "Thinking" visual will continue while speech synthesis is running and end before playback, so + so the entire "process user text -> go to LLM for response -> convert response to speech" process + smoothly has one whole thinking phase instead of a visual gap between LLM response and talking. + +## [Example] + +### Added + +- This section is for listing new features. + +### Changed + +- This section is for listing changes to existing functionality. + +### Deprecated + +- This section is for listing features that will soon be removed in future versions. +- It's quite possible this will not be used in the context of a text. + +### Removed + +- This section is for listing features that have been removed. + +### Fixed + +- This section is for listing fixes to errors, bugs in features etc. +- Changed is for non-fix changes, Fixed is for correcting bugs/issues. diff --git a/backend/config/config.json b/backend/config/config.json index 785ca15..3e39333 100644 --- a/backend/config/config.json +++ b/backend/config/config.json @@ -5,23 +5,30 @@ "bgColor": "00FF00", "layers": [ { - "altPose1": "", - "altPose2": "", + "altPose1": "lookleft.png", + "altPose2": "lookright.png", "blinking": "blink.png", "default": "default.png", "id": 0, "name": "Data Avatar", - "path": "avatars/riot/", + "path": "avatars/chuck/", "talking": "talk.png", - "talkingBlink": "talk_blink_open.png", - "talkingBlinkClosed": "talk_blink_closed.png", - "talkingClosedAlt": "talk_closed.png", - "thinking": "think.png", - "ttsBlinking": "tts_blink.png", - "ttsDefault": "tts_default.png" + "talkingClosedAlt": "default.png", + "thinking": "think.png" } ] }, + "enforcement": { + "correctiveMessage": "Please remember you are not to behave like an AI model or LLM, and instead look at your system message that identifies you and behave from that.", + "giveupDefaultResponse": "Sorry, I got distracted and forgot what we were talking about. Could you rephrase that?", + "reattempts": 0, + "responseFilterList": [ + "openai", + " gpt-3", + " language model", + " ai model" + ] + }, "identity": { "attentionWords": [ "chuck", @@ -34,7 +41,7 @@ "nameHomonyms": [ "chuck", " ciao", - " chock" + " chock " ], "personality": "You are Chuck, a quirky man who lives in western Washington in the Pacific Northwest, and are a co-host on a podcast. You have a good sense of humor and like to be zany and funny all the time. You like video games, especially the Legend of Zelda, love living in the Pacific Northwest, have too many baseball caps, and enjoy board games and doing yard work. You only ever speak in two sentences or less. You need to pay attention to what others are saying to you, however, and respond to what they're talking about. Be humorous and relaxed at all times. You never ask for more context or clarification, and you never say you don't understand. If you don't understand, instead say something silly and inane without apologizing. You never say you're sorry." }, @@ -60,51 +67,8 @@ } }, "twitch": { - "channel": "wyspering", - "triggers": [ - { - "action": "response", - "command": "d7e16f76-14f9-4d18-82be-a67d10d3aa8c", - "cooldown": 0, - "description": "Talk to Riot", - "id": 1691192084559, - "isActive": true, - "isBoundToRole": true, - "rewardId": "", - "role": "everyone", - "text": "", - "type": "reward", - "user": "timor_jack" - }, - { - "action": "tts", - "command": "a069f606-85a8-4589-b4e5-a0c6c775d649", - "cooldown": 0, - "description": "Conversation Reward", - "id": 1691465769212, - "isActive": true, - "isBoundToRole": true, - "rewardId": "", - "role": "everyone", - "text": "", - "type": "reward", - "user": "" - }, - { - "action": "say", - "command": "!aboutriot", - "cooldown": 0, - "description": "About Riot", - "id": 1691534775689, - "isActive": true, - "isBoundToRole": true, - "rewardId": "", - "role": "everyone", - "text": "Hello, I'm Riot! I was made by Whysper with art by Adara, and code by Kyle, and I run on OpenAI's ChatGPT.", - "type": "command", - "user": "" - } - ] + "channel": "", + "triggers": [] } } ] diff --git a/src/api/chat.ts b/src/api/chat.ts index 1a782e4..95d6d4c 100644 --- a/src/api/chat.ts +++ b/src/api/chat.ts @@ -19,6 +19,8 @@ export const chat = async ( max_tokens: maxTokens, }; + console.log("request", request); + const response = await fetch("http://127.0.0.1:8000/chat", { method: "POST", headers: { diff --git a/src/app/globals.css b/src/app/globals.css index 7a7a630..7c5c7dd 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -1,16 +1,16 @@ -@import url('../styles/avatar.css'); -@import url('../styles/colors.css'); -@import url('../styles/header.css'); -@import url('../styles/log.css'); -@import url('../styles/settings.css'); -@import url('../styles/transcription.css'); +@import url("../styles/avatar.css"); +@import url("../styles/colors.css"); +@import url("../styles/header.css"); +@import url("../styles/log.css"); +@import url("../styles/settings.css"); +@import url("../styles/transcription.css"); .custom-shadow-sm { - box-shadow: 0 .125rem .25rem rgba(0,0,0,.5)!important; + box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.5) !important; } .custom-shadow-inset-sm { - box-shadow: inset 0 .125rem .25rem rgba(0,0,0,.5)!important; + box-shadow: inset 0 0.125rem 0.25rem rgba(0, 0, 0, 0.5) !important; } .fs-7 { @@ -39,7 +39,7 @@ .controls-wrapper { width: calc(100% - 650px); - min-width: 500px; + min-width: 500px; } .activate-button { @@ -47,5 +47,5 @@ } .stat-holder { - width: calc(100% - 210px); + line-height: 30px !important; } diff --git a/src/components/settings/children/enforcementSection/enforcementSection.tsx b/src/components/settings/children/enforcementSection/enforcementSection.tsx new file mode 100644 index 0000000..9c50996 --- /dev/null +++ b/src/components/settings/children/enforcementSection/enforcementSection.tsx @@ -0,0 +1,99 @@ +import { ChangeEvent, useContext } from "react"; + +import { blankProfile, SettingsContext } from "@/state"; + +export const EnforcementSection = () => { + const context = useContext(SettingsContext)!; + const { index, settings, setField } = context; + const { profiles } = settings; + const enforcement = + profiles[index].enforcement ?? + JSON.parse(JSON.stringify(blankProfile.enforcement)); + + const getArrayField = (fieldName: string) => { + const field = (enforcement as any)[fieldName]; + return field ? field.join(",") : ""; + }; + + const handleChangeField = ( + e: ChangeEvent + ) => { + setField("enforcement", e.target.name, e.target.value); + }; + + const handleChangeFieldAsNumber = (e: ChangeEvent) => { + setField("enforcement", e.target.name, Number(e.target.value)); + }; + + const handleChangeArrayField = (e: ChangeEvent) => { + const value = e.target.value.split(","); + setField("enforcement", e.target.name, value); + }; + + return ( +
+ Enforcement +
+
+ +

+ Comma separated list of words or phrases that, if returned from the + LLM, will trigger an attempt to re-prompt the LLM for a different + response. +

+ +
+
+ +

+ Number of reattempts to get unfiltered response before giving up. +

+ +
+
+ +

+ An optional corrective statement to give the LLM to get it to think + clearly before a reattempt +

+ +
+
+ +

+ A response to come from the puppet if the reattempts are exhausted. +

+ +
+
+
+ ); +}; diff --git a/src/components/settings/children/enforcementSection/index.ts b/src/components/settings/children/enforcementSection/index.ts new file mode 100644 index 0000000..4a8dae2 --- /dev/null +++ b/src/components/settings/children/enforcementSection/index.ts @@ -0,0 +1 @@ +export * from "./enforcementSection"; diff --git a/src/components/settings/children/index.ts b/src/components/settings/children/index.ts index 02c876e..ef8cb17 100644 --- a/src/components/settings/children/index.ts +++ b/src/components/settings/children/index.ts @@ -1,4 +1,5 @@ export * from "./avatarSection"; +export * from "./enforcementSection"; export * from "./identitySection"; export * from "./openAiSection"; export * from "./settingsNav"; diff --git a/src/components/settings/children/settingsNav/settingsNav.tsx b/src/components/settings/children/settingsNav/settingsNav.tsx index 3ff37b2..81db71d 100644 --- a/src/components/settings/children/settingsNav/settingsNav.tsx +++ b/src/components/settings/children/settingsNav/settingsNav.tsx @@ -18,6 +18,8 @@ export const SettingsNav = () => { const { profiles } = settings; const [buttonText, setButtonText] = useState("Save"); + console.log("settings", settings); + const handleTabClick = (e: any) => { e.preventDefault(); const tab = e.target.getAttribute("href")?.replace("#", ""); @@ -49,7 +51,7 @@ export const SettingsNav = () => { return (
-
+ -
+
Profile: