Ashhar
commited on
Commit
·
031f614
1
Parent(s):
157791c
fix to prompt
Browse files- app.py +4 -3
- constants.py +5 -4
- pages/popular-stories.py +1 -1
app.py
CHANGED
@@ -81,7 +81,7 @@ def __isInvalidResponse(response: str):
|
|
81 |
return True
|
82 |
|
83 |
# lots of paragraphs
|
84 |
-
if len(re.findall(r'\n\n', response)) >
|
85 |
return True
|
86 |
|
87 |
# LLM API threw exception
|
@@ -243,7 +243,7 @@ def predict():
|
|
243 |
with client.messages.stream(
|
244 |
model=MODEL,
|
245 |
messages=messagesFormatted,
|
246 |
-
temperature=0.
|
247 |
system=C.SYSTEM_MSG,
|
248 |
max_tokens=4000,
|
249 |
) as stream:
|
@@ -389,6 +389,7 @@ if prompt := (
|
|
389 |
st.session_state["buttonValue"] = optionLabel
|
390 |
U.pprint(f"Selected: {optionLabel}")
|
391 |
|
|
|
392 |
responseParts = response.split(C.JSON_SEPARATOR)
|
393 |
|
394 |
jsonStr = None
|
@@ -424,7 +425,7 @@ if prompt := (
|
|
424 |
})
|
425 |
st.session_state.messages.append({
|
426 |
"role": "assistant",
|
427 |
-
"content":
|
428 |
})
|
429 |
|
430 |
if jsonStr:
|
|
|
81 |
return True
|
82 |
|
83 |
# lots of paragraphs
|
84 |
+
if len(re.findall(r'\n\n', response)) > 20:
|
85 |
return True
|
86 |
|
87 |
# LLM API threw exception
|
|
|
243 |
with client.messages.stream(
|
244 |
model=MODEL,
|
245 |
messages=messagesFormatted,
|
246 |
+
temperature=0.7,
|
247 |
system=C.SYSTEM_MSG,
|
248 |
max_tokens=4000,
|
249 |
) as stream:
|
|
|
389 |
st.session_state["buttonValue"] = optionLabel
|
390 |
U.pprint(f"Selected: {optionLabel}")
|
391 |
|
392 |
+
rawResponse = response
|
393 |
responseParts = response.split(C.JSON_SEPARATOR)
|
394 |
|
395 |
jsonStr = None
|
|
|
425 |
})
|
426 |
st.session_state.messages.append({
|
427 |
"role": "assistant",
|
428 |
+
"content": rawResponse,
|
429 |
})
|
430 |
|
431 |
if jsonStr:
|
constants.py
CHANGED
@@ -27,14 +27,15 @@ Keep options to less than 9.
|
|
27 |
Do not write anything after the JSON.
|
28 |
Keep options to less than 9.
|
29 |
|
30 |
-
- Rule 2:
|
31 |
-
And
|
32 |
```
|
33 |
{{
|
34 |
"action": "SHOW_STORY_DATABASE"
|
35 |
}}
|
36 |
```
|
37 |
Do not write anything after the JSON.
|
|
|
38 |
|
39 |
------
|
40 |
=> Task Definition:
|
@@ -45,8 +46,8 @@ Before giving any response, make sure to evaluate the "Format" rules described a
|
|
45 |
You initiate the storytelling process through a series of engaging prompts:
|
46 |
|
47 |
#### Story Origin:
|
48 |
-
- Asks users to choose between personal anecdotes or adapting a well-known real-life story
|
49 |
-
- If they choose to choose to adapt from a well known story, ask the user which story they would want to adapt
|
50 |
|
51 |
#### Story Use Case:
|
52 |
Asks users to define the purpose of building a story. It can be one of the following (provide very short description for each):
|
|
|
27 |
Do not write anything after the JSON.
|
28 |
Keep options to less than 9.
|
29 |
|
30 |
+
- Rule 2: In the MOST RECENT message, if the USER has chosen the option to adapt a well known story, then append this exact keyword "{JSON_SEPARATOR}" at the end of your FINAL answer.
|
31 |
+
And AFTER this, append a JSON in this format:
|
32 |
```
|
33 |
{{
|
34 |
"action": "SHOW_STORY_DATABASE"
|
35 |
}}
|
36 |
```
|
37 |
Do not write anything after the JSON.
|
38 |
+
Do this only once throughout the flow.
|
39 |
|
40 |
------
|
41 |
=> Task Definition:
|
|
|
46 |
You initiate the storytelling process through a series of engaging prompts:
|
47 |
|
48 |
#### Story Origin:
|
49 |
+
- Asks users to choose between personal anecdotes or adapting a well-known real-life story.
|
50 |
+
- If they choose to choose to adapt from a well known story, ask the user which story they would want to adapt and send append JSON as described above.
|
51 |
|
52 |
#### Story Use Case:
|
53 |
Asks users to define the purpose of building a story. It can be one of the following (provide very short description for each):
|
pages/popular-stories.py
CHANGED
@@ -30,7 +30,7 @@ col1, col2, col3 = storyPlaceholder.columns([1.5, 2.2, 1.5])
|
|
30 |
col2.image(C.DB_LOADER)
|
31 |
col2.write(
|
32 |
"""
|
33 |
-
<div class='blinking code large
|
34 |
Loading from database ...
|
35 |
</div>
|
36 |
""",
|
|
|
30 |
col2.image(C.DB_LOADER)
|
31 |
col2.write(
|
32 |
"""
|
33 |
+
<div class='blinking code large'>
|
34 |
Loading from database ...
|
35 |
</div>
|
36 |
""",
|