Skip to content

Commit

Permalink
show custom urls in uppy
Browse files Browse the repository at this point in the history
rename Custom URLs -> Submit Links in Bulk
  • Loading branch information
devxpy committed Feb 9, 2024
1 parent a8382ae commit d648157
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
3 changes: 3 additions & 0 deletions daras_ai_v2/bot_integration_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def general_integration_settings(bi: BotIntegration):
st.session_state[f"_bi_user_language_{bi.id}"] = BotIntegration._meta.get_field(
"user_language"
).default
st.session_state[f"_bi_streaming_enabled_{bi.id}"] = (
BotIntegration._meta.get_field("streaming_enabled").default
)
st.session_state[f"_bi_show_feedback_buttons_{bi.id}"] = (
BotIntegration._meta.get_field("show_feedback_buttons").default
)
Expand Down
8 changes: 3 additions & 5 deletions daras_ai_v2/doc_search_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ def document_uploader(
documents = st.session_state.get(key) or []
if isinstance(documents, str):
documents = [documents]
has_custom_urls = not all(map(is_user_uploaded_url, documents))
custom_key = "__custom_" + key
if st.checkbox(
"Enter Custom URLs", key=f"__custom_checkbox_{key}", value=has_custom_urls
):
if st.session_state.get(f"__custom_checkbox_{key}"):
if not custom_key in st.session_state:
st.session_state[custom_key] = "\n".join(documents)
if accept_multiple_files:
Expand All @@ -67,7 +64,7 @@ def document_uploader(
**kwargs,
)
if accept_multiple_files:
st.session_state[key] = text_value.strip().splitlines()
st.session_state[key] = filter(None, text_value.strip().splitlines())
else:
st.session_state[key] = text_value
else:
Expand All @@ -79,6 +76,7 @@ def document_uploader(
accept=accept,
accept_multiple_files=accept_multiple_files,
)
st.checkbox("Submit Links in Bulk", key=f"__custom_checkbox_{key}")
documents = st.session_state.get(key, [])
try:
documents = list(_expand_gdrive_folders(documents))
Expand Down
4 changes: 1 addition & 3 deletions gooey_ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ def text_area(
# assert not value, "only one of value or key can be provided"
# else:
if not key:
key = md5_values(
"textarea", label, height, help, value, placeholder, label_visibility
)
key = md5_values("textarea", label, height, help, placeholder, label_visibility)
value = str(state.session_state.setdefault(key, value) or "")
if label_visibility != "visible":
label = None
Expand Down
17 changes: 3 additions & 14 deletions recipes/QRCodeGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,9 @@ def vcard_form(*, key: str) -> VCARD:
st.error("No contact info found for that email")
else:
vcard = imported_vcard
# clear inputs
st.js(
# language=js
"""
const form = document.getElementById("gooey-form");
if (!form) return;
Object.entries(fields).forEach(([k, v]) => {
const field = form["__vcard_data__" + k];
if (!field) return;
field.value = v;
});
""",
fields=vcard.dict(),
)
# update inputs
for k, v in vcard.dict().items():
st.session_state[f"__vcard_data__{k}"] = v

vcard.format_name = st.text_input(
"Name*",
Expand Down
6 changes: 6 additions & 0 deletions routers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
RedirectException,
get_example_request_body,
)
from daras_ai_v2.bots import request_json
from daras_ai_v2.copy_to_clipboard_button_widget import copy_to_clipboard_scripts
from daras_ai_v2.db import FIREBASE_SESSION_COOKIE
from daras_ai_v2.manage_api_keys_widget import manage_api_keys
Expand Down Expand Up @@ -165,6 +166,11 @@ async def logout(request: Request):
return RedirectResponse(request.query_params.get("next", DEFAULT_LOGOUT_REDIRECT))


@app.post("/__/file-upload/url/meta")
async def file_upload(request: Request, body_json: dict = Depends(request_json)):
return dict(name=(body_json["url"]), type="url/undefined", size=None)


@app.post("/__/file-upload/")
def file_upload(request: Request, form_data: FormData = Depends(request_form_files)):
from wand.image import Image
Expand Down

0 comments on commit d648157

Please sign in to comment.