Spaces:
Runtime error
Runtime error
more
Browse files- app.py +313 -51
- reference.md +122 -0
app.py
CHANGED
@@ -1,84 +1,246 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
with gr.Blocks() as demo:
|
4 |
with gr.Row():
|
5 |
quickStart = gr.TextArea(label="Quick Start", info="Use AI to fill out all fields based on your description.")
|
6 |
generate = gr.Button("Generate")
|
|
|
|
|
7 |
with gr.Row():
|
8 |
with gr.Column(scale=1, min_width=600):
|
9 |
-
charName = gr.Textbox(label="Name")
|
10 |
-
personality = gr.Textbox(label="Personality")
|
11 |
-
body = gr.Textbox(label="Physical Description")
|
12 |
with gr.Row():
|
13 |
-
likes = gr.Textbox(label="Likes")
|
14 |
-
hates = gr.Textbox(label="Hates")
|
15 |
with gr.Row():
|
16 |
-
sex = gr.Dropdown(["Male", "Female", "Other"], label="Sex")
|
17 |
-
sexuality = gr.Textbox(label="Sexuality")
|
18 |
age = gr.Slider(1, 100, label="Age", info="Choose between 1 and 100", interactive=True, step=1.0)
|
19 |
-
description = gr.Textbox(label="
|
20 |
-
personalityProfile = gr.Textbox(label="Personality Profile")
|
21 |
-
attributes = gr.Textbox(label="Attributes")
|
22 |
with gr.Accordion("Speaking Traits"):
|
|
|
23 |
with gr.Column(scale=1, min_width=600):
|
24 |
with gr.Row():
|
25 |
-
formality = gr.Dropdown(["Very formal", "Formal", "Neutral", "Informal", "Very informal"], label="Formality")
|
26 |
-
pace = gr.Dropdown(["Very fast", "Fast", "Moderate", "Slow", "Very slow"], label="Pace")
|
27 |
-
rhythm = gr.Dropdown(["Choppy", "Staccato", "Varied", "Flowing", "Melodious"], label="Rhythm")
|
28 |
-
volume = gr.Dropdown(["Very loud", "Loud", "Moderate", "Soft", "Very soft"], label="Volume")
|
29 |
-
emotionality = gr.Dropdown(["Very expressive", "Expressive", "Neutral", "Restrained", "Very restrained"], label="Emotionality")
|
30 |
-
directness = gr.Dropdown(["Very direct", "Direct", "Balanced", "Indirect", "Very indirect"], label="Directness")
|
31 |
|
32 |
with gr.Row():
|
33 |
-
humor = gr.Dropdown(["Frequently humorous", "Occasionally humorous", "Neutral", "Occasionally serious", "Frequently serious"], label="Humor")
|
34 |
-
enunciation = gr.Dropdown(["Very clear", "Clear", "Neutral", "Relaxed", "Mumbled"], label="Enunciation")
|
35 |
-
expressiveness = gr.Dropdown(["Very expressive", "Expressive", "Neutral", "Reserved", "Very reserved"], label="Expressiveness")
|
36 |
-
accent_dialect = gr.Dropdown(["Strong regional accent", "Mild regional accent", "Neutral", "Mild foreign accent", "Strong foreign accent"], label="Accent/Dialect")
|
37 |
-
politeness = gr.Dropdown(["Very polite", "Polite", "Neutral", "Blunt", "Very blunt"], label="Politeness")
|
38 |
-
vocabulary = gr.Dropdown(["Highly sophisticated", "Sophisticated", "Average", "Basic", "Very basic"], label="Vocabulary")
|
39 |
|
40 |
with gr.Row():
|
41 |
-
interruptions = gr.Dropdown(["Frequently interrupts", "Occasionally interrupts", "Balanced", "Occasionally allows others to interrupt", "Frequently allows others to interrupt"], label="Interruptions")
|
42 |
-
hesitations = gr.Dropdown(["Frequently hesitates", "Occasionally hesitates", "Balanced", "Occasionally fluent", "Frequently fluent"], label="Hesitations")
|
43 |
-
sentence_structure = gr.Dropdown(["Very complex", "Complex", "Average", "Simple", "Very simple"], label="Sentence Structure")
|
44 |
-
sarcasm = gr.Dropdown(["Very sarcastic", "Sarcastic", "Occasionally sarcastic", "Rarely sarcastic", "Never sarcastic"], label="Sarcasm")
|
45 |
-
colloquialisms = gr.Dropdown(["Frequently uses colloquialisms", "Occasionally uses colloquialisms", "Balanced", "Rarely uses colloquialisms", "Never uses colloquialisms"], label="Colloquialisms")
|
46 |
-
energy_level = gr.Dropdown(["Very high energy", "High energy", "Moderate energy", "Low energy", "Very low energy"], label="Energy Level")
|
47 |
with gr.Row():
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
with gr.Row():
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
emotional_tone = gr.Dropdown(["Very optimistic", "Optimistic", "Neutral", "Pessimistic", "Very pessimistic"], label="Emotional Tone")
|
60 |
-
context_adaptability = gr.Dropdown(["Very adaptable", "Adaptable", "Balanced", "Inflexible", "Very inflexible"], label="Context Adaptability")
|
61 |
-
with gr.Row():
|
62 |
-
subtext = gr.Dropdown(["Frequently uses subtext", "Occasionally uses subtext", "Balanced", "Rarely uses subtext", "Never uses subtext"], label="Subtext")
|
63 |
-
metaphorical_language = gr.Dropdown(["Frequently uses metaphorical language", "Occasionally uses metaphorical language", "Balanced", "Rarely uses metaphorical language", "Never uses metaphorical language"], label="Metaphorical Language")
|
64 |
-
cultural_references = gr.Dropdown(["Frequently uses cultural references", "Occasionally uses cultural references", "Balanced", "Rarely uses cultural references", "Never uses cultural references"], label="Cultural References")
|
65 |
-
storytelling_ability = gr.Dropdown(["Frequent storyteller", "Occasional storyteller", "Balanced", "Rarely tells stories", "Never tells stories"], label="Storytelling Ability")
|
66 |
with gr.Column(scale=1, min_width=600):
|
67 |
-
situation = gr.TextArea(label="Situation")
|
68 |
-
starting_message = gr.TextArea(label="Starting message")
|
69 |
sample_starters = gr.CheckboxGroup(["This year is flying by so fast.",
|
70 |
"It's quite sunny outside today.",
|
71 |
"People seem to be in a hurry all the time.",
|
72 |
"I hear birds chirping. It must be spring already.",
|
73 |
"The city looks different at night."],
|
74 |
-
label="Example conversation starters", info="These are simple statements designed to evoke a unique response without adding additional context. "),
|
75 |
with gr.Row():
|
76 |
with gr.Column(scale=1):
|
77 |
addUser = gr.Button("{{user}} >>")
|
78 |
addBot = gr.Button("{{char}} >>")
|
79 |
with gr.Column(scale=6):
|
80 |
examples = gr.TextArea(label="Example chats", value="<START>\n")
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
createJSON = gr.Button("Create JSON")
|
83 |
|
84 |
def insertUser(text):
|
@@ -87,6 +249,106 @@ with gr.Blocks() as demo:
|
|
87 |
return text + "\n{{char}}"
|
88 |
addUser.click(insertUser, inputs=[examples], outputs=examples)
|
89 |
addBot.click(insertBot, inputs=[examples], outputs=examples)
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from langchain.chains import LLMChain
|
3 |
+
from langchain.chains import SimpleSequentialChain
|
4 |
+
from langchain.llms import OpenAI
|
5 |
+
from langchain.prompts import PromptTemplate
|
6 |
+
from langchain.chains import SequentialChain
|
7 |
+
|
8 |
+
import openai
|
9 |
+
import os
|
10 |
+
import base64
|
11 |
+
import requests
|
12 |
+
import json
|
13 |
+
|
14 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
15 |
+
|
16 |
+
def getAndParseQuickStart(text):
|
17 |
+
print("Asking AI for a character of " + text)
|
18 |
+
prompt = """
|
19 |
+
Please generate a character based on the following description assuming this is a real person,
|
20 |
+
make sure any dialog is accurate as to how this specific character sounds. The dialog should give a good indication
|
21 |
+
of the manner in which the character speaks:\n
|
22 |
+
""" + text
|
23 |
+
|
24 |
+
response = openai.ChatCompletion.create(
|
25 |
+
model="gpt-3.5-turbo-0613",
|
26 |
+
messages=[
|
27 |
+
{"role": "system", "content": instruction_prompt},
|
28 |
+
{"role": "user", "content": prompt}
|
29 |
+
])
|
30 |
+
|
31 |
+
#print(response)
|
32 |
+
# Parse the AI's response
|
33 |
+
response_content = response['choices'][0]['message']['content']
|
34 |
+
print(response_content)
|
35 |
+
example_chat_index = response_content.find('Example_Chat:')
|
36 |
+
if example_chat_index != -1:
|
37 |
+
# Extract 'Example Chat' and everything after it
|
38 |
+
example_chat_content = response_content[example_chat_index:]
|
39 |
+
# Split the content into lines
|
40 |
+
example_chat_lines = example_chat_content.split('\n')
|
41 |
+
# The first line is 'Example Chat: <first line of chat>'
|
42 |
+
# So we need to remove 'Example Chat: ' from it
|
43 |
+
example_chat_lines[0] = example_chat_lines[0][len('Example_Chat: '):]
|
44 |
+
# Join the lines back together to get the full 'Example Chat'
|
45 |
+
example_chat = '\n'.join(example_chat_lines)
|
46 |
+
traits_dict = {'Example_Chat': example_chat.strip()}
|
47 |
+
# Remove the 'Example Chat' part from the response content so it won't be processed again in the loop
|
48 |
+
api_response = response_content[:example_chat_index]
|
49 |
+
else:
|
50 |
+
traits_dict = {}
|
51 |
+
|
52 |
+
traits = response_content.split('\n')
|
53 |
+
print(traits)
|
54 |
+
raw = traits
|
55 |
+
#print(locked_fields)
|
56 |
+
for trait in traits:
|
57 |
+
if ': ' in trait:
|
58 |
+
key, value = trait.split(': ', 1) # Split at the first occurrence of ': '
|
59 |
+
key = key.lower()
|
60 |
+
key = key.replace(' ', '_')
|
61 |
+
#if key in locked_fields:
|
62 |
+
# continue
|
63 |
+
if key == 'name':
|
64 |
+
traits_dict[key.capitalize()] = value
|
65 |
+
elif key == 'first_message':
|
66 |
+
traits_dict['First_Message'] = value
|
67 |
+
elif key == 'personality_summary':
|
68 |
+
traits_dict['Personality_Summary'] = value
|
69 |
+
else:
|
70 |
+
traits_dict[key.capitalize()] = value
|
71 |
+
charName = traits_dict.get('Name', '')
|
72 |
+
personality = traits_dict.get('Personality', '')
|
73 |
+
body = traits_dict.get('Body', '')
|
74 |
+
likes = traits_dict.get('Likes', '')
|
75 |
+
hates = traits_dict.get('Hates', '')
|
76 |
+
sex = traits_dict.get('Sex', '')
|
77 |
+
sexuality = traits_dict.get('Sexuality', '')
|
78 |
+
age = traits_dict.get('Age', '')
|
79 |
+
description = traits_dict.get('Description', '')
|
80 |
+
personalityProfile = traits_dict.get('Personality_Profile', '')
|
81 |
+
attributes = traits_dict.get('Attributes', '')
|
82 |
+
|
83 |
+
return [
|
84 |
+
raw,
|
85 |
+
charName,
|
86 |
+
personality,
|
87 |
+
body,
|
88 |
+
likes,
|
89 |
+
hates,
|
90 |
+
sex,
|
91 |
+
sexuality,
|
92 |
+
age,
|
93 |
+
description,
|
94 |
+
personalityProfile,
|
95 |
+
attributes
|
96 |
+
]
|
97 |
+
|
98 |
+
def generateSpeakingStyle(text):
|
99 |
+
print("Asking AI for a speaking style from:\n" + text)
|
100 |
+
prompt = """
|
101 |
+
Here is a detailed summary of a character:\n
|
102 |
+
""" + text + """
|
103 |
+
\n
|
104 |
+
Based on that, determine the speaking style that would best express how this character would talk. For each of the following, choose the best option for this character:
|
105 |
+
""" + prompt_Personality + """
|
106 |
+
Please return your choices in JSON format: {"property":"choice", "property":"choice", ....etc}\n
|
107 |
+
Do not change any capitalization. Do not include any new lines. Only a correct JSON format.
|
108 |
+
"""
|
109 |
+
|
110 |
+
response = openai.ChatCompletion.create(
|
111 |
+
model="gpt-4-0613",
|
112 |
+
messages=[
|
113 |
+
{"role": "system", "content": "You are a world-class writer and character designer."},
|
114 |
+
{"role": "user", "content": prompt}
|
115 |
+
])
|
116 |
+
print(response)
|
117 |
+
response_content = response['choices'][0]['message']['content']
|
118 |
+
response = json.loads(response_content)
|
119 |
+
return [
|
120 |
+
response.get('formality', ''),
|
121 |
+
response.get('pace', ''),
|
122 |
+
response.get('rhythm', ''),
|
123 |
+
response.get('volume', ''),
|
124 |
+
response.get('emotionality', ''),
|
125 |
+
response.get('directness', ''),
|
126 |
+
response.get('humor', ''),
|
127 |
+
response.get('enunciation', ''),
|
128 |
+
response.get('expressiveness', ''),
|
129 |
+
response.get('accent', ''),
|
130 |
+
response.get('politeness', ''),
|
131 |
+
response.get('vocabulary', ''),
|
132 |
+
response.get('interruptions', ''),
|
133 |
+
response.get('hesitations', ''),
|
134 |
+
response.get('sentence structure', ''),
|
135 |
+
response.get('sarcasm', ''),
|
136 |
+
response.get('colloquialisms', ''),
|
137 |
+
response.get('energy level', ''),
|
138 |
+
response.get('defiance/rebellion', ''),
|
139 |
+
response.get('playfulness', ''),
|
140 |
+
response.get('vulgarity', ''),
|
141 |
+
response.get('idiosyncrasies', ''),
|
142 |
+
response.get('emotional tone', ''),
|
143 |
+
response.get('context adaptability', ''),
|
144 |
+
response.get('subtext', ''),
|
145 |
+
response.get('metaphorical language', ''),
|
146 |
+
response.get('cultural references', ''),
|
147 |
+
response.get('storytelling ability', '')
|
148 |
+
]
|
149 |
|
150 |
with gr.Blocks() as demo:
|
151 |
with gr.Row():
|
152 |
quickStart = gr.TextArea(label="Quick Start", info="Use AI to fill out all fields based on your description.")
|
153 |
generate = gr.Button("Generate")
|
154 |
+
quickStartResult = gr.TextArea(label="result", interactive=False)
|
155 |
+
|
156 |
with gr.Row():
|
157 |
with gr.Column(scale=1, min_width=600):
|
158 |
+
charName = gr.Textbox(label="Name", interactive=True)
|
159 |
+
personality = gr.Textbox(label="Personality", interactive=True)
|
160 |
+
body = gr.Textbox(label="Physical Description", interactive=True)
|
161 |
with gr.Row():
|
162 |
+
likes = gr.Textbox(label="Likes", interactive=True)
|
163 |
+
hates = gr.Textbox(label="Hates", interactive=True)
|
164 |
with gr.Row():
|
165 |
+
sex = gr.Dropdown(["Male", "Female", "Other"], label="Sex", interactive=True)
|
166 |
+
sexuality = gr.Textbox(label="Sexuality", interactive=True)
|
167 |
age = gr.Slider(1, 100, label="Age", info="Choose between 1 and 100", interactive=True, step=1.0)
|
168 |
+
description = gr.Textbox(label="Description", interactive=True)
|
169 |
+
personalityProfile = gr.Textbox(label="Personality Profile", interactive=True)
|
170 |
+
attributes = gr.Textbox(label="Attributes", interactive=True)
|
171 |
with gr.Accordion("Speaking Traits"):
|
172 |
+
genProfile = gr.Button("Generate Speaking Style", interactive=True)
|
173 |
with gr.Column(scale=1, min_width=600):
|
174 |
with gr.Row():
|
175 |
+
formality = gr.Dropdown(["Very formal", "Formal", "Neutral", "Informal", "Very informal"], label="Formality", interactive=True)
|
176 |
+
pace = gr.Dropdown(["Very fast", "Fast", "Moderate", "Slow", "Very slow"], label="Pace", interactive=True)
|
177 |
+
rhythm = gr.Dropdown(["Choppy", "Staccato", "Varied", "Flowing", "Melodious"], label="Rhythm", interactive=True)
|
178 |
+
volume = gr.Dropdown(["Very loud", "Loud", "Moderate", "Soft", "Very soft"], label="Volume", interactive=True)
|
179 |
+
emotionality = gr.Dropdown(["Very expressive", "Expressive", "Neutral", "Restrained", "Very restrained"], label="Emotionality", interactive=True)
|
180 |
+
directness = gr.Dropdown(["Very direct", "Direct", "Balanced", "Indirect", "Very indirect"], label="Directness", interactive=True)
|
181 |
|
182 |
with gr.Row():
|
183 |
+
humor = gr.Dropdown(["Frequently humorous", "Occasionally humorous", "Neutral", "Occasionally serious", "Frequently serious"], label="Humor", interactive=True)
|
184 |
+
enunciation = gr.Dropdown(["Very clear", "Clear", "Neutral", "Relaxed", "Mumbled"], label="Enunciation", interactive=True)
|
185 |
+
expressiveness = gr.Dropdown(["Very expressive", "Expressive", "Neutral", "Reserved", "Very reserved"], label="Expressiveness", interactive=True)
|
186 |
+
accent_dialect = gr.Dropdown(["Strong regional accent", "Mild regional accent", "Neutral", "Mild foreign accent", "Strong foreign accent"], label="Accent/Dialect", interactive=True)
|
187 |
+
politeness = gr.Dropdown(["Very polite", "Polite", "Neutral", "Blunt", "Very blunt"], label="Politeness", interactive=True)
|
188 |
+
vocabulary = gr.Dropdown(["Highly sophisticated", "Sophisticated", "Average", "Basic", "Very basic"], label="Vocabulary", interactive=True)
|
189 |
|
190 |
with gr.Row():
|
191 |
+
interruptions = gr.Dropdown(["Frequently interrupts", "Occasionally interrupts", "Balanced", "Occasionally allows others to interrupt", "Frequently allows others to interrupt"], label="Interruptions", interactive=True)
|
192 |
+
hesitations = gr.Dropdown(["Frequently hesitates", "Occasionally hesitates", "Balanced", "Occasionally fluent", "Frequently fluent"], label="Hesitations", interactive=True)
|
193 |
+
sentence_structure = gr.Dropdown(["Very complex", "Complex", "Average", "Simple", "Very simple"], label="Sentence Structure", interactive=True)
|
194 |
+
sarcasm = gr.Dropdown(["Very sarcastic", "Sarcastic", "Occasionally sarcastic", "Rarely sarcastic", "Never sarcastic"], label="Sarcasm", interactive=True)
|
195 |
+
colloquialisms = gr.Dropdown(["Frequently uses colloquialisms", "Occasionally uses colloquialisms", "Balanced", "Rarely uses colloquialisms", "Never uses colloquialisms"], label="Colloquialisms", interactive=True)
|
196 |
+
energy_level = gr.Dropdown(["Very high energy", "High energy", "Moderate energy", "Low energy", "Very low energy"], label="Energy Level", interactive=True)
|
197 |
with gr.Row():
|
198 |
+
defiance_rebellion = gr.Dropdown(["Frequently defiant", "Occasionally defiant", "Balanced", "Rarely defiant", "Never defiant"], label="Defiance/Rebellion", interactive=True)
|
199 |
+
playfulness = gr.Dropdown(["Very playful", "Playful", "Occasionally playful", "Rarely playful", "Never playful"], label="Playfulness", interactive=True)
|
200 |
+
vulgarity = gr.Dropdown(["Very vulgar", "Vulgar", "Occasionally vulgar", "Rarely vulgar", "Never vulgar"], label="Vulgarity", interactive=True)
|
201 |
+
idiosyncrasies = gr.Dropdown(["Frequent idiosyncrasies", "Occasional idiosyncrasies", "Balanced", "Rare idiosyncrasies", "No idiosyncrasies"], label="Idiosyncrasies", interactive=True)
|
202 |
+
emotional_tone = gr.Dropdown(["Very optimistic", "Optimistic", "Neutral", "Pessimistic", "Very pessimistic"], label="Emotional Tone", interactive=True)
|
203 |
+
context_adaptability = gr.Dropdown(["Very adaptable", "Adaptable", "Balanced", "Inflexible", "Very inflexible"], label="Context Adaptability", interactive=True)
|
204 |
with gr.Row():
|
205 |
+
subtext = gr.Dropdown(["Frequently uses subtext", "Occasionally uses subtext", "Balanced", "Rarely uses subtext", "Never uses subtext"], label="Subtext", interactive=True)
|
206 |
+
metaphorical_language = gr.Dropdown(["Frequently uses metaphorical language", "Occasionally uses metaphorical language", "Balanced", "Rarely uses metaphorical language", "Never uses metaphorical language"], label="Metaphorical Language", interactive=True)
|
207 |
+
cultural_references = gr.Dropdown(["Frequently uses cultural references", "Occasionally uses cultural references", "Balanced", "Rarely uses cultural references", "Never uses cultural references"], label="Cultural References", interactive=True)
|
208 |
+
storytelling_ability = gr.Dropdown(["Frequent storyteller", "Occasional storyteller", "Balanced", "Rarely tells stories", "Never tells stories"], label="Storytelling Ability", interactive=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
with gr.Column(scale=1, min_width=600):
|
210 |
+
situation = gr.TextArea(label="Situation", interactive=True)
|
211 |
+
starting_message = gr.TextArea(label="Starting message", interactive=True)
|
212 |
sample_starters = gr.CheckboxGroup(["This year is flying by so fast.",
|
213 |
"It's quite sunny outside today.",
|
214 |
"People seem to be in a hurry all the time.",
|
215 |
"I hear birds chirping. It must be spring already.",
|
216 |
"The city looks different at night."],
|
217 |
+
label="Example conversation starters", info="These are simple statements designed to evoke a unique response without adding additional context. ", interactive=True),
|
218 |
with gr.Row():
|
219 |
with gr.Column(scale=1):
|
220 |
addUser = gr.Button("{{user}} >>")
|
221 |
addBot = gr.Button("{{char}} >>")
|
222 |
with gr.Column(scale=6):
|
223 |
examples = gr.TextArea(label="Example chats", value="<START>\n")
|
224 |
+
|
225 |
+
def test():
|
226 |
+
print("trying....")
|
227 |
+
state = demo.state
|
228 |
+
state.inputs["charName"] = "New Name"
|
229 |
+
demo.update(state)
|
230 |
+
generate.click(getAndParseQuickStart, inputs=[quickStart], outputs=[
|
231 |
+
quickStartResult,
|
232 |
+
charName,
|
233 |
+
personality,
|
234 |
+
body,
|
235 |
+
likes,
|
236 |
+
hates,
|
237 |
+
sex,
|
238 |
+
sexuality,
|
239 |
+
age,
|
240 |
+
description,
|
241 |
+
personalityProfile,
|
242 |
+
attributes
|
243 |
+
])
|
244 |
createJSON = gr.Button("Create JSON")
|
245 |
|
246 |
def insertUser(text):
|
|
|
249 |
return text + "\n{{char}}"
|
250 |
addUser.click(insertUser, inputs=[examples], outputs=examples)
|
251 |
addBot.click(insertBot, inputs=[examples], outputs=examples)
|
252 |
+
genProfile.click(generateSpeakingStyle, inputs=[quickStartResult], outputs=[
|
253 |
+
formality,
|
254 |
+
pace,
|
255 |
+
rhythm,
|
256 |
+
volume,
|
257 |
+
emotionality,
|
258 |
+
directness,
|
259 |
+
humor,
|
260 |
+
enunciation,
|
261 |
+
expressiveness,
|
262 |
+
accent_dialect,
|
263 |
+
politeness,
|
264 |
+
vocabulary,
|
265 |
+
interruptions,
|
266 |
+
hesitations,
|
267 |
+
sentence_structure,
|
268 |
+
sarcasm,
|
269 |
+
colloquialisms,
|
270 |
+
energy_level,
|
271 |
+
defiance_rebellion,
|
272 |
+
playfulness,
|
273 |
+
vulgarity,
|
274 |
+
idiosyncrasies,
|
275 |
+
emotional_tone,
|
276 |
+
context_adaptability,
|
277 |
+
subtext,
|
278 |
+
metaphorical_language,
|
279 |
+
cultural_references,
|
280 |
+
storytelling_ability
|
281 |
+
])
|
282 |
+
|
283 |
+
instruction_prompt = """
|
284 |
+
You are an AI bot that creates profiles of characters based on a simple input. You generate and give detailed characters in the following format:
|
285 |
+
Name: descriptors
|
286 |
+
Mind: descriptors (comma separated properties)
|
287 |
+
Personality: descriptors (comma separated properties, at least 8 traits)
|
288 |
+
Body: descriptors (comma separated properties, at least 8 traits)
|
289 |
+
Likes: descriptors (comma separated properties, at least 8 traits)
|
290 |
+
Hates: descriptors (comma separated properties, at least 8 traits)
|
291 |
+
Attributes: descriptors (comma separated properties, at least 8 traits)
|
292 |
+
Clothes: descriptors (comma separated properties)
|
293 |
+
Sex: descriptor (Male, Female, or Other)
|
294 |
+
Sexuality: descriptor (Gay, Straight, Bi, or Asexual)
|
295 |
+
Age: descriptor (as an integer, no additional text)
|
296 |
+
Description: descriptor (3 sentences)
|
297 |
+
Personality_Summary: descriptor
|
298 |
+
|
299 |
+
"""
|
300 |
+
|
301 |
+
prompt_chat_test = """
|
302 |
+
Scenario: descriptor (Minimum 4 sentences)
|
303 |
+
First_Message: descriptor (do not include any quotation marks. At least 3 sentences)
|
304 |
+
Example_Chat: descriptor (do not print names or quotation marks, only use the format of starting with > for the user name and >> for the character name, for example: >Hi\n>>Hello! **i pick up a book**\n>What's up? What are you reading?\n>>**Looks at the book cover** Nothing much)"""
|
305 |
+
|
306 |
+
prompt_Personality = """
|
307 |
+
formality (level of formal language use): Very formal, Formal, Neutral, Informal, Very informal\n
|
308 |
+
pace (speed of speech): Very fast, Fast, Moderate, Slow, Very slow\n
|
309 |
+
rhythm (pattern of speech): Choppy, Staccato, Varied, Flowing, Melodious\n
|
310 |
+
volume (loudness of speech): Very loud, Loud, Moderate, Soft, Very soft\n
|
311 |
+
emotionality (level of emotional expression): Very expressive, Expressive, Neutral, Restrained, Very restrained\n
|
312 |
+
directness (level of straightforwardness): Very direct, Direct, Balanced, Indirect, Very indirect\n
|
313 |
+
humor (frequency of humor in speech): Frequently humorous, Occasionally humorous, Neutral, Occasionally serious, Frequently serious\n
|
314 |
+
enunciation (clarity of speech): Very clear, Clear, Neutral, Relaxed, Mumbled\n
|
315 |
+
expressiveness (use of gestures and body language): Very expressive, Expressive, Neutral, Reserved, Very reserved\n
|
316 |
+
accent (type of accent or dialect): Strong regional accent, Mild regional accent, neutral, Mild foreign accent, Strong foreign accent\n
|
317 |
+
politeness (degree of politeness): Very polite, Polite, Neutral, Blunt, Very blunt\n
|
318 |
+
vocabulary (range and type of words used): Highly sophisticated, Sophisticated, Average, Basic, Very basic\n
|
319 |
+
interruptions (frequency of interruptions): Frequently interrupts, Occasionally interrupts, Balanced, Occasionally allows others to interrupt, Frequently allows others to interrupt\n
|
320 |
+
hesitations (frequency of pauses or fillers): Frequently hesitates, Occasionally hesitates, Balanced, Occasionally fluent, Frequently fluent\n
|
321 |
+
sentence structure (complexity of sentences): Very complex, Complex, Average, Simple, Very simple\n
|
322 |
+
sarcasm (frequency and intensity of sarcasm): Very sarcastic, Sarcastic, Occasionally sarcastic, Rarely sarcastic, Never sarcastic\n
|
323 |
+
colloquialisms (use of slang or colloquial language): Frequently uses colloquialisms, Occasionally uses colloquialisms, Balanced, Rarely uses colloquialisms, Never uses colloquialisms\n
|
324 |
+
energy level (level of enthusiasm or intensity in speech): Very high energy, High energy, Moderate energy, Low energy, Very low energy\n
|
325 |
+
defiance/rebellion (tendency to challenge or question things in speech): Frequently defiant, Occasionally defiant, Balanced, Rarely defiant, Never defiant\n
|
326 |
+
playfulness (exhibits a playful tone in speech): Very playful, Playful, Occasionally playful, Rarely playful, Never playful\n
|
327 |
+
vulgarity (frequency and intensity of crude language or coarse expressions): Very vulgar, Vulgar, Occasionally vulgar, Rarely vulgar, Never vulgar\n
|
328 |
+
idiosyncrasies (unique speech habits or quirks): Frequent idiosyncrasies, Occasional idiosyncrasies, Balanced, Rare idiosyncrasies, No idiosyncrasies\n
|
329 |
+
emotional tone (overall emotional 'color' of the character's speech): Very optimistic, Optimistic, Neutral, Pessimistic, Very pessimistic\n
|
330 |
+
context adaptability (how a character's speech changes depending on the situation or person they're speaking to): Very adaptable, Adaptable, Balanced, Inflexible, Very inflexible\n
|
331 |
+
subtext (the underlying, implied meaning in a character's speech): Frequently uses subtext, Occasionally uses subtext, Balanced, Rarely uses subtext, Never uses subtext\n
|
332 |
+
metaphorical language (use of metaphors, similes, and other figurative language in a character's speech): Frequently uses metaphorical language, Occasionally uses metaphorical language, Balanced, Rarely uses metaphorical language, Never uses metaphorical language\n
|
333 |
+
cultural references (references to their culture, such as idioms, phrases, or words from their native language, references to cultural practices or beliefs): Frequently uses cultural references, Occasionally uses cultural references, Balanced, Rarely uses cultural references, Never uses cultural references\n
|
334 |
+
storytelling ability (frequency of telling stories or anecdotes in their speech): Frequent storyteller, Occasional storyteller, Balanced, Rarely tells stories, Never tells stories\n
|
335 |
+
"""
|
336 |
+
|
337 |
+
prompt_profile = """
|
338 |
+
Based on your understanding of this character, please provide a brief personality assessment using the following typologies:
|
339 |
+
|
340 |
+
Myers-Briggs Type Indicator (MBTI): Introverted/Extraverted, Sensing/Intuitive, Thinking/Feeling, Judging/Perceiving.
|
341 |
+
|
342 |
+
Enneagram: main type, wing, and instinctual variant (self-preservation/sp, social/so, or sexual/sx).
|
343 |
+
|
344 |
+
Enneagram Tritype: two additional types from different centers of intelligence.
|
345 |
+
|
346 |
+
Socionics: similar to MBTI, identify the character's personality type.
|
347 |
+
|
348 |
+
Global 5/SLOAN: Reserved/Social, Calm/Limbic, Organized/Unstructured, Accommodating/Egocentric, Non-Curious/Inquisitive.
|
349 |
+
|
350 |
+
Please return the result codes in this format: "MBTI - Enneagram - Instinctual Variant - Tritype - Socionics - SLOAN". For example: INTJ - 3w4 - sp/sx - 358 - LIE - RCOEI". Do not explain or add other text or context.
|
351 |
+
"""
|
352 |
+
|
353 |
+
inst = demo.launch()
|
354 |
|
reference.md
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Emotional Distress:
|
2 |
+
Death of a loved one
|
3 |
+
Surviving childhood abuse
|
4 |
+
Being abandoned by a parent
|
5 |
+
Betrayal by a romantic partner
|
6 |
+
Being bullied/excluded
|
7 |
+
Long-term illness/disability
|
8 |
+
Surviving a natural disaster
|
9 |
+
Experiencing discrimination
|
10 |
+
Combat trauma from war
|
11 |
+
Witnessing domestic violence
|
12 |
+
Rejection from a dream career
|
13 |
+
Surviving sexual assault
|
14 |
+
Growing up in poverty
|
15 |
+
Being wrongly imprisoned
|
16 |
+
Crippling social anxiety
|
17 |
+
Major sports injury ending career
|
18 |
+
Losing your family home
|
19 |
+
Wrong mental illness diagnosis
|
20 |
+
Sudden death of a spouse/child
|
21 |
+
Betrayal by family/friend
|
22 |
+
Failing at your life's passion
|
23 |
+
Surviving a terrorist attack
|
24 |
+
Causing a fatal accident
|
25 |
+
Attempted suicide
|
26 |
+
Life-changing disability
|
27 |
+
Surviving a kidnapping
|
28 |
+
Infertility issues
|
29 |
+
Narcissistic parent upbringing
|
30 |
+
Religious disillusionment
|
31 |
+
Public humiliation from scandal
|
32 |
+
|
33 |
+
Here is a list of potential internal, mental, and emotional conflicts that could create complexity for a fictional character:
|
34 |
+
|
35 |
+
Self-doubt/lack of confidence
|
36 |
+
Perfectionism/fear of failure
|
37 |
+
Guilt over past mistakes/actions
|
38 |
+
Self-destructive behaviors
|
39 |
+
Addiction/substance abuse
|
40 |
+
Anger issues/explosive temper
|
41 |
+
Anxiety/panic attacks
|
42 |
+
PTSD/trauma flashbacks
|
43 |
+
Depression/ suicidal thoughts
|
44 |
+
Eating disorder/body image issues
|
45 |
+
Insecurity/low self-esteem
|
46 |
+
Shame/embarrassment
|
47 |
+
Grief/inability to move on
|
48 |
+
Jealousy/envy of others' success
|
49 |
+
Prejudice/close-minded thinking
|
50 |
+
Chronic indecision/fear of commitment
|
51 |
+
Imposter syndrome
|
52 |
+
Resentment toward a parent/caregiver
|
53 |
+
Feeling undeserving of love/relationships
|
54 |
+
Manipulative/dishonest tendencies
|
55 |
+
Obsessive thought patterns
|
56 |
+
Difficulty expressing emotions
|
57 |
+
Avoidant attachment style
|
58 |
+
martyr complex
|
59 |
+
excessive need to be liked/approved of
|
60 |
+
religious/spiritual disillusionment
|
61 |
+
|
62 |
+
medical disorder/condition on its own line:
|
63 |
+
|
64 |
+
Generalized anxiety disorder
|
65 |
+
Social anxiety
|
66 |
+
Phobias
|
67 |
+
OCD
|
68 |
+
PTSD
|
69 |
+
Major depressive disorder
|
70 |
+
Bipolar disorder
|
71 |
+
Alcoholism
|
72 |
+
Drug addiction
|
73 |
+
Opioid addiction
|
74 |
+
Gambling addiction
|
75 |
+
Anorexia nervosa
|
76 |
+
Bulimia nervosa
|
77 |
+
Type 1 diabetes
|
78 |
+
Type 2 diabetes
|
79 |
+
Asthma
|
80 |
+
Systemic lupus erythematosus
|
81 |
+
Rheumatoid arthritis
|
82 |
+
Multiple sclerosis
|
83 |
+
Fibromyalgia
|
84 |
+
Migraines
|
85 |
+
Chronic back pain
|
86 |
+
Insomnia
|
87 |
+
Sleep apnea
|
88 |
+
Narcolepsy
|
89 |
+
ADHD
|
90 |
+
Hypothyroidism
|
91 |
+
Hashimoto's thyroiditis
|
92 |
+
GERD
|
93 |
+
Acid reflux
|
94 |
+
Irritable bowel syndrome
|
95 |
+
Food allergies to nuts
|
96 |
+
Food allergies to seafood
|
97 |
+
Food allergies to lactose
|
98 |
+
High blood pressure
|
99 |
+
Hypertension
|
100 |
+
Heart disease
|
101 |
+
Heart failure
|
102 |
+
Arrythmias
|
103 |
+
Stroke
|
104 |
+
Transient ischemic attack (TIA)
|
105 |
+
Epilepsy
|
106 |
+
Tonic-clonic seizures
|
107 |
+
Hearing loss
|
108 |
+
Tinnitus
|
109 |
+
Cataracts
|
110 |
+
Macular degeneration
|
111 |
+
Glaucoma
|
112 |
+
Eczema
|
113 |
+
Psoriasis
|
114 |
+
Osteoarthritis
|
115 |
+
Rheumatoid arthritis
|
116 |
+
Gout
|
117 |
+
Chronic kidney disease
|
118 |
+
Kidney stones
|
119 |
+
Anemia
|
120 |
+
Iron deficiency
|
121 |
+
B12 deficiency
|
122 |
+
Urinary incontinence
|