Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ model = "llama-3.1-70b-versatile"
|
|
20 |
# Define function to generate text
|
21 |
def generate_text(parent_name, child_name, language):
|
22 |
prompts = {
|
23 |
-
"posh": f"Generate a concise silly letter
|
24 |
"english": f"Generate a concise silly letter in standard English to {parent_name} about their child {child_name}'s detention reasons. Write extreme but realistic behaviours.",
|
25 |
"hungarian": f"Generate a Hungarian language, concise silly letter to {parent_name} about their child {child_name}'s detention reasons. Write extreme but realistic behaviours. Make sur you use formal you."
|
26 |
}
|
@@ -107,8 +107,10 @@ html_template = """
|
|
107 |
</head>
|
108 |
<body>
|
109 |
<h1>Silly Detention Letter Generator</h1>
|
|
|
110 |
<div id="letter">{{ message }}</div>
|
111 |
<button id="regenerate" onclick="location.reload()">Regenerate Letter</button>
|
|
|
112 |
<form method="post">
|
113 |
<input type="text" name="parent_name" placeholder="Parent's Name" required>
|
114 |
<input type="text" name="child_name" placeholder="Child's Name" required>
|
@@ -131,12 +133,9 @@ def home():
|
|
131 |
parent_name = request.form["parent_name"]
|
132 |
child_name = request.form["child_name"]
|
133 |
language = request.form["language"]
|
|
|
134 |
else:
|
135 |
-
|
136 |
-
child_name = "John"
|
137 |
-
language = "posh"
|
138 |
-
|
139 |
-
message = generate_text(parent_name, child_name, language)
|
140 |
return render_template_string(html_template, message=message)
|
141 |
except Exception as e:
|
142 |
app.logger.error(f"Error in home route: {str(e)}")
|
|
|
20 |
# Define function to generate text
|
21 |
def generate_text(parent_name, child_name, language):
|
22 |
prompts = {
|
23 |
+
"posh": f"Generate a concise silly letter written in posh British English used in private schools - to {parent_name} about their child {child_name}'s detention reasons. Write extreme but realistic behaviours.",
|
24 |
"english": f"Generate a concise silly letter in standard English to {parent_name} about their child {child_name}'s detention reasons. Write extreme but realistic behaviours.",
|
25 |
"hungarian": f"Generate a Hungarian language, concise silly letter to {parent_name} about their child {child_name}'s detention reasons. Write extreme but realistic behaviours. Make sur you use formal you."
|
26 |
}
|
|
|
107 |
</head>
|
108 |
<body>
|
109 |
<h1>Silly Detention Letter Generator</h1>
|
110 |
+
{% if message %}
|
111 |
<div id="letter">{{ message }}</div>
|
112 |
<button id="regenerate" onclick="location.reload()">Regenerate Letter</button>
|
113 |
+
{% endif %}
|
114 |
<form method="post">
|
115 |
<input type="text" name="parent_name" placeholder="Parent's Name" required>
|
116 |
<input type="text" name="child_name" placeholder="Child's Name" required>
|
|
|
133 |
parent_name = request.form["parent_name"]
|
134 |
child_name = request.form["child_name"]
|
135 |
language = request.form["language"]
|
136 |
+
message = generate_text(parent_name, child_name, language)
|
137 |
else:
|
138 |
+
message = None
|
|
|
|
|
|
|
|
|
139 |
return render_template_string(html_template, message=message)
|
140 |
except Exception as e:
|
141 |
app.logger.error(f"Error in home route: {str(e)}")
|