Spaces:
Build error
Build error
File size: 2,099 Bytes
ceefdf5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import gradio as gr
from templates import parser
from interfaces import utils
from modules import palmchat
template_file = "templates/basic.jinja"
async def title_gen(cursors):
stories = ""
for cursor in cursors:
stories = stories + cursor["story"]
prompt = f"""what would be the title of the story below? be specific and creative.
{stories}
title: """
parameters = {
'model': 'models/text-bison-001',
'candidate_count': 1,
'temperature': 0.7,
'top_k': 40,
'top_p': 1,
'max_output_tokens': 4096,
}
_, title = await palmchat.gen_text(prompt, mode="text", parameters=parameters)
return title
def export(
title, cursors,
main_char_img, main_char_name, main_char_age, main_char_mbti, main_char_personality, main_char_job,
side_char_enable1, side_char_img1, side_char_name1, side_char_age1, side_char_mbti1, side_char_personality1, side_char_job1,
side_char_enable2, side_char_img2, side_char_name2, side_char_age2, side_char_mbti2, side_char_personality2, side_char_job2,
side_char_enable3, side_char_img3, side_char_name3, side_char_age3, side_char_mbti3, side_char_personality3, side_char_job3,
):
print(main_char_img)
characters = [
{
'img': main_char_img,
'name': main_char_name,
}
]
utils.add_side_character_to_export(
characters, side_char_enable1, side_char_img1, side_char_name1, side_char_age1, side_char_mbti1, side_char_personality1, side_char_job1
)
utils.add_side_character_to_export(
characters, side_char_enable2, side_char_img2, side_char_name2, side_char_age2, side_char_mbti2, side_char_personality2, side_char_job2
)
utils.add_side_character_to_export(
characters, side_char_enable3, side_char_img3, side_char_name3, side_char_age3, side_char_mbti3, side_char_personality3, side_char_job3
)
html_as_string = parser.gen_from_file(
template_file,
kwargs={
"title": title,
"characters": characters,
"items": cursors
}
)
return html_as_string
|