improved ui
Browse files- introduck/api.py +12 -3
- introduck/assets/static/favicon.ico +0 -0
- introduck/routes.py +58 -57
- main.py +2 -2
introduck/api.py
CHANGED
@@ -1,10 +1,19 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
from
|
|
|
|
|
3 |
|
4 |
|
5 |
-
def
|
6 |
api: FastAPI = FastAPI()
|
7 |
|
8 |
-
api.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
return api
|
1 |
from fastapi import FastAPI
|
2 |
+
from fastapi.responses import FileResponse
|
3 |
+
from introduck.routes import create_playground_route
|
4 |
+
from pathlib import Path
|
5 |
|
6 |
|
7 |
+
def create_api_playground() -> FastAPI:
|
8 |
api: FastAPI = FastAPI()
|
9 |
|
10 |
+
@api.get("/favicon.ico")
|
11 |
+
async def favicon():
|
12 |
+
cwd_path: Path = Path(__file__).parent
|
13 |
+
favicon_path: Path = cwd_path / "assets" / "static" / "favicon.ico"
|
14 |
+
print(f"favicon path is {favicon_path}")
|
15 |
+
return FileResponse(path=favicon_path)
|
16 |
+
|
17 |
+
api.mount("/", create_playground_route())
|
18 |
|
19 |
return api
|
introduck/assets/static/favicon.ico
ADDED
introduck/routes.py
CHANGED
@@ -55,7 +55,7 @@ def _use_message_template() -> (str, str):
|
|
55 |
return _INTRO_SUBJECT_EXAMPLE, _INTRO_MESSAGE_EXAMPLE
|
56 |
|
57 |
|
58 |
-
def
|
59 |
# TODO: Fix once resolved https://github.com/gradio-app/gradio/issues/1683
|
60 |
# TODO: ...and remove elem_id="htxt" from HighlightedText for RF822 output
|
61 |
css_workaround: str = """
|
@@ -65,62 +65,67 @@ def create_base_route(title: str = "") -> FastAPI:
|
|
65 |
}
|
66 |
"""
|
67 |
|
|
|
|
|
|
|
68 |
base_blocks: gr.Blocks = gr.Blocks(
|
69 |
analytics_enabled=False,
|
70 |
title=title,
|
71 |
css=css_workaround)
|
72 |
|
73 |
with base_blocks:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
gr.Markdown("""\
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
78 |
""")
|
79 |
|
80 |
-
with gr.Box():
|
81 |
-
with gr.Column():
|
82 |
-
gr.Markdown("## New intro request")
|
83 |
-
|
84 |
-
email_sender_input: gr.Textbox = gr.Textbox(
|
85 |
-
label="From:",
|
86 |
-
lines=1,
|
87 |
-
max_lines=1,
|
88 |
-
placeholder="founder@acme.com")
|
89 |
-
|
90 |
-
email_recipients_input: gr.Textbox = gr.Textbox(
|
91 |
-
label="To:",
|
92 |
-
lines=1,
|
93 |
-
max_lines=1,
|
94 |
-
placeholder="vc@example.com")
|
95 |
-
|
96 |
-
email_subject_input: gr.Textbox = gr.Textbox(
|
97 |
-
show_label=False,
|
98 |
-
lines=1,
|
99 |
-
max_lines=1,
|
100 |
-
placeholder="Subject...",
|
101 |
-
interactive=True)
|
102 |
-
|
103 |
-
email_body_input: gr.Textbox = gr.Textbox(
|
104 |
-
show_label=False,
|
105 |
-
lines=5,
|
106 |
-
max_lines=42,
|
107 |
-
placeholder="Type a message...",
|
108 |
-
interactive=True)
|
109 |
-
|
110 |
-
# TODO: Add support for attached files.
|
111 |
-
# email_attachments_input: gr.File = gr.File(
|
112 |
-
# label="Attachments:",
|
113 |
-
# file_count="multiple")
|
114 |
-
|
115 |
-
with gr.Row():
|
116 |
-
email_template_button: gr.Button = gr.Button(
|
117 |
-
value="Use template",
|
118 |
-
variant="secondary")
|
119 |
-
|
120 |
-
email_submit_button: gr.Button = gr.Button(
|
121 |
-
value="Submit",
|
122 |
-
variant="primary")
|
123 |
-
|
124 |
with gr.Tabs(selected="default"):
|
125 |
with gr.TabItem(label="Contacts", id="default"):
|
126 |
contacts_table_headers: list[str] = [
|
@@ -160,12 +165,12 @@ def create_base_route(title: str = "") -> FastAPI:
|
|
160 |
gr.Markdown("Yes!")
|
161 |
|
162 |
gr.Markdown("""\
|
163 |
-
[Contact us](
|
164 |
-
[Terms of Service](
|
165 |
-
[Privacy Policy](
|
166 |
""")
|
167 |
|
168 |
-
gr.Markdown("**©**
|
169 |
|
170 |
# ui end, continue with signals and slots...
|
171 |
|
@@ -187,8 +192,4 @@ def create_base_route(title: str = "") -> FastAPI:
|
|
187 |
rejection_template_output,
|
188 |
rfc822_output])
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
# TODO: overwrite /favicon.ico
|
193 |
-
|
194 |
-
return base_route
|
55 |
return _INTRO_SUBJECT_EXAMPLE, _INTRO_MESSAGE_EXAMPLE
|
56 |
|
57 |
|
58 |
+
def create_playground_route() -> FastAPI:
|
59 |
# TODO: Fix once resolved https://github.com/gradio-app/gradio/issues/1683
|
60 |
# TODO: ...and remove elem_id="htxt" from HighlightedText for RF822 output
|
61 |
css_workaround: str = """
|
65 |
}
|
66 |
"""
|
67 |
|
68 |
+
copyright_string: str = "Introduck LLC, 2022"
|
69 |
+
title: str = "Introduck Playground"
|
70 |
+
|
71 |
base_blocks: gr.Blocks = gr.Blocks(
|
72 |
analytics_enabled=False,
|
73 |
title=title,
|
74 |
css=css_workaround)
|
75 |
|
76 |
with base_blocks:
|
77 |
+
gr.Markdown(f"# {title}<br/>")
|
78 |
+
|
79 |
+
gr.Markdown("## New intro request")
|
80 |
+
|
81 |
+
email_sender_input: gr.Textbox = gr.Textbox(
|
82 |
+
label="From (optional):",
|
83 |
+
lines=1,
|
84 |
+
max_lines=1,
|
85 |
+
placeholder="founder@acme.com")
|
86 |
+
|
87 |
+
email_recipients_input: gr.Textbox = gr.Textbox(
|
88 |
+
label="To (optional):",
|
89 |
+
lines=1,
|
90 |
+
max_lines=1,
|
91 |
+
placeholder="jane@vc2.com, john@vc01.com")
|
92 |
+
|
93 |
+
email_subject_input: gr.Textbox = gr.Textbox(
|
94 |
+
show_label=False,
|
95 |
+
lines=1,
|
96 |
+
max_lines=1,
|
97 |
+
placeholder="Subject...",
|
98 |
+
interactive=True)
|
99 |
+
|
100 |
+
email_body_input: gr.Textbox = gr.Textbox(
|
101 |
+
show_label=False,
|
102 |
+
lines=5,
|
103 |
+
max_lines=42,
|
104 |
+
placeholder="Type a message...",
|
105 |
+
interactive=True)
|
106 |
+
|
107 |
+
# TODO: Add support for attached files.
|
108 |
+
# email_attachments_input: gr.File = gr.File(
|
109 |
+
# label="Attachments:",
|
110 |
+
# file_count="multiple")
|
111 |
+
|
112 |
+
with gr.Row():
|
113 |
+
email_template_button: gr.Button = gr.Button(
|
114 |
+
value="Use template",
|
115 |
+
variant="secondary")
|
116 |
+
|
117 |
+
email_submit_button: gr.Button = gr.Button(
|
118 |
+
value="Submit",
|
119 |
+
variant="primary")
|
120 |
+
|
121 |
gr.Markdown("""\
|
122 |
+
**NOTE:** This email form is used to extract useful information from
|
123 |
+
intro requests. We assure you that no data will be shared publicly
|
124 |
+
and only a small group of people will get access to this data in
|
125 |
+
order to label it and create new datasets for model training. By
|
126 |
+
clicking **"Submit"** you automatically agree to this terms.\
|
127 |
""")
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
with gr.Tabs(selected="default"):
|
130 |
with gr.TabItem(label="Contacts", id="default"):
|
131 |
contacts_table_headers: list[str] = [
|
165 |
gr.Markdown("Yes!")
|
166 |
|
167 |
gr.Markdown("""\
|
168 |
+
[Contact us](mailto:hello@introduck.ai) /
|
169 |
+
[Terms of Service](https://introduck.ai/terms) /
|
170 |
+
[Privacy Policy](https://introduck.ai/privacy)
|
171 |
""")
|
172 |
|
173 |
+
gr.Markdown(f"**©** {copyright_string}")
|
174 |
|
175 |
# ui end, continue with signals and slots...
|
176 |
|
192 |
rejection_template_output,
|
193 |
rfc822_output])
|
194 |
|
195 |
+
return GradioApp.create_app(blocks=base_blocks)
|
|
|
|
|
|
|
|
main.py
CHANGED
@@ -8,6 +8,6 @@ Usage examples:
|
|
8 |
"""
|
9 |
|
10 |
from fastapi import FastAPI
|
11 |
-
from introduck.api import
|
12 |
|
13 |
-
app: FastAPI =
|
8 |
"""
|
9 |
|
10 |
from fastapi import FastAPI
|
11 |
+
from introduck.api import create_api_playground
|
12 |
|
13 |
+
app: FastAPI = create_api_playground()
|