Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,17 +25,31 @@ def generate_user_stories(text, prompt):
|
|
25 |
return ""
|
26 |
|
27 |
def format_as_user_stories(summary):
|
28 |
-
# Enhanced formatting logic to extract user stories
|
29 |
user_stories = []
|
30 |
lines = summary.split('. ')
|
31 |
|
32 |
for line in lines:
|
33 |
-
# Improved pattern matching for user stories
|
34 |
line = line.strip()
|
35 |
if "as a" in line.lower() and "i want" in line.lower():
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Initialize session state for input history if it doesn't exist
|
41 |
if 'input_history' not in st.session_state:
|
|
|
25 |
return ""
|
26 |
|
27 |
def format_as_user_stories(summary):
|
|
|
28 |
user_stories = []
|
29 |
lines = summary.split('. ')
|
30 |
|
31 |
for line in lines:
|
|
|
32 |
line = line.strip()
|
33 |
if "as a" in line.lower() and "i want" in line.lower():
|
34 |
+
# Extract the parts of the user story
|
35 |
+
parts = line.split("so that")
|
36 |
+
if len(parts) == 2:
|
37 |
+
story = {
|
38 |
+
"As a": parts[0].strip().capitalize(),
|
39 |
+
"I want to": parts[1].strip().capitalize(),
|
40 |
+
"So that": parts[1].strip().capitalize()
|
41 |
+
}
|
42 |
+
user_stories.append(story)
|
43 |
|
44 |
+
# Format user stories
|
45 |
+
formatted_stories = ""
|
46 |
+
for story in user_stories:
|
47 |
+
formatted_stories += f"**User Story:**\n\n" \
|
48 |
+
f"**As a:** {story['As a']}\n" \
|
49 |
+
f"**I want to:** {story['I want to']}\n" \
|
50 |
+
f"**So that:** {story['So that']}\n\n"
|
51 |
+
|
52 |
+
return formatted_stories
|
53 |
|
54 |
# Initialize session state for input history if it doesn't exist
|
55 |
if 'input_history' not in st.session_state:
|