Compare commits

...

2 Commits

4 changed files with 24 additions and 18 deletions

View File

@ -7,17 +7,29 @@ import AMUseBotBackend.consts as c
import json
import streamlit as st
from dotenv import load_dotenv
load_dotenv()
CHARACTERS = os.getenv('CHARACTERS')
class DP:
def __init__(self, dst: DST, llm_rephrasing=True, character='ramsay'): #TODO: a way to set llm_rephrasing status and a character
def __init__(self, dst: DST, llm_rephrasing=False, character='default'): #TODO: a way to set llm_rephrasing status and a character
self.dst_module = dst
self.llm_rephrasing = llm_rephrasing
with open('ai_talks/AMUseBotBackend/utils/characters_dict.json') as f:
with open(CHARACTERS) as f:
characters_dict = json.load(f)
self.character = characters_dict[character]
def change_character(self, character):
with open(CHARACTERS) as f:
characters_dict = json.load(f)
self.character = characters_dict[character]
if self.character == 'default':
self.llm_rephrasing = False
else:
self.llm_rephrasing = True
def llm_rephrase(self, character, response):
model = character['model']
@ -40,7 +52,6 @@ class DP:
def generate_response(self, intents: List[str]) -> str:
# Prompt
if (None == intents):
return NLG.MESSAGE_PROMPT

View File

@ -1,5 +1,7 @@
{
"default": {"model": "gpt-3.5-turbo-0613", "prompt":
"default": {"model": "", "prompt": "", "leftside_input":"", "rightside_input": ""},
"helpful_chef": {"model": "gpt-3.5-turbo-0613", "prompt":
"You're a master chef known for treating everyone like your equal. You're currently reading steps of a recipe to your apprentice.",
"leftside_input": "Rephrase this step of a recipe to make it sound more like a natural, full English sentence: '",
"rightside_input": "'."},

View File

@ -107,8 +107,11 @@ def main() -> None:
horizontal=True,
)
if role_kind == st.session_state.locale.radio_text1:
c2.selectbox(label=st.session_state.locale.select_placeholder2, key="role",
character_type = c2.selectbox(label=st.session_state.locale.select_placeholder2, key="role",
options=st.session_state.locale.ai_role_options)
st.session_state.dp.change_character(character_type)
elif role_kind == st.session_state.locale.radio_text2:
c2.text_input(label=st.session_state.locale.select_placeholder3, key="role")

View File

@ -1,16 +1,6 @@
AI_ROLE_OPTIONS_EN: list[str] = [
"helpful assistant",
"code assistant",
"code reviewer",
"text improver",
"cinema expert",
"sport expert",
"online games expert",
"food recipes expert",
"English grammar expert",
"friendly and helpful teaching assistant",
"laconic assistant",
"helpful, pattern-following assistant",
"translate corporate jargon into plain English",
"default",
"helpful_chef",
"ramsay",
]