chainyo commited on
Commit
d9c2461
β€’
1 Parent(s): e6974a3

add input-check and first ui stuff

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. README.md +5 -5
  3. api.py +25 -0
  4. app.py +56 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__/
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
- title: Kwest.dev
3
- emoji: ⚑
4
- colorFrom: yellow
5
- colorTo: red
6
  sdk: streamlit
7
  sdk_version: 1.37.0
8
  app_file: app.py
9
- pinned: false
10
  license: apache-2.0
11
  ---
12
 
 
1
  ---
2
+ title: kwest.dev
3
+ emoji: πŸͺ„
4
+ colorFrom: blue
5
+ colorTo: magenta
6
  sdk: streamlit
7
  sdk_version: 1.37.0
8
  app_file: app.py
9
+ pinned: true
10
  license: apache-2.0
11
  ---
12
 
api.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """API interactions for the Kwest API."""
2
+
3
+ import os
4
+
5
+ import requests
6
+
7
+
8
+ API_URL = os.getenv("API_URL", None)
9
+ AUTH_TOKEN = os.getenv("AUTH_TOKEN", None)
10
+
11
+ if not API_URL or not AUTH_TOKEN:
12
+ raise ValueError("API_URL and AUTH_TOKEN secrets must be set in the environment variables.")
13
+
14
+
15
+ def check_if_input_is_valid(input_str: str) -> bool:
16
+ """Check if the input string is valid for the API."""
17
+ response = requests.post(
18
+ f"{API_URL}/check-input",
19
+ headers={"Authorization": f"{AUTH_TOKEN}"},
20
+ json={"input": input_str},
21
+ )
22
+ if response.status_code == 200:
23
+ return response.json()["output"]
24
+ else:
25
+ return None
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """kwest.dev is a saas tool to craft stories for your ideas."""
2
+
3
+ import streamlit as st
4
+
5
+ from api import check_if_input_is_valid
6
+
7
+ RECIPES = ["sell", "motivate", "convince", "connect", "explain", "lead", "impress"]
8
+ VALID_EMOJIS = {"yes": "βœ…", "no": "❌"}
9
+
10
+
11
+ st.title("kwest.dev")
12
+ st.subheader("Leverage the power of storytelling for any idea. πŸ’‘")
13
+
14
+ with st.expander(label="How to present your idea to get the best story πŸ‘‡", expanded=True):
15
+ st.markdown(
16
+ """
17
+ - 🎯 Explain the **main objective** of your idea. What is the **main goal** you are trying to achieve?
18
+ - πŸ“ Give as much **context** as possible. For example, what is the problem you are trying to solve? If you have a good name for your idea, share it.
19
+ - πŸ‘€ What is the **audience** for your idea? Who are the people that should be interested in it?
20
+
21
+ Once you have shared this information, we will propose 2 recipes for your story. Choose the one you like the most between the two.
22
+
23
+ The different recipes available are: `sell`, `motivate`, `convince`, `connect`, `explain`, `lead`, `impress`
24
+
25
+ If you aren't satisfied with the recipes proposed, you can choose a different one below.
26
+
27
+ __Examples of good and bad inputs:__
28
+
29
+ βœ… `I need a pitch for a new app that helps people find the best restaurants in town. I will present it to angel investors. The name of the app is "Foodie".`
30
+
31
+ ❌ `I need a pitch for a new app. It's cool.`
32
+ """
33
+ )
34
+
35
+ input_col, btn_col = st.columns([3, 1], vertical_alignment="bottom")
36
+ with input_col:
37
+ input_str = st.text_area("Your idea that needs a story", "", placeholder="I need a pitch for ...")
38
+ with btn_col:
39
+ input_is_valid = st.button(
40
+ label="▢️",
41
+ key="check_input",
42
+ help="Check if the input is valid",
43
+ on_click=check_if_input_is_valid,
44
+ kwargs={"input_str": input_str}
45
+ )
46
+
47
+ if input_is_valid:
48
+ st.write(
49
+ f"Objective: {VALID_EMOJIS[input_is_valid['objective']]} | "
50
+ f"Context: {VALID_EMOJIS[input_is_valid['context']]} | "
51
+ f"Audience: {VALID_EMOJIS[input_is_valid['audience']]}"
52
+ )
53
+
54
+ if input_is_valid["objective"] == "yes" and input_is_valid["context"] == "yes" and input_is_valid["audience"] == "yes":
55
+ st.write("Choose the recipe you want to use for your story.")
56
+