Spaces:
Runtime error
Runtime error
Gradio version
Browse filesGradio working. Not all fields populate yet.
- temp_prompts.txt +32 -0
- test.py +229 -35
temp_prompts.txt
CHANGED
@@ -55,3 +55,35 @@ speech_traits = {
|
|
55 |
"abbreviations": "Abbreviations refer to shortened forms like acronyms and initialisms. Writing with many abbreviations uses things like 'LOL' and 'IDK', while formal writing avoids abbreviations.",
|
56 |
"grammar_spelling": "Grammar and spelling refer to the proper use of syntax, mechanics, and word forms. Strong grammar and spelling adheres to conventions, while poor grammar makes frequent mistakes."
|
57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
"abbreviations": "Abbreviations refer to shortened forms like acronyms and initialisms. Writing with many abbreviations uses things like 'LOL' and 'IDK', while formal writing avoids abbreviations.",
|
56 |
"grammar_spelling": "Grammar and spelling refer to the proper use of syntax, mechanics, and word forms. Strong grammar and spelling adheres to conventions, while poor grammar makes frequent mistakes."
|
57 |
}
|
58 |
+
speech_options = {
|
59 |
+
"formality": ["Very informal","Informal","Neutral","Formal","Very formal"],
|
60 |
+
"pace": ["Very slow","Slow","Moderate","Fast","Very fast"],
|
61 |
+
"rhythm": ["Melodious","Flowing","Varied","Staccato","Choppy"],
|
62 |
+
"volume": ["Very soft","Soft","Moderate","Loud","Very loud"],
|
63 |
+
"emotionality": ["Very restrained","Restrained","Neutral","Expressive","Very expressive"],
|
64 |
+
"directness": ["Very indirect","Indirect","Balanced","Direct","Very direct"],
|
65 |
+
"humor": ["Frequently serious","Occasionally serious","Neutral","Occasionally humorous","Frequently humorous"],
|
66 |
+
"enunciation": ["Mumbled","Relaxed","Neutral","Clear","Very clear"],
|
67 |
+
"expressiveness": ["Very reserved","Reserved","Neutral","Expressive","Very expressive"],
|
68 |
+
"accent": ["Strong foreign accent","Mild foreign accent","Neutral","Mild regional accent","Strong regional accent"],
|
69 |
+
"politeness": ["Very blunt","Blunt","Neutral","Polite","Very polite"],
|
70 |
+
"vocabulary": ["Very basic","Basic","Average","Sophisticated","Highly sophisticated"],
|
71 |
+
"interruptions": ["Frequently allows others to interrupt","Occasionally allows others to interrupt","Balanced","Occasionally interrupts","Frequently interrupts"],
|
72 |
+
"hesitations": ["Frequently fluent","Occasionally fluent","Balanced","Occasionally hesitates","Frequently hesitates"],
|
73 |
+
"sentence_structure": ["Very simple","Simple","Average","Complex","Very complex"],
|
74 |
+
"sarcasm": ["Never sarcastic","Rarely sarcastic","Occasionally sarcastic","Sarcastic","Very sarcastic"],
|
75 |
+
"colloquialisms": ["Never uses colloquialisms","Rarely uses colloquialisms","Balanced","Occasionally uses colloquialisms","Frequently uses colloquialisms"],
|
76 |
+
"energy_level": ["Very low energy","Low energy","Moderate energy","High energy","Very high energy"],
|
77 |
+
"defiance/rebellion": ["Never defiant","Rarely defiant","Balanced","Occasionally defiant","Frequently defiant"],
|
78 |
+
"playfulness": ["Never playful","Rarely playful","Occasionally playful","Playful","Very playful"],
|
79 |
+
"vulgarity": ["Never vulgar","Rarely vulgar","Occasionally vulgar","Vulgar","Very vulgar"],
|
80 |
+
"idiosyncrasies": ["No idiosyncrasies","Rare idiosyncrasies","Balanced","Occasional idiosyncrasies","Frequent idiosyncrasies"],
|
81 |
+
"emotional_tone": ["Very pessimistic","Pessimistic","Neutral","Optimistic","Very optimistic"],
|
82 |
+
"context_adaptability": ["Very inflexible","Inflexible","Balanced","Adaptable","Very adaptable"],
|
83 |
+
"subtext": ["Never uses subtext","Rarely uses subtext","Balanced","Occasionally uses subtext","Frequently uses subtext"],
|
84 |
+
"metaphorical_language": ["Never uses metaphorical language","Rarely uses metaphorical language","Balanced","Occasionally uses metaphorical language","Frequently uses metaphorical language"],
|
85 |
+
"cultural_references": ["Never uses cultural references","Rarely uses cultural references","Balanced","Occasionally uses cultural references","Frequently uses cultural references"],
|
86 |
+
"storytelling_ability": ["Never tells stories","Rarely tells stories","Balanced","Occasional storyteller","Frequent storyteller"],
|
87 |
+
"abbreviations": ["Never","Rare","Occasional","Frequent","Very frequent"],
|
88 |
+
"grammar_spelling": ["Very poor","Poor","Average","Good","Excellent"]
|
89 |
+
}
|
test.py
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
import requests
|
2 |
import json
|
3 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
#Jup1t3R!
|
5 |
|
6 |
### Great results with lmsys_vicuna-13b-v1.1 8-bit>> ~425s
|
@@ -8,7 +14,7 @@ import time
|
|
8 |
### Good results with lmsys_vicuna-13b-v1.1 4-bit>> ~150s
|
9 |
### Good results with lmsys_vicuna-7b-v1.1 4-bit>> ~75s
|
10 |
|
11 |
-
HOST = '
|
12 |
URI = f'http://{HOST}/api/v1/generate'
|
13 |
#MPT
|
14 |
# INSTRUCTION_KEY = "### Instruction:"
|
@@ -16,8 +22,9 @@ URI = f'http://{HOST}/api/v1/generate'
|
|
16 |
#LLAMA
|
17 |
INSTRUCTION_KEY = "### User:"
|
18 |
RESPONSE_KEY = "### Assistant:"
|
|
|
19 |
|
20 |
-
character = "
|
21 |
|
22 |
preprompt = f"""
|
23 |
{INSTRUCTION_KEY}
|
@@ -26,11 +33,10 @@ You are a professional writer, novelist, and character creator. You are extremel
|
|
26 |
|
27 |
postprompt = f"\n{RESPONSE_KEY}t\n"
|
28 |
general = ""
|
29 |
-
traits_dict = {}
|
30 |
first_time = 0
|
31 |
last_time = 0
|
32 |
|
33 |
-
def run(prompt, toks, seed=-1):
|
34 |
start_time = time.time()
|
35 |
request = {
|
36 |
'prompt': prompt,
|
@@ -74,10 +80,6 @@ def run(prompt, toks, seed=-1):
|
|
74 |
total_time = round(end_time - start_time, 2)
|
75 |
if response.status_code == 200:
|
76 |
result = response.json()['results'][0]['text']
|
77 |
-
# return result
|
78 |
-
# print("-------------")
|
79 |
-
# print(f"{result} ({total_time}s)")
|
80 |
-
# print("-------------")
|
81 |
print(f"({total_time}s)")
|
82 |
return result
|
83 |
else:
|
@@ -117,7 +119,8 @@ def getGeneralDescription(json, name):
|
|
117 |
{json}
|
118 |
Based on this information, use your experience as a writer to write a beautiful 5 sentence summary of {name}. Although inspired by a real character, create a fictitious version. \n{RESPONSE_KEY}: Sure! Here is a plain-text summary of a fictitious character based on the information you provided:"""
|
119 |
print("Getting description.")
|
120 |
-
|
|
|
121 |
|
122 |
def getName(character):
|
123 |
prompt = f"{RESPONSE_KEY}Here is a list of names that fit with a fictitious character that would appear on their birth certificate without any additional context or information other than their name:\nA childrens book character of a brilliant scientist's name is: Professor Brains\nAbe Licoln's name is: Abraham Licoln\nA fun loving Teddy Bear's name is: Teddy (fuzzmuffin)_McFuzz\nHans from Star War's name is: Hans Solo\n{character}'s name is:"
|
@@ -202,7 +205,7 @@ def getAllSpeech(general, name):
|
|
202 |
"metaphorical_language": ["Never uses metaphorical language","Rarely uses metaphorical language","Balanced","Occasionally uses metaphorical language","Frequently uses metaphorical language"],
|
203 |
"cultural_references": ["Never uses cultural references","Rarely uses cultural references","Balanced","Occasionally uses cultural references","Frequently uses cultural references"],
|
204 |
"storytelling_ability": ["Never tells stories","Rarely tells stories","Balanced","Occasional storyteller","Frequent storyteller"],
|
205 |
-
"abbreviations": ["Never","
|
206 |
"grammar_spelling": ["Very poor","Poor","Average","Good","Excellent"]
|
207 |
}
|
208 |
traits_dict['speech']={}
|
@@ -233,8 +236,9 @@ def getAllSpeech(general, name):
|
|
233 |
if was_found==False:
|
234 |
traits_dict['speech'][key] = "neutral"
|
235 |
print(f">>> FAIL, setting to 'neutral'")
|
|
|
236 |
|
237 |
-
def unwrapText():
|
238 |
description_unwrapped = f"""
|
239 |
{traits_dict['name']} is a {traits_dict['age']}-year-old {traits_dict['sexuality']} {traits_dict['sex']}.{traits_dict['general']} {traits_dict['name']} likes {traits_dict['likes']}. {traits_dict['name']} hates {traits_dict['hates']}.
|
240 |
"""
|
@@ -262,6 +266,8 @@ They have a {traits_dict['speech']['emotional_tone']} tone
|
|
262 |
{"They " + traits_dict['speech']['metaphorical_language'] + "." if traits_dict['speech']['metaphorical_language']!="balanced" else ""}
|
263 |
{"They " + traits_dict['speech']['cultural_references'] + "." if traits_dict['speech']['cultural_references']!="balanced" else ""}
|
264 |
{"They " + traits_dict['speech']['storytelling_ability'] + "." if traits_dict['speech']['storytelling_ability']!="balanced" else ""}
|
|
|
|
|
265 |
"""
|
266 |
traits_dict['speech_unwrapped'] = speech_unwrapped
|
267 |
print(f"{speech_unwrapped} {description_unwrapped}")
|
@@ -294,6 +300,7 @@ Tell me your analysis in this exact format: MBTI - Enneagram - Instinctual Varia
|
|
294 |
def test():
|
295 |
prompt = f"""
|
296 |
{INSTRUCTION_KEY}
|
|
|
297 |
{traits_dict['speech_unwrapped']}
|
298 |
Use this information and your writing and creative experience to create a sample dialogue between {traits_dict['name']} and a fictional neutral character named John. {traits_dict['name']} must speak exactly as specified. Words chosen, topic discussed, grammar, sentence structure, and vocabulary should all be considered when shaping this conversation.
|
299 |
{RESPONSE_KEY}
|
@@ -308,31 +315,218 @@ def test():
|
|
308 |
"""
|
309 |
response = run(preprompt + prompt, 500)
|
310 |
print(f"*2* {response} ***")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
312 |
-
if __name__ == '__main__':
|
313 |
-
first_time = time.time()
|
314 |
-
cleaned_data = remove_after_first_brace(getTraits(character))
|
315 |
-
traits_dict = json.loads(cleaned_data)
|
316 |
-
for key, value in traits_dict.items():
|
317 |
-
if isinstance(value, str):
|
318 |
-
traits_dict[key] = value.lower()
|
319 |
-
|
320 |
-
# To check the updated dictionary:
|
321 |
-
traits_dict['name'] = getName(character)
|
322 |
-
traits_dict['sex'] = remove_non_letters(getSex(character))
|
323 |
-
traits_dict['sexuality'] = remove_non_letters(getSexuality(character))
|
324 |
-
traits_dict['age'] = remove_non_numbers(getAge(character))
|
325 |
-
traits_dict['general'] = getGeneralDescription(traits_dict, traits_dict['name'])
|
326 |
-
traits_dict['psych'] = getPsychProfile(traits_dict['general'])
|
327 |
-
getAllSpeech(traits_dict['general'], traits_dict['name'])
|
328 |
-
unwrapText()
|
329 |
-
last_time = time.time()
|
330 |
-
total_time = round(last_time - first_time, 2)
|
331 |
-
print(f"Total time taken >> {total_time}")
|
332 |
-
print(" ################# OUTPUT #################")
|
333 |
-
for key, value in traits_dict.items():
|
334 |
-
print(f"{key}: {value}")
|
335 |
-
test()
|
336 |
|
337 |
|
338 |
|
|
|
1 |
import requests
|
2 |
import json
|
3 |
import time
|
4 |
+
from ast import Interactive
|
5 |
+
import gradio as gr
|
6 |
+
import re
|
7 |
+
import codecs
|
8 |
+
import random
|
9 |
+
|
10 |
#Jup1t3R!
|
11 |
|
12 |
### Great results with lmsys_vicuna-13b-v1.1 8-bit>> ~425s
|
|
|
14 |
### Good results with lmsys_vicuna-13b-v1.1 4-bit>> ~150s
|
15 |
### Good results with lmsys_vicuna-7b-v1.1 4-bit>> ~75s
|
16 |
|
17 |
+
HOST = '127.0.0.1:5000'
|
18 |
URI = f'http://{HOST}/api/v1/generate'
|
19 |
#MPT
|
20 |
# INSTRUCTION_KEY = "### Instruction:"
|
|
|
22 |
#LLAMA
|
23 |
INSTRUCTION_KEY = "### User:"
|
24 |
RESPONSE_KEY = "### Assistant:"
|
25 |
+
traits_dict = {}
|
26 |
|
27 |
+
character = "Ender Wiggins"
|
28 |
|
29 |
preprompt = f"""
|
30 |
{INSTRUCTION_KEY}
|
|
|
33 |
|
34 |
postprompt = f"\n{RESPONSE_KEY}t\n"
|
35 |
general = ""
|
|
|
36 |
first_time = 0
|
37 |
last_time = 0
|
38 |
|
39 |
+
def run(prompt, toks=250, seed=-1):
|
40 |
start_time = time.time()
|
41 |
request = {
|
42 |
'prompt': prompt,
|
|
|
80 |
total_time = round(end_time - start_time, 2)
|
81 |
if response.status_code == 200:
|
82 |
result = response.json()['results'][0]['text']
|
|
|
|
|
|
|
|
|
83 |
print(f"({total_time}s)")
|
84 |
return result
|
85 |
else:
|
|
|
119 |
{json}
|
120 |
Based on this information, use your experience as a writer to write a beautiful 5 sentence summary of {name}. Although inspired by a real character, create a fictitious version. \n{RESPONSE_KEY}: Sure! Here is a plain-text summary of a fictitious character based on the information you provided:"""
|
121 |
print("Getting description.")
|
122 |
+
result = run(preprompt + prompt, 250)
|
123 |
+
return result.strip("`")
|
124 |
|
125 |
def getName(character):
|
126 |
prompt = f"{RESPONSE_KEY}Here is a list of names that fit with a fictitious character that would appear on their birth certificate without any additional context or information other than their name:\nA childrens book character of a brilliant scientist's name is: Professor Brains\nAbe Licoln's name is: Abraham Licoln\nA fun loving Teddy Bear's name is: Teddy (fuzzmuffin)_McFuzz\nHans from Star War's name is: Hans Solo\n{character}'s name is:"
|
|
|
205 |
"metaphorical_language": ["Never uses metaphorical language","Rarely uses metaphorical language","Balanced","Occasionally uses metaphorical language","Frequently uses metaphorical language"],
|
206 |
"cultural_references": ["Never uses cultural references","Rarely uses cultural references","Balanced","Occasionally uses cultural references","Frequently uses cultural references"],
|
207 |
"storytelling_ability": ["Never tells stories","Rarely tells stories","Balanced","Occasional storyteller","Frequent storyteller"],
|
208 |
+
"abbreviations": ["Never","Rarely","Occasionally","Frequently","Very frequently"],
|
209 |
"grammar_spelling": ["Very poor","Poor","Average","Good","Excellent"]
|
210 |
}
|
211 |
traits_dict['speech']={}
|
|
|
236 |
if was_found==False:
|
237 |
traits_dict['speech'][key] = "neutral"
|
238 |
print(f">>> FAIL, setting to 'neutral'")
|
239 |
+
return traits_dict['speech']
|
240 |
|
241 |
+
def unwrapText(traits_dict):
|
242 |
description_unwrapped = f"""
|
243 |
{traits_dict['name']} is a {traits_dict['age']}-year-old {traits_dict['sexuality']} {traits_dict['sex']}.{traits_dict['general']} {traits_dict['name']} likes {traits_dict['likes']}. {traits_dict['name']} hates {traits_dict['hates']}.
|
244 |
"""
|
|
|
266 |
{"They " + traits_dict['speech']['metaphorical_language'] + "." if traits_dict['speech']['metaphorical_language']!="balanced" else ""}
|
267 |
{"They " + traits_dict['speech']['cultural_references'] + "." if traits_dict['speech']['cultural_references']!="balanced" else ""}
|
268 |
{"They " + traits_dict['speech']['storytelling_ability'] + "." if traits_dict['speech']['storytelling_ability']!="balanced" else ""}
|
269 |
+
{"They write with " + traits_dict['speech']['grammar_spelling'] + " grammar and spelling."}
|
270 |
+
{"They " + traits_dict['speech']['abbreviations'] + " use of abbreviations like 'lol' and 'brb'."}
|
271 |
"""
|
272 |
traits_dict['speech_unwrapped'] = speech_unwrapped
|
273 |
print(f"{speech_unwrapped} {description_unwrapped}")
|
|
|
300 |
def test():
|
301 |
prompt = f"""
|
302 |
{INSTRUCTION_KEY}
|
303 |
+
{traits_dict['general']}
|
304 |
{traits_dict['speech_unwrapped']}
|
305 |
Use this information and your writing and creative experience to create a sample dialogue between {traits_dict['name']} and a fictional neutral character named John. {traits_dict['name']} must speak exactly as specified. Words chosen, topic discussed, grammar, sentence structure, and vocabulary should all be considered when shaping this conversation.
|
306 |
{RESPONSE_KEY}
|
|
|
315 |
"""
|
316 |
response = run(preprompt + prompt, 500)
|
317 |
print(f"*2* {response} ***")
|
318 |
+
|
319 |
+
# def go():
|
320 |
+
# first_time = time.time()
|
321 |
+
# cleaned_data = remove_after_first_brace(getTraits(character))
|
322 |
+
# traits_dict = json.loads(cleaned_data)
|
323 |
+
# for key, value in traits_dict.items():
|
324 |
+
# if isinstance(value, str):
|
325 |
+
# traits_dict[key] = value.lower()
|
326 |
+
|
327 |
+
# traits_dict['name'] = getName(character)
|
328 |
+
# traits_dict['sex'] = remove_non_letters(getSex(character))
|
329 |
+
# traits_dict['sexuality'] = remove_non_letters(getSexuality(character))
|
330 |
+
# traits_dict['age'] = remove_non_numbers(getAge(character))
|
331 |
+
# traits_dict['general'] = getGeneralDescription(traits_dict, traits_dict['name'])
|
332 |
+
# traits_dict['psych'] = getPsychProfile(traits_dict['general'])
|
333 |
+
# getAllSpeech(traits_dict['general'], traits_dict['name'])
|
334 |
+
# unwrapText(traits_dict)
|
335 |
+
# last_time = time.time()
|
336 |
+
# total_time = round(last_time - first_time, 2)
|
337 |
+
# print(f"Total time taken >> {total_time}")
|
338 |
+
# print(" ################# OUTPUT #################")
|
339 |
+
# print(json.dumps(traits_dict))
|
340 |
+
# print(" ################# END #################")
|
341 |
+
# # for key, value in traits_dict.items():
|
342 |
+
# # print(f"{key}: {value}")
|
343 |
+
# test()
|
344 |
+
|
345 |
+
with gr.Blocks() as demo:
|
346 |
+
rawQuickResults=gr.Textbox(visible=False)
|
347 |
+
gr.Markdown(
|
348 |
+
"""
|
349 |
+
# Character Maker v0.2 #
|
350 |
+
""")
|
351 |
+
|
352 |
+
numTraits = 8
|
353 |
+
def updateTraitCount(text):
|
354 |
+
numTraits = text
|
355 |
+
print (numTraits)
|
356 |
+
def generateMedicalSecrets(count):
|
357 |
+
with open('medical_secrets.txt', 'r') as file:
|
358 |
+
lines = file.readlines()
|
359 |
+
selected_lines = random.sample(lines, count)
|
360 |
+
codes = [re.search(r'\((.*?)\)', line).group(1) for line in selected_lines]
|
361 |
+
codes_string = ', '.join(codes)
|
362 |
+
print(codes)
|
363 |
+
return "medical conditions: " + codes_string
|
364 |
+
|
365 |
+
with gr.Row():
|
366 |
+
quickStart = gr.Textbox(label="Quick Start", info="Use AI to fill out all fields based on your description.")
|
367 |
+
generate = gr.Button("Generate Quick Start")
|
368 |
+
|
369 |
+
with gr.Row():
|
370 |
+
with gr.Column(scale=1, min_width=600):
|
371 |
+
trait_count = gr.Slider(4, 20, label="Minimum number of traits for each category (this is currently ignored)", interactive=False, step=1.0, value=8)
|
372 |
+
trait_count.change(updateTraitCount, inputs=[trait_count])
|
373 |
+
charName = gr.Textbox(label="Name", interactive=True)
|
374 |
+
personality = gr.Textbox(label="Personality", interactive=True)
|
375 |
+
body = gr.Textbox(label="Physical Description", interactive=True)
|
376 |
+
with gr.Row():
|
377 |
+
likes = gr.Textbox(label="Likes", interactive=True)
|
378 |
+
hates = gr.Textbox(label="Hates", interactive=True)
|
379 |
+
with gr.Row():
|
380 |
+
sex = gr.Dropdown(["Male", "Female", "Other"], label="Sex", interactive=True)
|
381 |
+
sexuality = gr.Textbox(label="Sexuality", interactive=True)
|
382 |
+
age = gr.Slider(1, 100, label="Age", info="Choose between 1 and 100", interactive=True, step=1.0, value=21)
|
383 |
+
description = gr.Textbox(label="Description", interactive=True)
|
384 |
+
attributes = gr.Textbox(label="Attributes", interactive=True)
|
385 |
+
with gr.Row():
|
386 |
+
personalityProfile = gr.Textbox(label="Psychological Profile", interactive=True)
|
387 |
+
generatePersonality = gr.Button("2. Analyze Personality")
|
388 |
+
|
389 |
+
with gr.Accordion("Speaking Traits"):
|
390 |
+
speechOverview = gr.TextArea(label="Speech style", interactive=True)
|
391 |
+
with gr.Column(scale=1, min_width=600):
|
392 |
+
with gr.Row():
|
393 |
+
formality = gr.Dropdown(["Very formal", "Formal", "Neutral", "Informal", "Very informal"], label="Formality", interactive=True)
|
394 |
+
pace = gr.Dropdown(["Very fast", "Fast", "Moderate", "Slow", "Very slow"], label="Pace", interactive=True)
|
395 |
+
rhythm = gr.Dropdown(["Choppy", "Staccato", "Varied", "Flowing", "Melodious"], label="Rhythm", interactive=True)
|
396 |
+
volume = gr.Dropdown(["Very loud", "Loud", "Moderate", "Soft", "Very soft"], label="Volume", interactive=True)
|
397 |
+
emotionality = gr.Dropdown(["Very expressive", "Expressive", "Neutral", "Restrained", "Very restrained"], label="Emotionality", interactive=True)
|
398 |
+
directness = gr.Dropdown(["Very direct", "Direct", "Balanced", "Indirect", "Very indirect"], label="Directness", interactive=True)
|
399 |
+
|
400 |
+
with gr.Row():
|
401 |
+
humor = gr.Dropdown(["Frequently humorous", "Occasionally humorous", "Neutral", "Occasionally serious", "Frequently serious"], label="Humor", interactive=True)
|
402 |
+
enunciation = gr.Dropdown(["Very clear", "Clear", "Neutral", "Relaxed", "Mumbled"], label="Enunciation", interactive=True)
|
403 |
+
expressiveness = gr.Dropdown(["Very expressive", "Expressive", "Neutral", "Reserved", "Very reserved"], label="Expressiveness", interactive=True)
|
404 |
+
accent_dialect = gr.Dropdown(["Strong regional accent", "Mild regional accent", "Neutral", "Mild foreign accent", "Strong foreign accent"], label="Accent/Dialect", interactive=True)
|
405 |
+
politeness = gr.Dropdown(["Very polite", "Polite", "Neutral", "Blunt", "Very blunt"], label="Politeness", interactive=True)
|
406 |
+
vocabulary = gr.Dropdown(["Highly sophisticated", "Sophisticated", "Average", "Basic", "Very basic"], label="Vocabulary", interactive=True)
|
407 |
+
|
408 |
+
with gr.Row():
|
409 |
+
interruptions = gr.Dropdown(["Frequently interrupts", "Occasionally interrupts", "Balanced", "Occasionally allows others to interrupt", "Frequently allows others to interrupt"], label="Interruptions", interactive=True)
|
410 |
+
hesitations = gr.Dropdown(["Frequently hesitates", "Occasionally hesitates", "Balanced", "Occasionally fluent", "Frequently fluent"], label="Hesitations", interactive=True)
|
411 |
+
sentence_structure = gr.Dropdown(["Very complex", "Complex", "Average", "Simple", "Very simple"], label="Sentence Structure", interactive=True)
|
412 |
+
sarcasm = gr.Dropdown(["Very sarcastic", "Sarcastic", "Occasionally sarcastic", "Rarely sarcastic", "Never sarcastic"], label="Sarcasm", interactive=True)
|
413 |
+
colloquialisms = gr.Dropdown(["Frequently uses colloquialisms", "Occasionally uses colloquialisms", "Balanced", "Rarely uses colloquialisms", "Never uses colloquialisms"], label="Colloquialisms", interactive=True)
|
414 |
+
energy_level = gr.Dropdown(["Very high energy", "High energy", "Moderate energy", "Low energy", "Very low energy"], label="Energy Level", interactive=True)
|
415 |
+
with gr.Row():
|
416 |
+
defiance_rebellion = gr.Dropdown(["Frequently defiant", "Occasionally defiant", "Balanced", "Rarely defiant", "Never defiant"], label="Defiance/Rebellion", interactive=True)
|
417 |
+
playfulness = gr.Dropdown(["Very playful", "Playful", "Occasionally playful", "Rarely playful", "Never playful"], label="Playfulness", interactive=True)
|
418 |
+
vulgarity = gr.Dropdown(["Very vulgar", "Vulgar", "Occasionally vulgar", "Rarely vulgar", "Never vulgar"], label="Vulgarity", interactive=True)
|
419 |
+
idiosyncrasies = gr.Dropdown(["Frequent idiosyncrasies", "Occasional idiosyncrasies", "Balanced", "Rare idiosyncrasies", "No idiosyncrasies"], label="Idiosyncrasies", interactive=True)
|
420 |
+
emotional_tone = gr.Dropdown(["Very optimistic", "Optimistic", "Neutral", "Pessimistic", "Very pessimistic"], label="Emotional Tone", interactive=True)
|
421 |
+
context_adaptability = gr.Dropdown(["Very adaptable", "Adaptable", "Balanced", "Inflexible", "Very inflexible"], label="Context Adaptability", interactive=True)
|
422 |
+
with gr.Row():
|
423 |
+
subtext = gr.Dropdown(["Frequently uses subtext", "Occasionally uses subtext", "Balanced", "Rarely uses subtext", "Never uses subtext"], label="Subtext", interactive=True)
|
424 |
+
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)
|
425 |
+
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)
|
426 |
+
storytelling_ability = gr.Dropdown(["Frequent storyteller", "Occasional storyteller", "Balanced", "Rarely tells stories", "Never tells stories"], label="Storytelling Ability", interactive=True)
|
427 |
+
with gr.Column(scale=1, min_width=600):
|
428 |
+
gr.Markdown("""**SECRETS**\n
|
429 |
+
Medical conditions : This will choose a random medical condition(s) that this character suffers from.
|
430 |
+
Conditions will be saved only as a medical diagnosis code to save on token space and so it can be a secret to YOU as well.
|
431 |
+
""")
|
432 |
+
with gr.Row():
|
433 |
+
conditions_count = gr.Slider(1, 10, label="Number of conditions", info="Choose between 1 and 10", interactive=True, step=1.0, value=1)
|
434 |
+
med_secret_button = gr.Button("5. Generate secret medical condition(s) (COMING SOON)", interactive=True)
|
435 |
+
med_secret = gr.Textbox(label="Secrets", interactive=True, type='password')
|
436 |
+
gr.Markdown("""Trauma : This will choose a random psychological event that affects how this character behaves.
|
437 |
+
Example: Experiencing discrimination
|
438 |
+
""")
|
439 |
+
with gr.Row():
|
440 |
+
secrets_count = gr.Slider(1, 10, label="Number of issues", info="Choose between 1 and 10", interactive=True, step=1.0)
|
441 |
+
secret_button = gr.Button("6. Generate secret issues(s) (COMING SOON)", interactive=False)
|
442 |
+
secret = gr.Textbox(label="Secrets", interactive=True, type='password')
|
443 |
+
situation = gr.TextArea(label="Situation (COMING SOON)", interactive=False)
|
444 |
+
starting_message = gr.TextArea(label="Starting message (COMING SOON)", interactive=False)
|
445 |
+
# sample_starters = gr.CheckboxGroup(["This year is flying by so fast.",
|
446 |
+
# "It's quite sunny outside today.",
|
447 |
+
# "People seem to be in a hurry all the time.",
|
448 |
+
# "I hear birds chirping. It must be spring already.",
|
449 |
+
# "The city looks different at night."],
|
450 |
+
# label="Example conversation starters", info="These are simple statements designed to evoke a unique response without adding additional context. ", interactive=True),
|
451 |
+
with gr.Row():
|
452 |
+
with gr.Column(scale=1):
|
453 |
+
examples = gr.TextArea(label="Example chats (COMING SOON)", value="<START>\n")
|
454 |
+
|
455 |
+
def genMedical(text):
|
456 |
+
return "none"
|
457 |
+
|
458 |
+
med_secret_button.click(generateMedicalSecrets, inputs=[conditions_count], outputs=[med_secret])
|
459 |
+
createJSON = gr.Button("4. Create JSON")
|
460 |
+
quickStartResult = gr.JSON(label="result", interactive=True)
|
461 |
+
|
462 |
+
def updateFields(text):
|
463 |
+
print("updating fields")
|
464 |
+
charName = text.get('name', '')
|
465 |
+
personality = text.get('personality', '')
|
466 |
+
body = text.get('body', '')
|
467 |
+
likes = text.get('likes', '')
|
468 |
+
hates = text.get('hates', '')
|
469 |
+
sex = text.get('sex', '')
|
470 |
+
sexuality = text.get('sexuality', '')
|
471 |
+
age = text.get('age', '')
|
472 |
+
description = text.get('general', '')
|
473 |
+
personalityProfile = text.get('psych', '')
|
474 |
+
attributes = text.get('attributes', '')
|
475 |
+
speechOverview = text.get('speech_unwrapped', '')
|
476 |
+
return [
|
477 |
+
charName,
|
478 |
+
personality,
|
479 |
+
body,
|
480 |
+
likes,
|
481 |
+
hates,
|
482 |
+
sex,
|
483 |
+
sexuality,
|
484 |
+
age,
|
485 |
+
description,
|
486 |
+
personalityProfile,
|
487 |
+
attributes,
|
488 |
+
speechOverview
|
489 |
+
]
|
490 |
+
|
491 |
+
quickStartResult.change(updateFields, inputs=[quickStartResult], outputs=[
|
492 |
+
charName,
|
493 |
+
personality,
|
494 |
+
body,
|
495 |
+
likes,
|
496 |
+
hates,
|
497 |
+
sex,
|
498 |
+
sexuality,
|
499 |
+
age,
|
500 |
+
description,
|
501 |
+
personalityProfile,
|
502 |
+
attributes,
|
503 |
+
speechOverview
|
504 |
+
])
|
505 |
+
|
506 |
+
def generateQuickStart(text):
|
507 |
+
first_time = time.time()
|
508 |
+
cleaned_data = remove_after_first_brace(getTraits(text))
|
509 |
+
traits_dict = json.loads(cleaned_data)
|
510 |
+
for key, value in traits_dict.items():
|
511 |
+
if isinstance(value, str):
|
512 |
+
traits_dict[key] = value.lower()
|
513 |
+
traits_dict['name'] = getName(text)
|
514 |
+
traits_dict['sex'] = remove_non_letters(getSex(text))
|
515 |
+
traits_dict['sexuality'] = remove_non_letters(getSexuality(text))
|
516 |
+
traits_dict['age'] = remove_non_numbers(getAge(text))
|
517 |
+
traits_dict['general'] = getGeneralDescription(traits_dict, traits_dict['name'])
|
518 |
+
traits_dict['psych'] = getPsychProfile(traits_dict['general'])
|
519 |
+
traits_dict['speech'] = getAllSpeech(traits_dict['general'], traits_dict['name'])
|
520 |
+
unwrapText(traits_dict)
|
521 |
+
last_time = time.time()
|
522 |
+
total_time = round(last_time - first_time, 2)
|
523 |
+
print(f"completed in {total_time} s")
|
524 |
+
return traits_dict
|
525 |
+
|
526 |
+
generate.click(generateQuickStart, inputs=[quickStart], outputs=[quickStartResult])
|
527 |
+
|
528 |
+
inst = demo.launch()
|
529 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
530 |
|
531 |
|
532 |
|