Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,13 +36,21 @@ generator = pipeline(
|
|
36 |
|
37 |
def generate_reply(prompt):
|
38 |
full_prompt = (
|
39 |
-
spartan_intro.strip() +
|
40 |
-
"
|
41 |
-
"User: " + prompt.strip() + "\n"
|
42 |
"Spartan Mentor:"
|
43 |
)
|
44 |
result = generator(full_prompt, max_length=300, num_return_sequences=1)[0]["generated_text"]
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
iface = gr.Interface(
|
48 |
fn=generate_reply,
|
|
|
36 |
|
37 |
def generate_reply(prompt):
|
38 |
full_prompt = (
|
39 |
+
spartan_intro.strip() +
|
40 |
+
"\n\n[Conversation begins]\n" +
|
41 |
+
"User: " + prompt.strip() + "\n" +
|
42 |
"Spartan Mentor:"
|
43 |
)
|
44 |
result = generator(full_prompt, max_length=300, num_return_sequences=1)[0]["generated_text"]
|
45 |
+
|
46 |
+
# After "Spartan Mentor:", capture only what bot says
|
47 |
+
if "Spartan Mentor:" in result:
|
48 |
+
result = result.split("Spartan Mentor:")[-1]
|
49 |
+
|
50 |
+
if "User:" in result:
|
51 |
+
result = result.split("User:")[0]
|
52 |
+
|
53 |
+
return result.strip()
|
54 |
|
55 |
iface = gr.Interface(
|
56 |
fn=generate_reply,
|