Spaces:
Sleeping
Sleeping
alexanderHSG commited on
Commit ·
2b84a2c
1
Parent(s): d927a2f
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,9 +62,9 @@ def format_chat_prompt(message, chat_history, max_convo_length):
|
|
| 62 |
|
| 63 |
#this is a simple prompt that takes a storyline prompt and formats an output in json to return a storyline of X slides.
|
| 64 |
def slide_deck_storyline(storyline_prompt, nr_of_storypoints=5):
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
You know how tell a compelling, structure and exhaustive narrative around any given academic topic.
|
| 69 |
What you are particularly good at, is taking any given input and building a storyline in the delivered as
|
| 70 |
{nr_of_storypoints} storypoints and nothing else. This is your only chance to impress me.
|
|
@@ -80,7 +80,7 @@ def slide_deck_storyline(storyline_prompt, nr_of_storypoints=5):
|
|
| 80 |
The elements of the list should be storypoints, highlighting what the point the sliStorypoint is trying to make is.
|
| 81 |
"""
|
| 82 |
|
| 83 |
-
|
| 84 |
model = "gpt-4o",
|
| 85 |
response_format = {"type": "json_object"},
|
| 86 |
messages = [
|
|
@@ -88,17 +88,17 @@ def slide_deck_storyline(storyline_prompt, nr_of_storypoints=5):
|
|
| 88 |
{"role": "user", "content": storyline_prompt}],
|
| 89 |
temperature=0
|
| 90 |
)
|
| 91 |
-
|
| 92 |
-
|
| 93 |
#pretty_list = "\n".join([f"⚡ {key}: {value}" for key, value in map.items()])
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
#add one column to the list with the name of the storypoint
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
| 102 |
|
| 103 |
|
| 104 |
#this is a prompt that takes a filter prompt and formats an output in json to return a filter cypress query.
|
|
@@ -446,10 +446,7 @@ async () => {
|
|
| 446 |
SLIDE_DECK: {
|
| 447 |
label: "title",
|
| 448 |
|
| 449 |
-
|
| 450 |
-
// This function returns HTML content that will be shown as tooltip
|
| 451 |
-
return `<b>Name:</b> ${node.properties.title}<br/>;
|
| 452 |
-
}
|
| 453 |
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {
|
| 454 |
static: {
|
| 455 |
caption: "title",
|
|
@@ -709,9 +706,9 @@ Outcome: Fellow consultant will develop a comprehensive understanding of AI's po
|
|
| 709 |
btn_buildstoryline.click(slide_deck_storyline,
|
| 710 |
inputs = [storyline_prompt, nr_storypoints_to_build],
|
| 711 |
outputs = [storyline_output_JSON, storyline_output_storypoint_name_list]
|
| 712 |
-
).then(track_user_interaction, inputs=[storyline_prompt, gr.Textbox("build storyline prompt", visible=False)]
|
| 713 |
-
).then(track_user_interaction, inputs=[storyline_output_storypoint_name_list, gr.Textbox("build storyline gpt output", visible=False)]
|
| 714 |
-
).then(track_user_interaction, inputs=[nr_storypoints_to_build, gr.Textbox("build storyline number of points", visible=False)])
|
| 715 |
|
| 716 |
storyline_prompt.submit(slide_deck_storyline,
|
| 717 |
inputs = [storyline_prompt, nr_storypoints_to_build],
|
|
@@ -740,7 +737,7 @@ Outcome: Fellow consultant will develop a comprehensive understanding of AI's po
|
|
| 740 |
).then(js = js_call_draw)
|
| 741 |
|
| 742 |
with gr.Column(scale=2):
|
| 743 |
-
custom_filtering_output = gr.Textbox(lines=2, scale=3, interactive=True, label = "Describe what you would like to filter for?", placeholder = """For example: """)
|
| 744 |
customfilter_btn = gr.Button("Apply custom filter")
|
| 745 |
customfilter_btn.click(custom_filtering, inputs=[custom_filtering_output, queryPlaceholder, responsePlaceholder], outputs=[graphVisual, customFilterQuery]
|
| 746 |
).then(track_user_interaction, inputs=[custom_filtering_output, gr.Textbox("customFilterPrompt", visible=False)]
|
|
|
|
| 62 |
|
| 63 |
#this is a simple prompt that takes a storyline prompt and formats an output in json to return a storyline of X slides.
|
| 64 |
def slide_deck_storyline(storyline_prompt, nr_of_storypoints=5):
|
| 65 |
+
print("hi")
|
| 66 |
+
nr_of_storypoints = str(nr_of_storypoints)
|
| 67 |
+
system_prompt = f"""You are an AI particularly skilled at captivating storytelling for educational purposes.
|
| 68 |
You know how tell a compelling, structure and exhaustive narrative around any given academic topic.
|
| 69 |
What you are particularly good at, is taking any given input and building a storyline in the delivered as
|
| 70 |
{nr_of_storypoints} storypoints and nothing else. This is your only chance to impress me.
|
|
|
|
| 80 |
The elements of the list should be storypoints, highlighting what the point the sliStorypoint is trying to make is.
|
| 81 |
"""
|
| 82 |
|
| 83 |
+
response = openai.chat.completions.create(
|
| 84 |
model = "gpt-4o",
|
| 85 |
response_format = {"type": "json_object"},
|
| 86 |
messages = [
|
|
|
|
| 88 |
{"role": "user", "content": storyline_prompt}],
|
| 89 |
temperature=0
|
| 90 |
)
|
| 91 |
+
res = response.choices[0].message.content
|
| 92 |
+
map = json.loads(res)
|
| 93 |
#pretty_list = "\n".join([f"⚡ {key}: {value}" for key, value in map.items()])
|
| 94 |
+
storypoint_name_list = [map[key] for key in map]
|
| 95 |
+
storypoint_name_nested = [storypoint_name_list]
|
| 96 |
+
storypoint_name_nested = list(zip(*storypoint_name_nested))
|
| 97 |
#add one column to the list with the name of the storypoint
|
| 98 |
|
| 99 |
+
storypoint_name_nested = [[f"SP {i}", item] for i, item in enumerate(storypoint_name_nested, 1)]
|
| 100 |
|
| 101 |
+
return map, storypoint_name_nested
|
| 102 |
|
| 103 |
|
| 104 |
#this is a prompt that takes a filter prompt and formats an output in json to return a filter cypress query.
|
|
|
|
| 446 |
SLIDE_DECK: {
|
| 447 |
label: "title",
|
| 448 |
|
| 449 |
+
|
|
|
|
|
|
|
|
|
|
| 450 |
[NeoVis.NEOVIS_ADVANCED_CONFIG]: {
|
| 451 |
static: {
|
| 452 |
caption: "title",
|
|
|
|
| 706 |
btn_buildstoryline.click(slide_deck_storyline,
|
| 707 |
inputs = [storyline_prompt, nr_storypoints_to_build],
|
| 708 |
outputs = [storyline_output_JSON, storyline_output_storypoint_name_list]
|
| 709 |
+
)#.then(track_user_interaction, inputs=[storyline_prompt, gr.Textbox("build storyline prompt", visible=False)]
|
| 710 |
+
#).then(track_user_interaction, inputs=[storyline_output_storypoint_name_list, gr.Textbox("build storyline gpt output", visible=False)]
|
| 711 |
+
#).then(track_user_interaction, inputs=[nr_storypoints_to_build, gr.Textbox("build storyline number of points", visible=False)])
|
| 712 |
|
| 713 |
storyline_prompt.submit(slide_deck_storyline,
|
| 714 |
inputs = [storyline_prompt, nr_storypoints_to_build],
|
|
|
|
| 737 |
).then(js = js_call_draw)
|
| 738 |
|
| 739 |
with gr.Column(scale=2):
|
| 740 |
+
custom_filtering_output = gr.Textbox(lines=2, scale=3, interactive=True, label = "Describe what you would like to filter for?", placeholder = """For example: 'Filter to only show slides and their respective slide decks that are assigned to the third STORYPOINT'""")
|
| 741 |
customfilter_btn = gr.Button("Apply custom filter")
|
| 742 |
customfilter_btn.click(custom_filtering, inputs=[custom_filtering_output, queryPlaceholder, responsePlaceholder], outputs=[graphVisual, customFilterQuery]
|
| 743 |
).then(track_user_interaction, inputs=[custom_filtering_output, gr.Textbox("customFilterPrompt", visible=False)]
|