Application API¶

app.py is the user-interface shell for Boo that coordinates model selection, mode selection, user
inputs, uploaded files, provider routing, result rendering, and session-state persistence.
Module Responsibilities¶
The application module normally owns the following responsibilities:
| Area | Responsibility |
|---|---|
| Page setup | Configure Streamlit page metadata, layout, title, branding, and top-level containers. |
| Navigation | Render tabs, expanders, sidebars, model selectors, mode selectors, and workflow controls. |
| Session state | Initialize, read, and update st.session_state keys used across reruns. |
| Provider routing | Dispatch user requests to gpt.py, gemini.py, or grok.py based on selected provider/model. |
| Input handling | Read text prompts, uploaded documents, URLs, audio files, images, and workflow options. |
| Output rendering | Display responses, errors, metrics, tables, images, files, and downloadable artifacts. |
| Error handling | Convert runtime exceptions into clear user-facing messages and developer-friendly logs. |
Streamlit Import Warning¶
Streamlit application files often execute UI code at import time. That can make direct
mkdocstrings documentation fragile because MkDocs imports the module during the build.
If this page causes mkdocs build to fail, remove app temporarily and document import-safe
helper modules instead. A better long-term design is to move reusable application logic into modules
that do not render Streamlit widgets at import time.
Recommended import-safe module candidates include:
src/app_services.py
src/session_state.py
src/provider_router.py
src/rendering.py
src/file_services.py
Session-State Contract¶
The application should use explicit session-state keys for values that must survive Streamlit reruns. The exact keys depend on the current source code, but the application should generally separate these categories:
| State Category | Example Keys |
|---|---|
| Selection state | selected_model_name, selected_mode_name, selected_provider_name |
| Input state | prompt_text, uploaded_files, uploaded_documents, allow_domains |
| Intermediate state | parsed_documents, chunked_documents, embedding_results |
| Provider state | provider_client_status, vector_store_id, file_ids |
| Output state | chat_response, image_response, audio_response, dataframe_response |
| UI state | active_tab, show_advanced_options, sidebar_expanded |
Session-state keys should be written before they are read. Keys should not be reused for unrelated data structures.
Workflow Routing¶
A typical application workflow should follow this pattern:
- Read the selected provider, model, and mode from Streamlit controls.
- Validate required user inputs for the selected mode.
- Instantiate or call the correct provider wrapper.
- Execute the provider method.
- Normalize the result for display.
- Save the result to session state if it is needed after rerun.
- Render the result in the appropriate UI panel.
Documentation Guidance¶
Public helper functions in app.py should use Google-style docstrings so they can be rendered by
MkDocs when the module is import-safe.
A recommended docstring pattern is:
def render_text_mode( selected_model_name: str ) -> None:
"""
Purpose:
Render the text-generation workflow for the selected model.
Args:
selected_model_name (str): Name of the model selected in the Streamlit UI.
Returns:
None: Writes Streamlit controls and output directly to the page.
"""
API Reference¶
The section below is generated from the source module when mkdocs build runs.
app ¶
Assembly: Boo
Filename: app.py
Author: Terry D. Eppler
Created: 05-31-2024
Last Modified By: Terry D. Eppler
Last Modified On: 05-01-2025
Boo is a data analysis tool integrating various Generative GPT, Text-Processing, and
Machine-Learning algorithms for federal analysts.
Copyright © 2022 Terry Eppler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You can contact me at: terryeppler@gmail.com or eppler.terry@epa.gov
throw_if ¶
Throw if.
Purpose
Validates that a required argument contains a usable value before the surrounding workflow continues. This guard centralizes early validation so provider wrappers and UI routines fail with consistent, readable error messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name value used by the operation. |
required |
value
|
object
|
Value value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
get_runtime_config_value ¶
Get runtime config value.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_key
|
str
|
Session key value used by the operation. |
required |
config_name
|
str
|
Config name value used by the operation. |
required |
env_name
|
str
|
Env name value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
sync_provider_config ¶
sync_provider_config(
session_key: str,
config_name: str,
env_name: str,
value: Any,
provider: Optional[str] = None,
) -> None
Sync provider config.
Purpose
Performs the sync_provider_config workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_key
|
str
|
Session key value used by the operation. |
required |
config_name
|
str
|
Config name value used by the operation. |
required |
env_name
|
str
|
Env name value used by the operation. |
required |
value
|
Any
|
Value value used by the operation. |
required |
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
init_env_state ¶
init_env_state(
key: str,
config_name: str,
env_name: str,
provider: Optional[str] = None,
) -> None
Init env state.
Purpose
Performs the init_env_state workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Key value used by the operation. |
required |
config_name
|
str
|
Config name value used by the operation. |
required |
env_name
|
str
|
Env name value used by the operation. |
required |
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
copy_state_alias ¶
Copy state alias.
Purpose
Performs the copy_state_alias workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_key
|
str
|
Source key value used by the operation. |
required |
target_key
|
str
|
Target key value used by the operation. |
required |
default
|
Any
|
Default value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
extract_response_text ¶
Extract response text.
Purpose
Extracts structured information from a provider response, uploaded file, or application data object. The function normalizes provider-specific shapes into values that can be rendered, stored, or passed to later processing steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
object
|
Response value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
encode_image_base64 ¶
Encode image base64.
Purpose
Performs the encode_image_base64 workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
sanitize_markdown ¶
Sanitize markdown.
Purpose
Performs the sanitize_markdown workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
init_state ¶
Init state.
Purpose
Performs the init_state workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
reset_state ¶
Reset state.
Purpose
Removes or resets the requested application state or provider resource in a controlled manner. The function keeps cleanup behavior centralized so callers do not duplicate lifecycle logic.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
extract_answer ¶
Extract answer.
Purpose
Extracts structured information from a provider response, uploaded file, or application data object. The function normalizes provider-specific shapes into values that can be rendered, stored, or passed to later processing steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
Response value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
extract_sources ¶
Extract sources.
Purpose
Extracts structured information from a provider response, uploaded file, or application data object. The function normalizes provider-specific shapes into values that can be rendered, stored, or passed to later processing steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
Response value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Return value produced by the operation. |
Source code in app.py
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
extract_analysis ¶
Extract analysis.
Purpose
Extracts structured information from a provider response, uploaded file, or application data object. The function normalizes provider-specific shapes into values that can be rendered, stored, or passed to later processing steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
Response value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Return value produced by the operation. |
Source code in app.py
save_temp ¶
Save temp.
Purpose
Persists or stages input data so it can be used by later provider or application workflows. The function standardizes file handling and returns a stable reference for downstream processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upload
|
object
|
Upload value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Optional[str]: Return value produced by the operation. |
Source code in app.py
update_token_counters ¶
Update token counters.
Purpose
Performs the update_token_counters workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resp
|
Any
|
Resp value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
count_tokens ¶
Count tokens.
Purpose
Performs the count_tokens workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Return value produced by the operation. |
Source code in app.py
normalize_storage_object ¶
Normalize storage object.
Purpose
Normalizes incoming values into a predictable representation for application processing. The function reduces provider, user-input, or serialization differences before values are stored or displayed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Return value produced by the operation. |
Source code in app.py
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 | |
render_storage_metadata ¶
Render storage metadata.
Purpose
Renders the requested user interface element or result block in Streamlit using normalized inputs. The function keeps presentation logic isolated from provider calls and data-processing steps so the screen output remains predictable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
Dict[str, Any]
|
Metadata value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
save_uploaded_storage_file ¶
Save uploaded storage file.
Purpose
Persists or stages input data so it can be used by later provider or application workflows. The function standardizes file handling and returns a stable reference for downstream processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Uploaded file value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Return value produced by the operation. |
Source code in app.py
normalize_text ¶
Normalize text.
Purpose
Normalizes incoming values into a predictable representation for application processing. The function reduces provider, user-input, or serialization differences before values are stored or displayed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
convert_xml ¶
Convert xml.
Purpose
Performs the convert_xml workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
convert_markdown ¶
Convert markdown.
Purpose
Performs the convert_markdown workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
Any
|
Text value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
inject_response_css ¶
Inject response css.
Purpose
Performs the inject_response_css workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
style_subheaders ¶
Style subheaders.
Purpose
Performs the style_subheaders workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
apply_gemini_runtime_config ¶
Apply gemini runtime config.
Purpose
Supports the apply gemini runtime config application workflow by coordinating validated inputs, Streamlit session state, provider configuration, and local data processing.
Source code in app.py
extract_text_from_bytes ¶
Extract text from bytes.
Purpose
Extracts structured information from a provider response, uploaded file, or application data object. The function normalizes provider-specific shapes into values that can be rendered, stored, or passed to later processing steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_bytes
|
bytes
|
File bytes value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
route_document_query ¶
Route document query.
Purpose
Performs the route_document_query workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Prompt value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 | |
summarize_active_document ¶
Summarize active document.
Purpose
Performs the summarize_active_document workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
load_embedder ¶
Load embedder.
Purpose
Performs the load_embedder workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
SentenceTransformer |
SentenceTransformer
|
Return value produced by the operation. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
retrieve_top_doc_chunks ¶
Retrieve top doc chunks.
Purpose
Performs the retrieve_top_doc_chunks workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Query value used by the operation. |
required |
k
|
int
|
K value used by the operation. |
6
|
Returns:
| Type | Description |
|---|---|
List[Tuple[str, str, float]]
|
List[Tuple[str, str, float]]: Return value produced by the operation. |
Source code in app.py
build_document_user_input ¶
Build document user input.
Purpose
Builds the normalized data structure required by the application workflow. The function converts caller input, session state, or provider-specific options into a stable shape that downstream API calls and rendering code can consume safely.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_query
|
str
|
User query value used by the operation. |
required |
k
|
int
|
K value used by the operation. |
6
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
initialize_database ¶
Initialize database.
Purpose
Performs the initialize_database workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 | |
read_table ¶
Read table.
Purpose
Performs the read_table workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table value used by the operation. |
required |
limit
|
int
|
Limit value used by the operation. |
None
|
offset
|
int
|
Offset value used by the operation. |
0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Return value produced by the operation. |
Source code in app.py
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 | |
render_table ¶
Render table.
Purpose
Renders the requested user interface element or result block in Streamlit using normalized inputs. The function keeps presentation logic isolated from provider calls and data-processing steps so the screen output remains predictable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Df value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
drop_table ¶
Drop table.
Purpose
Performs the drop_table workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
create_index ¶
Create index.
Purpose
Creates the requested resource, connection, schema object, or user interface artifact using validated inputs. The function encapsulates setup details so callers can rely on a consistent resource lifecycle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Table value used by the operation. |
required |
column
|
str
|
Column value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
create_visualization ¶
Create visualization.
Purpose
Creates the requested resource, connection, schema object, or user interface artifact using validated inputs. The function encapsulates setup details so callers can rely on a consistent resource lifecycle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Df value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 | |
get_sqlite_type ¶
Get sqlite type.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
object
|
Dtype value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
create_custom_table ¶
Create custom table.
Purpose
Creates the requested resource, connection, schema object, or user interface artifact using validated inputs. The function encapsulates setup details so callers can rely on a consistent resource lifecycle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_name
|
str
|
Table name value used by the operation. |
required |
columns
|
list
|
Columns value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
is_safe_query ¶
Is safe query.
Purpose
Performs the is_safe_query workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Query value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Return value produced by the operation. |
Source code in app.py
create_identifier ¶
Create identifier.
Purpose
Creates the requested resource, connection, schema object, or user interface artifact using validated inputs. The function encapsulates setup details so callers can rely on a consistent resource lifecycle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
rename_column ¶
Rename column.
Purpose
Performs the rename_column workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_name
|
str
|
Table name value used by the operation. |
required |
old_name
|
str
|
Old name value used by the operation. |
required |
new_name
|
str
|
New name value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 | |
rename_table ¶
Rename table.
Purpose
Performs the rename_table workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_name
|
str
|
Old name value used by the operation. |
required |
new_name
|
str
|
New name value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 | |
fetch_prompt_categories ¶
Fetch prompt categories.
Purpose
Returns populated prompt categories authorized for the selected application mode. Categories retain their configured display order and categories without corresponding database records are excluded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode_name
|
str
|
Application mode used to determine the permitted prompt categories. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Ordered prompt categories available to the selected mode. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
fetch_prompt_options ¶
Fetch prompt options.
Purpose
Returns prompt-template identifiers and display metadata for the selected category. The result provides stable numeric identifiers for widget state while preserving captions for presentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Prompt category used to filter the available templates. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Prompt identifiers and display metadata ordered by caption and |
List[Dict[str, Any]]
|
identifier. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
fetch_prompt_by_id ¶
Fetch prompt by identifier.
Purpose
Returns the complete prompt-template record associated with a stable numeric identifier. The identifier-based lookup prevents ambiguous template selection when captions or names are duplicated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id
|
int
|
Numeric primary key of the prompt-template record. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]]: Complete prompt-template record when found; otherwise None. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
reset_prompt_template_selection ¶
Reset prompt template selection.
Purpose
Clears a mode-specific prompt-template selection when its category changes without modifying the current system-instruction text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id_key
|
str
|
Session-state key storing the selected prompt identifier. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
load_prompt_template ¶
Load prompt template.
Purpose
Loads the selected prompt body into a mode-specific system-instruction field while preserving independent template state across application modes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id_key
|
str
|
Session-state key storing the selected prompt identifier. |
required |
instructions_key
|
str
|
Session-state key receiving the selected prompt body. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
format_prompt_option ¶
Format prompt option.
Purpose
Resolves a prompt identifier to its human-readable caption for presentation in a Streamlit selection control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id
|
int
|
Numeric prompt identifier rendered by the selection control. |
required |
prompt_options
|
List[Dict[str, Any]]
|
Available prompt records used to resolve the caption. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Prompt caption when found; otherwise the numeric identifier as text. |
Source code in app.py
fetch_prompts_df ¶
Fetch prompts dataframe.
Purpose
Returns prompt-template metadata for management and review without rendering large prompt bodies directly in the primary data grid.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Prompt-template metadata with a selection column. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
insert_prompt ¶
Insert prompt.
Purpose
Creates a prompt-template record using the canonical category-aware prompt schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Prompt-template values containing Caption, Name, Category, and Prompt. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
update_prompt ¶
Update prompt.
Purpose
Updates an existing prompt-template record using the canonical category-aware prompt schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id
|
int
|
Numeric primary key of the prompt-template record. |
required |
data
|
Dict[str, Any]
|
Replacement Caption, Name, Category, and Prompt values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
delete_prompt ¶
Delete prompt.
Purpose
Removes the prompt-template record associated with the supplied numeric identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id
|
int
|
Numeric primary key of the prompt-template record. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
build_prompt ¶
Build prompt.
Purpose
Builds the normalized data structure required by the application workflow. The function converts caller input, session state, or provider-specific options into a stable shape that downstream API calls and rendering code can consume safely.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_input
|
str
|
User input value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 | |
get_provider_name ¶
Get provider name.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
get_provider_module ¶
Get provider module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
provider_has_class ¶
Provider has class.
Purpose
Performs the provider_has_class workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
str
|
Class name value used by the operation. |
required |
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Return value produced by the operation. |
Source code in app.py
get_provider_class ¶
Get provider class.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
str
|
Class name value used by the operation. |
required |
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
type |
type
|
Return value produced by the operation. |
Source code in app.py
get_provider_instance ¶
Get provider instance.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
class_name
|
str
|
Class name value used by the operation. |
required |
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_chat_module ¶
Get chat module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_tts_module ¶
Get tts module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_images_module ¶
Get images module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_embeddings_module ¶
Get embeddings module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_translation_module ¶
Get translation module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_transcription_module ¶
Get transcription module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_files_module ¶
Get files module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_vectorstores_module ¶
Get vector stores module.
Purpose
Returns the OpenAI VectorStores wrapper used by the Vector Stores mode. The function prevents provider-specific retrieval resources from being routed through the OpenAI VectorStores contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider selected by the application. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Instantiated OpenAI VectorStores wrapper. |
Source code in app.py
get_collections_module ¶
Get collections module.
Purpose
Returns the xAI Collections wrapper used by the Collections mode. The function keeps Grok Collections separate from OpenAI Vector Stores and Gemini File Search Stores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider selected by the application. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Instantiated xAI Collections wrapper. |
Source code in app.py
get_file_search_module ¶
Get file search module.
Purpose
Returns the Gemini FileSearch wrapper used by the File Search Stores mode. The function prevents OpenAI Vector Stores and xAI Collections from being routed through the Gemini File Search contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider selected by the application. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Instantiated Gemini FileSearch wrapper. |
Source code in app.py
get_cloud_buckets_module ¶
Get cloud buckets module.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_mode_classes ¶
Get mode classes.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Optional[str]
|
Mode value used by the operation. |
None
|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
provider_supports_mode ¶
Determine provider mode support.
Purpose
Determines whether the selected provider exposes the wrapper and functionality required by an application mode. The function preserves Buddy's Chat alias while enforcing provider-native retrieval-resource boundaries for OpenAI Vector Stores, xAI Collections, Gemini File Search Stores, and Google Cloud Buckets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Required provider name. |
required |
mode_name
|
str
|
Required application mode name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the provider supports the requested mode; otherwise False. |
Source code in app.py
3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 | |
require_provider_mode ¶
Require provider mode.
Purpose
Performs the require_provider_mode workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Optional[str]
|
Mode value used by the operation. |
None
|
provider
|
Optional[str]
|
Provider value used by the operation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Return value produced by the operation. |
Source code in app.py
get_provider_options ¶
Get provider options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
get_raw_provider_modes ¶
Get raw provider modes.
Purpose
Returns the application modes configured for the selected provider while enforcing provider-native retrieval-resource terminology. GPT retains Vector Stores, Gemini retains File Search Stores and Google Cloud Buckets, and Grok exposes Collections instead of Vector Stores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Required provider name. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Ordered provider-specific application modes. |
Source code in app.py
normalize_mode_name ¶
Normalize mode name.
Purpose
Normalizes incoming values into a predictable representation for application processing. The function reduces provider, user-input, or serialization differences before values are stored or displayed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode_name
|
Optional[str]
|
Mode name value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
normalize_mode_list ¶
Normalize mode list.
Purpose
Normalizes incoming values into a predictable representation for application processing. The function reduces provider, user-input, or serialization differences before values are stored or displayed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
List[str]
|
Modes value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
mode_requires_runtime_wrapper ¶
Mode requires runtime wrapper.
Purpose
Performs the mode_requires_runtime_wrapper workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode_name
|
str
|
Mode name value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Return value produced by the operation. |
Source code in app.py
get_supported_provider_modes ¶
Get supported provider modes.
Purpose
Returns the configured application modes available to the selected provider. Mode availability is determined by the provider-specific configuration and is not altered by runtime wrapper introspection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Selected provider name. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Normalized provider modes in configured display order. |
Source code in app.py
get_mode_index ¶
Get mode index.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modes
|
List[str]
|
Modes value used by the operation. |
required |
current_mode
|
Optional[str]
|
Current mode value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Return value produced by the operation. |
Source code in app.py
render_provider_keys ¶
Render provider keys.
Purpose
Renders the requested user interface element or result block in Streamlit using normalized inputs. The function keeps presentation logic isolated from provider calls and data-processing steps so the screen output remains predictable.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
get_text_options ¶
get_text_options(
instance: Any,
attr_name: str,
fallback: Optional[List[str]] = None,
) -> List[str]
Get text options.
Purpose
Returns normalized option values exposed by the selected provider wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Provider wrapper instance. |
required |
attr_name
|
str
|
Option-property name. |
required |
fallback
|
Optional[List[str]]
|
Values returned when the property is unavailable. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Normalized provider option values. |
Source code in app.py
parse_semicolon_list ¶
Parse semicolon list.
Purpose
Converts a semicolon-delimited value into normalized non-empty entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Delimited source value. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Parsed values. |
Source code in app.py
parse_comma_list ¶
Parse comma list.
Purpose
Converts a comma-delimited value into normalized non-empty entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Delimited source value. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Parsed values. |
Source code in app.py
get_grok_collection_options ¶
Get Grok collection options.
Purpose
Returns configured xAI Collection labels mapped to provider collection identifiers.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: Collection labels mapped to identifiers. |
Source code in app.py
get_selected_grok_collection_ids ¶
Get selected Grok collection IDs.
Purpose
Resolves configured collection labels and manually entered collection identifiers.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Unique xAI Collection identifiers. |
Source code in app.py
sanitize_text_selection ¶
Sanitize text selection.
Purpose
Removes a stale single-select value when it is not supported by the selected provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key. |
required |
valid_options
|
List[str]
|
Supported option values. |
required |
default
|
Any
|
Replacement value. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
sanitize_text_multiselect ¶
Sanitize text multiselect.
Purpose
Removes stale multi-select values that are unsupported by the selected provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key. |
required |
valid_options
|
List[str]
|
Supported option values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
build_text_context ¶
Build text context.
Purpose
Returns prior Text Mode user and assistant messages without including the current prompt.
Returns:
| Type | Description |
|---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: Prior conversation messages. |
Source code in app.py
normalize_text_domains ¶
Normalize allowed domains.
Purpose
Removes URL schemes and paths from Web Search domain restrictions.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Provider-compatible domain names. |
Source code in app.py
get_text_response_schema ¶
Get text response schema.
Purpose
Parses the configured JSON schema only when the selected response mode requires it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
required
|
bool
|
Indicates whether an empty schema is invalid. |
False
|
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]]: Parsed JSON schema or None. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when required schema text is missing or invalid. |
Source code in app.py
get_gpt_text_format ¶
Get GPT text format.
Purpose
Builds the response-format value accepted by the GPT Chat replacement.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
GPT response-format configuration. |
Source code in app.py
get_gemini_text_schema ¶
Get Gemini text schema.
Purpose
Returns a Gemini response schema only when JSON output is selected and schema text has been entered.
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]]: Parsed schema or None. |
Source code in app.py
get_grok_text_schema ¶
Get Grok text schema.
Purpose
Returns the required xAI schema only when JSON Schema output is selected.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Parsed schema or None. |
Source code in app.py
validate_text_request ¶
Validate text request.
Purpose
Prevents submission when the selected provider operation is missing required provider-specific controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function validates state. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when required request values are missing. |
Source code in app.py
reset_text_model_settings ¶
Reset text model settings.
Purpose
Resets Text Mode model and provider-capability selections.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
reset_text_inference_settings ¶
Reset text inference settings.
Purpose
Resets Text Mode sampling and penalty controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
reset_text_tool_settings ¶
Reset text tool settings.
Purpose
Resets Text Mode tools, grounding, domains, URLs, and retrieval resources.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
reset_text_response_settings ¶
Reset text response settings.
Purpose
Resets Text Mode output, structured-response, streaming, storage, and continuation controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
clear_text_messages ¶
Clear text messages.
Purpose
Clears Text Mode conversation, continuation, answer, and source state.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
build_gpt_text_kwargs ¶
build_gpt_text_kwargs(
prompt: str,
prior_context: List[Dict[str, str]],
stream_handler: Any = None,
) -> Dict[str, Any]
Build GPT text arguments.
Purpose
Builds only arguments accepted by the GPT Chat replacement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Current user prompt. |
required |
prior_context
|
List[Dict[str, str]]
|
Prior conversation messages. |
required |
stream_handler
|
Any
|
Optional streaming callback. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: GPT text-generation arguments. |
Source code in app.py
build_gemini_text_kwargs ¶
build_gemini_text_kwargs(
prompt: str,
prior_context: List[Dict[str, str]],
stream_handler: Any = None,
) -> Dict[str, Any]
Build Gemini text arguments.
Purpose
Builds only arguments accepted by the Gemini Chat replacement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Current user prompt. |
required |
prior_context
|
List[Dict[str, str]]
|
Prior conversation messages. |
required |
stream_handler
|
Any
|
Optional streaming callback. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Gemini text-generation arguments. |
Source code in app.py
build_grok_text_kwargs ¶
build_grok_text_kwargs(
prompt: str,
prior_context: List[Dict[str, str]],
stream_handler: Any = None,
) -> Dict[str, Any]
Build Grok text arguments.
Purpose
Builds only arguments accepted by the Grok Chat replacement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Current user prompt. |
required |
prior_context
|
List[Dict[str, str]]
|
Prior conversation messages. |
required |
stream_handler
|
Any
|
Optional streaming callback. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Grok text-generation arguments. |
Source code in app.py
call_generate_text ¶
call_generate_text(
prompt: str,
prior_context: List[Dict[str, str]],
stream_handler: Any = None,
) -> Any
Call generate text.
Purpose
Dispatches Text Mode through the exact replacement interface for the selected provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Current user prompt. |
required |
prior_context
|
List[Dict[str, str]]
|
Prior conversation messages. |
required |
stream_handler
|
Any
|
Optional streaming callback. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider-generated text. |
Source code in app.py
get_text_avatar ¶
Get text avatar.
Purpose
Returns the configured assistant avatar for the selected provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
Message role. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Avatar value. |
Source code in app.py
extract_text_sources ¶
Extract text sources.
Purpose
Extracts provider-specific grounding and search sources from the latest response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Selected provider wrapper. |
required |
response
|
Any
|
Provider response. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized source records. |
Source code in app.py
update_text_usage ¶
Update text usage.
Purpose
Updates application token counters from the latest provider response when the application usage helper is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
Provider response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates application state. |
Source code in app.py
load_text_instruction_template ¶
Load Text instruction template.
Purpose
Loads the selected prompt template into the Text Mode system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Text Mode session state. |
Source code in app.py
clear_text_instructions ¶
Clear Text instructions.
Purpose
Clears the Text Mode system instructions and its selected prompt template.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Text Mode session state. |
Source code in app.py
convert_text_system_instructions ¶
Convert Text system instructions.
Purpose
Converts the Text Mode system instructions between Markdown headings and XML-style heading elements.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Text Mode session state. |
Source code in app.py
on_stream_chunk ¶
On stream chunk.
Purpose
Renders the accumulated provider streaming response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
str
|
Provider text delta. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates the streaming placeholder. |
Source code in app.py
get_image_options ¶
get_image_options(
instance: Any,
attr_name: str,
fallback: Optional[List[str]] = None,
) -> List[str]
Get image options.
Purpose
Returns normalized image options exposed by the selected provider wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Provider image-wrapper instance. |
required |
attr_name
|
str
|
Wrapper option-property name. |
required |
fallback
|
Optional[List[str]]
|
Values used when the property is unavailable. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Normalized provider option values. |
Source code in app.py
sanitize_image_selection ¶
Sanitize image selection.
Purpose
Removes stale single-select values that are unsupported by the selected provider and image operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key. |
required |
valid_options
|
List[str]
|
Supported option values. |
required |
default
|
Any
|
Replacement value. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
sanitize_image_multiselect ¶
Sanitize image multiselect.
Purpose
Removes stale multi-select values that are unsupported by the selected provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key. |
required |
valid_options
|
List[str]
|
Supported option values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
get_provider_image_models ¶
Get provider image models.
Purpose
Returns models configured for the selected provider and image operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected_mode
|
Optional[str]
|
Generation, Analysis, or Editing. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Available model identifiers. |
Source code in app.py
6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 | |
get_selected_image_model ¶
Get selected image model.
Purpose
Returns the model selected for the requested image operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Generation, Analysis, or Editing. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Selected model identifier. |
Source code in app.py
save_uploaded_image ¶
Save uploaded image.
Purpose
Persists an uploaded image to a temporary local file for provider requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Streamlit uploaded-file object. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Temporary local path or None. |
Source code in app.py
append_image_message ¶
Append image message.
Purpose
Appends an Images Mode conversation message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
Message role. |
required |
content
|
str
|
Message content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
render_image_messages ¶
Render image messages.
Purpose
Renders Images Mode conversation messages.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function renders Streamlit content. |
Source code in app.py
clear_image_messages ¶
Clear image messages.
Purpose
Clears Images Mode message and result collections.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
clear_image_instructions ¶
Clear image instructions.
Purpose
Clears Images Mode system instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
convert_image_system_instructions ¶
Convert image system instructions.
Purpose
Converts Images Mode instructions between XML and Markdown.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
load_image_instruction_template ¶
Load image instruction template.
Purpose
Loads the selected Images Mode prompt template into system instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Raises:
| Type | Description |
|---|---|
Error
|
Re-raised after the exception is logged. |
Source code in app.py
reset_image_model_settings ¶
Reset image model settings.
Purpose
Resets Images Mode operation and model selections.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
reset_image_inference_settings ¶
Reset image inference settings.
Purpose
Resets provider-supported image inference controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
reset_image_response_settings ¶
Reset image response settings.
Purpose
Resets provider-supported image analysis response controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
reset_image_visual_settings ¶
Reset image visual settings.
Purpose
Resets provider-supported generation and editing output controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
render_image_output ¶
Render image output.
Purpose
Renders provider image URLs, byte content, lists, or compatible image objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider image output. |
required |
caption
|
str
|
Image caption. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when at least one image is rendered. |
Source code in app.py
update_image_usage ¶
Update image usage.
Purpose
Updates application usage counters when a compatible usage helper is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
Provider response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates application state. |
Source code in app.py
validate_image_request ¶
Validate image request.
Purpose
Validates required Images Mode controls for the selected provider operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Generation, Analysis, or Editing. |
required |
prompt
|
str
|
Operation prompt. |
required |
path
|
str
|
Optional required local image path. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Selected provider model. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when a required input is missing. |
Source code in app.py
run_image_generation ¶
Run image generation.
Purpose
Calls the exact generation interface implemented by the selected provider wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Image-generation prompt. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider image output. |
Source code in app.py
run_image_analysis ¶
Run image analysis.
Purpose
Calls the exact image-analysis interface implemented by the selected provider wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Image-analysis prompt. |
required |
path
|
str
|
Local image path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider analysis text. |
Source code in app.py
run_image_editing ¶
Run image editing.
Purpose
Calls the exact image-editing interface implemented by the selected provider wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Image-editing prompt. |
required |
path
|
str
|
Local source-image path. |
required |
mask_path
|
str
|
Optional GPT mask path. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider edited-image output. |
Source code in app.py
6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 | |
get_audio_help ¶
Get audio help.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name value used by the operation. |
required |
fallback
|
str
|
Fallback value used by the operation. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Return value produced by the operation. |
Source code in app.py
get_audio_options ¶
get_audio_options(
instance: Any,
attr_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get audio options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Instance value used by the operation. |
required |
attr_name
|
str
|
Attr name value used by the operation. |
required |
fallback
|
Optional[List[Any]]
|
Fallback value used by the operation. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Return value produced by the operation. |
Source code in app.py
audio_has_method ¶
Audio has method.
Purpose
Performs the audio_has_method workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Instance value used by the operation. |
required |
method_names
|
List[str]
|
Method names value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Return value produced by the operation. |
Source code in app.py
get_audio_task_options ¶
Get audio task options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
get_audio_task_instance ¶
Get audio task instance.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Optional[str]
|
Task value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Return value produced by the operation. |
Source code in app.py
get_audio_model_options ¶
Get audio model options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Optional[str]
|
Task value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
get_audio_language_options ¶
Get audio language options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Optional[str]
|
Task value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
get_audio_voice_options ¶
Get audio voice options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
get_audio_format_options ¶
Get audio format options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Optional[str]
|
Task value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Return value produced by the operation. |
Source code in app.py
get_audio_include_options ¶
Get audio include options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and down stream logic can consume it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Optional[str]
|
Task value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
get_audio_sample_rate_options ¶
Get audio sample rate options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Returns:
| Type | Description |
|---|---|
List[int]
|
List[int]: Return value produced by the operation. |
Source code in app.py
get_audio_bit_rate_options ¶
Get audio bit rate options.
Purpose
Returns normalized information for the application component. The method provides a stable view of provider capabilities, stored state, or response metadata so UI controls and downstream logic can consume it consistently.
Returns:
| Type | Description |
|---|---|
List[int]
|
List[int]: Return value produced by the operation. |
Source code in app.py
sanitize_audio_selection ¶
Sanitize audio selection.
Purpose
Performs the sanitize_audio_selection workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Key value used by the operation. |
required |
valid_options
|
List[Any]
|
Valid options value used by the operation. |
required |
default
|
Any
|
Default value used by the operation. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
sanitize_audio_multiselect ¶
Sanitize audio multiselect.
Purpose
Performs the sanitize_audio_multiselect workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Key value used by the operation. |
required |
valid_options
|
List[str]
|
Valid options value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
parse_audio_domains ¶
Parse audio domains.
Purpose
Performs the parse_audio_domains workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Return value produced by the operation. |
Source code in app.py
save_audio_upload ¶
Save audio upload.
Purpose
Persists or stages input data so it can be used by later provider or application workflows. The function standardizes file handling and returns a stable reference for downstream processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Uploaded file value used by the operation. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Return value produced by the operation. |
Source code in app.py
append_audio_message ¶
Append audio message.
Purpose
Performs the append_audio_message workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
Role value used by the operation. |
required |
content
|
str
|
Content value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
render_audio_messages ¶
Render audio messages.
Purpose
Renders the requested user interface element or result block in Streamlit using normalized inputs. The function keeps presentation logic isolated from provider calls and data-processing steps so the screen output remains predictable.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
clear_audio_messages ¶
Clear audio messages.
Purpose
Removes or resets the requested application state or provider resource in a controlled manner. The function keeps cleanup behavior centralized so callers do not duplicate lifecycle logic.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
clear_audio_instructions ¶
Clear audio instructions.
Purpose
Removes or resets the requested application state or provider resource in a controlled manner. The function keeps cleanup behavior centralized so callers do not duplicate lifecycle logic.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
convert_audio_system_instructions ¶
Convert audio system instructions.
Purpose
Performs the convert_audio_system_instructions workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
load_audio_instruction_template ¶
Load audio instruction template.
Purpose
Loads the selected Audio-mode prompt template into the Audio-mode system-instruction field using the stable prompt identifier stored in session state.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
reset_audio_task_controls ¶
Reset audio task controls.
Purpose
Removes or resets the requested application state or provider resource in a controlled manner. The function keeps cleanup behavior centralized so callers do not duplicate lifecycle logic.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
reset_audio_inference_controls ¶
Reset audio inference controls.
Purpose
Removes or resets the requested application state or provider resource in a controlled manner. The function keeps cleanup behavior centralized so callers do not duplicate lifecycle logic.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
reset_audio_playback_controls ¶
Reset audio playback controls.
Purpose
Removes or resets the requested application state or provider resource in a controlled manner. The function keeps cleanup behavior centralized so callers do not duplicate lifecycle logic.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
update_audio_usage ¶
Update audio usage.
Purpose
Performs the update_audio_usage workflow using the inputs supplied by the caller and the current runtime configuration. The function keeps this behavior isolated so related UI, provider, and data-processing paths can call it consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Instance value used by the operation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
normalize_audio_text_result ¶
Normalize audio text result.
Purpose
Normalizes provider transcription and translation results into displayable text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider result returned by the active audio wrapper. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Extracted text or an empty string. |
Source code in app.py
normalize_audio_bytes_result ¶
Normalize audio bytes result.
Purpose
Normalizes provider text-to-speech results into audio bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider result returned by the active text-to-speech wrapper. |
required |
Returns:
| Type | Description |
|---|---|
Optional[bytes]
|
Optional[bytes]: Generated audio bytes when available; otherwise None. |
Source code in app.py
get_audio_mime_type ¶
Get audio MIME type.
Purpose
Converts the selected provider audio format into a valid MIME type for Streamlit playback and download controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_value
|
Any
|
Provider audio format or MIME-type value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Valid audio MIME type. |
Source code in app.py
get_audio_file_extension ¶
Get audio file extension.
Purpose
Converts the selected provider audio format into a safe download-file extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_value
|
Any
|
Provider audio format or MIME-type value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Audio file extension without a leading period. |
Source code in app.py
get_audio_source_mime_type ¶
Get audio source MIME type.
Purpose
Resolves the source-audio MIME type required by Gemini and Grok upload workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Local source-audio path. |
required |
selected_format
|
Any
|
Current format selection from Audio Mode. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Source-audio MIME type. |
Source code in app.py
get_audio_target_language ¶
Get audio target language.
Purpose
Returns the selected target language required by provider translation wrappers.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Selected target language. |
Source code in app.py
run_audio_transcription ¶
Run audio transcription.
Purpose
Executes the selected provider transcription wrapper using only arguments implemented by that provider contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Required local source-audio path. |
required |
prompt
|
Optional[str]
|
Optional transcription guidance. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Generated transcript. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 | |
run_audio_translation ¶
Run audio translation.
Purpose
Executes the selected provider audio-translation wrapper using only arguments implemented by that provider contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Required local source-audio path. |
required |
prompt
|
Optional[str]
|
Optional translation guidance. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Generated translated text. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 | |
run_audio_tts ¶
Run audio text-to-speech.
Purpose
Executes the selected provider text-to-speech wrapper using only arguments implemented by that provider contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Required text converted to speech. |
required |
Returns:
| Type | Description |
|---|---|
Optional[bytes]
|
Optional[bytes]: Generated audio bytes when available. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 | |
get_docqna_options ¶
get_docqna_options(
instance: Any,
attr_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get Document Q&A options.
Purpose
Returns provider-supported control options exposed by the active Chat wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Active provider Chat wrapper. |
required |
attr_name
|
str
|
Wrapper option property or method name. |
required |
fallback
|
Optional[List[Any]]
|
Values used when the wrapper exposes no options. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported control options. |
Source code in app.py
sanitize_docqna_selection ¶
Sanitize Document Q&A selection.
Purpose
Clears a stored single-selection value that is unsupported by the active provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key containing the selection. |
required |
options
|
List[Any]
|
Provider-supported option values. |
required |
default
|
Any
|
Replacement value used for an invalid selection. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
sanitize_docqna_multiselect ¶
Sanitize Document Q&A multiselect.
Purpose
Removes stored multiselect values unsupported by the active provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key containing selected values. |
required |
options
|
List[Any]
|
Provider-supported option values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
parse_docqna_list ¶
Parse Document Q&A list.
Purpose
Converts comma-delimited text or an existing sequence into normalized nonempty provider argument values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
String or sequence containing provider option values. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Normalized provider argument values. |
Source code in app.py
clear_docqna_instructions ¶
Clear Document Q&A instructions.
Purpose
Clears the active Document Q&A system instructions and selected prompt template.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
convert_docqna_system_instructions ¶
Convert Document Q&A system instructions.
Purpose
Converts Document Q&A instructions between XML blocks and Markdown headings.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
load_docqna_instruction_template ¶
Load Document Q&A instruction template.
Purpose
Loads the selected Document Q&A prompt template into the system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
unload_docqna_document ¶
Unload Document Q&A document.
Purpose
Removes the active local document and its bytes without clearing configuration, instructions, or conversation history.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
clear_docqna_messages ¶
Clear Document Q&A messages.
Purpose
Clears Document Q&A conversation state and generated answer and source output.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
run_document_query ¶
Run Document Q&A query.
Purpose
Builds locally grounded document input and invokes the exact text-generation contract implemented by the selected provider Chat wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
User question submitted for the active document. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Provider-generated document-grounded answer. |
Raises:
| Type | Description |
|---|---|
Error
|
Re-raised after the exception is logged. |
Source code in app.py
8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 | |
get_embedding_help ¶
Get embedding help.
Purpose
Returns normalized help text for an Embeddings Mode control from the current application configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration attribute containing the help text. |
required |
fallback
|
str
|
Fallback help text used when the attribute is unavailable. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Configured or fallback help text. |
Source code in app.py
get_embedding_options ¶
get_embedding_options(
instance: Any,
attr_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get embedding options.
Purpose
Returns a normalized list of provider options exposed through an Embeddings wrapper property or method. Missing or explicitly unavailable options use the supplied fallback, while provider-wrapper execution failures are logged and re-raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Provider Embeddings wrapper instance. |
required |
attr_name
|
str
|
Name of the wrapper option property or method. fallback (Optional[List[Any]]): Values used when the wrapper exposes no options. |
required |
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported option values or the supplied fallback. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises provider-wrapper failures after recording them with the application logger. |
Source code in app.py
normalize_embedding_text ¶
Normalize embedding text.
Purpose
Converts source input into normalized text suitable for chunking and provider embedding requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Source text value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Normalized source text. |
Source code in app.py
chunk_embedding_text ¶
Chunk embedding text.
Purpose
Divides embedding source text into bounded overlapping chunks while preserving the existing application chunking helpers when available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_value
|
str
|
Source text to divide. |
required |
chunk_size
|
int
|
Maximum words or tokens retained in each chunk. |
required |
overlap
|
int
|
Number of words or tokens shared by adjacent chunks. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Ordered embedding chunks. |
Source code in app.py
normalize_embedding_vectors ¶
Normalize embedding vectors.
Purpose
Converts GPT, Gemini, dictionary, response-object, batch, single-vector, and base64-encoded embedding outputs into a consistent collection of floating-point vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
Any
|
Provider embedding result or response object. |
required |
Returns:
| Type | Description |
|---|---|
List[List[float]]
|
List[List[float]]: Normalized embedding vectors. |
Source code in app.py
10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 | |
call_embeddings_create ¶
Call embeddings create.
Purpose
Routes embedding creation to the exact GPT or Gemini wrapper contract using the currently selected provider controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
List[str]
|
Required source-text chunks. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider embedding output. |
Raises:
| Type | Description |
|---|---|
Error
|
Re-raised after the exception is logged. |
Source code in app.py
extract_embedding_usage ¶
Extract embedding usage.
Purpose
Extracts provider usage metadata from the active wrapper response or returned embedding result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider embedding result. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized provider usage metadata. |
Source code in app.py
build_embedding_metrics ¶
build_embedding_metrics(
source_text: str,
chunks: List[str],
vectors: List[List[float]],
usage: Dict[str, Any],
) -> Dict[str, Any]
Build embedding metrics.
Purpose
Builds source-text, chunk, vector, dimensionality, and usage metrics for the current embedding result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_text
|
str
|
Complete normalized source text. |
required |
chunks
|
List[str]
|
Source-text chunks submitted to the provider. |
required |
vectors
|
List[List[float]]
|
Normalized embedding vectors. |
required |
usage
|
Dict[str, Any]
|
Provider usage metadata. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Embedding metrics. |
Source code in app.py
build_embeddings_dataframe ¶
Build embeddings dataframe.
Purpose
Builds a tabular embedding output containing chunk identifiers, source text, and one column for each vector dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunks
|
List[str]
|
Source-text chunks. |
required |
vectors
|
List[List[float]]
|
Normalized embedding vectors. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Embedding output dataframe. |
Source code in app.py
render_embedding_metrics ¶
Render embedding metrics.
Purpose
Renders token, chunk, vector, dimensionality, and type-token-ratio metrics for the active embedding result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
Dict[str, Any]
|
Embedding metrics. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function renders Streamlit controls. |
Source code in app.py
reset_embeddings_all ¶
Reset embeddings all.
Purpose
Clears Embeddings Mode source input, provider configuration, generated vectors, metrics, dataframe output, and compatibility aliases.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
update_embedding_usage ¶
Update embedding usage.
Purpose
Updates the shared application token counters when the embedding provider exposes compatible usage metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Any
|
Provider response containing usage metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
get_files_help ¶
Get Files help.
Purpose
Returns configured help text for a Files Mode control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Configuration attribute name. |
required |
fallback
|
str
|
Fallback text. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Configured or fallback help text. |
Source code in app.py
get_files_options ¶
get_files_options(
instance: Any,
attr_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get Files options.
Purpose
Returns provider-supported options exposed by a Files wrapper property or method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Files wrapper instance. |
required |
attr_name
|
str
|
Option property or method name. |
required |
fallback
|
Optional[List[Any]]
|
Fallback options. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported options. |
Source code in app.py
sanitize_files_selection ¶
Sanitize Files selection.
Purpose
Clears a stored selection when it is not supported by the active provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key. |
required |
valid_options
|
List[Any]
|
Valid provider options. |
required |
default
|
Any
|
Replacement value. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
sanitize_files_multiselect ¶
Sanitize Files multiselect.
Purpose
Removes stored multiselect values unsupported by the active provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key. |
required |
valid_options
|
List[Any]
|
Valid provider options. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
normalize_file_id ¶
Normalize file identifier.
Purpose
Extracts a stable provider file identifier from a file response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider file response. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Provider file identifier or resource name. |
Source code in app.py
normalize_files_list ¶
Normalize Files list.
Purpose
Converts provider-specific file collections into rows for the Files Mode table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider file-list response. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized file records. |
Source code in app.py
10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 | |
normalize_file_metadata ¶
Normalize file metadata.
Purpose
Converts provider file metadata into a dictionary suitable for Streamlit output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider file response. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized metadata. |
Source code in app.py
save_uploaded_file_for_api ¶
Save uploaded file for API.
Purpose
Writes a Streamlit uploaded file to a temporary local path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Streamlit uploaded-file object. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: Temporary file path. |
Source code in app.py
normalize_file_content ¶
Normalize file content.
Purpose
Converts extracted provider content into displayable text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Any
|
Provider file content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Displayable content. |
Source code in app.py
get_effective_file_id ¶
Get effective file identifier.
Purpose
Returns the first populated provider file identifier from the supplied state keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*keys
|
str
|
Ordered session-state keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Active file identifier. |
Source code in app.py
refresh_files_table ¶
Refresh Files table.
Purpose
Lists provider files and stores normalized records for display and selection.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized provider file records. |
Source code in app.py
upload_provider_file ¶
Upload provider file.
Purpose
Uploads a staged local file through the exact selected-provider Files contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Streamlit uploaded-file object. |
required |
purpose
|
Optional[str]
|
Optional file-purpose value. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider file response. |
Source code in app.py
retrieve_provider_file ¶
Retrieve provider file.
Purpose
Retrieves file metadata through the exact selected-provider Files contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_id
|
str
|
Provider file identifier or resource name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider file metadata. |
Source code in app.py
extract_provider_file ¶
Extract provider file.
Purpose
Retrieves file content through the exact selected-provider Files contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_id
|
str
|
Provider file identifier or resource name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Extracted content or downloaded bytes. |
Source code in app.py
delete_provider_file ¶
Delete provider file.
Purpose
Deletes a file through the exact selected-provider Files contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_id
|
str
|
Provider file identifier or resource name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Provider deletion response. |
Source code in app.py
ask_provider_file ¶
Ask provider file.
Purpose
Executes a file-aware question through the exact search contract implemented by the selected provider wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_id
|
str
|
Provider file identifier or resource name. |
required |
prompt
|
str
|
Question asked about the file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Provider-generated answer. |
Source code in app.py
11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 | |
clear_files_outputs ¶
Clear Files outputs.
Purpose
Clears loaded file records, metadata, extracted content, and operation results.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
clear_files_messages ¶
Clear Files messages.
Purpose
Clears Files Mode messages and the latest generated answer.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
append_files_message ¶
Append Files message.
Purpose
Adds a user or assistant message to Files Mode history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
Message role. |
required |
content
|
str
|
Message content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
render_files_messages ¶
Render Files messages.
Purpose
Renders Files Mode conversation history.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function renders Streamlit output. |
Source code in app.py
clear_files_instructions ¶
Clear Files instructions.
Purpose
Clears Files Mode system instructions and its selected prompt template.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
convert_files_system_instructions ¶
Convert Files system instructions.
Purpose
Converts Files Mode instructions between XML blocks and Markdown headings.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
load_files_instruction_template ¶
Load Files instruction template.
Purpose
Loads the selected Files Mode prompt template into the system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates session state. |
Source code in app.py
get_vector_store_options ¶
get_vector_store_options(
instance: Any,
attribute_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get Vector Store options.
Purpose
Returns provider-supported option values exposed by the GPT VectorStores wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Active GPT VectorStores wrapper. |
required |
attribute_name
|
str
|
Wrapper option-property name. |
required |
fallback
|
Optional[List[Any]]
|
Values returned when the property is unavailable. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported option values. |
Source code in app.py
parse_vector_store_json ¶
Parse Vector Store JSON.
Purpose
Parses optional JSON text used by Vector Store metadata, attributes, filters, and ranking controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
JSON text or an existing dictionary. |
required |
label
|
str
|
Field label included in validation errors. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Parsed JSON object or an empty dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when nonempty input is not a JSON object. |
Source code in app.py
parse_vector_store_ids ¶
Parse Vector Store identifiers.
Purpose
Converts comma-delimited file identifiers into unique nonempty values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Comma-delimited identifier text. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Unique parsed identifiers. |
Source code in app.py
get_selected_vector_store_id ¶
Get selected Vector Store identifier.
Purpose
Returns the selected Vector Store identifier or the manually entered fallback.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Active Vector Store identifier. |
Source code in app.py
normalize_vector_store_rows ¶
Normalize Vector Store rows.
Purpose
Converts a GPT Vector Store response into records suitable for Streamlit tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider response containing one or more Vector Stores. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized Vector Store records. |
Source code in app.py
normalize_vector_file_rows ¶
Normalize Vector Store file rows.
Purpose
Converts a GPT Vector Store file response into records suitable for Streamlit tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider response containing one or more Vector Store files. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized file records. |
Source code in app.py
clear_vector_store_outputs ¶
Clear Vector Store outputs.
Purpose
Clears Vector Store tables, metadata, batch results, and search results without changing configuration controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
clear_vector_store_instructions ¶
Clear Vector Store instructions.
Purpose
Clears Vector Store system instructions and the selected prompt template.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
load_vector_store_instruction_template ¶
Load Vector Store instruction template.
Purpose
Loads the selected prompt template into the Vector Store system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
convert_vector_store_instructions ¶
Convert Vector Store instructions.
Purpose
Converts Vector Store system instructions between Markdown headings and XML-style heading elements.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
get_collection_options ¶
get_collection_options(
instance: Any,
attribute_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get Collection options.
Purpose
Returns provider-supported option values exposed by the Grok Collections wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Active Grok Collections wrapper. |
required |
attribute_name
|
str
|
Wrapper option-property name. |
required |
fallback
|
Optional[List[Any]]
|
Values returned when the property is unavailable. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported option values. |
Source code in app.py
parse_collection_json ¶
Parse Collection JSON.
Purpose
Parses optional JSON used by Collection document attributes and search filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
JSON text or an existing dictionary. |
required |
label
|
str
|
Field label included in validation errors. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Parsed JSON object or an empty dictionary. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when nonempty input is not a JSON object. |
Source code in app.py
parse_collection_ids ¶
Parse Collection document identifiers.
Purpose
Converts comma-delimited document identifiers into unique nonempty values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Comma-delimited identifier text. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Unique parsed identifiers. |
Source code in app.py
get_selected_collection_id ¶
Get selected Collection identifier.
Purpose
Returns the selected Collection identifier or the manually entered fallback.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Active Collection identifier. |
Source code in app.py
normalize_collection_rows ¶
Normalize Collection rows.
Purpose
Converts a Grok Collection response into records suitable for Streamlit tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider response containing one or more Collections. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized Collection records. |
Source code in app.py
normalize_collection_document_rows ¶
Normalize Collection document rows.
Purpose
Converts a Grok Collection document response into records suitable for Streamlit tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Provider response containing one or more Collection documents. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized document records. |
Source code in app.py
clear_collection_outputs ¶
Clear Collection outputs.
Purpose
Clears Collection tables, document tables, metadata, batch results, and search results without changing configuration controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
clear_collection_instructions ¶
Clear Collection instructions.
Purpose
Clears Collection system instructions and the selected prompt template.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
load_collection_instruction_template ¶
Load Collection instruction template.
Purpose
Loads the selected prompt template into the Collection system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
convert_collection_instructions ¶
Convert Collection instructions.
Purpose
Converts Collection system instructions between Markdown headings and XML-style heading elements.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_collection_selection ¶
Reset Collection-selection controls.
Purpose
Restores the Collection-selection controls to their default values.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_collection_documents ¶
Reset Collection-document controls.
Purpose
Restores the Collection-document controls to their default values.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_collection_lifecycle ¶
Reset Collection-lifecycle controls.
Purpose
Restores the Collection-lifecycle controls to their default values.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_collection_search ¶
Reset Collection-search controls.
Purpose
Restores the Collection-search controls to their default values.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_collection_system_instructions ¶
Reset Collection system-instruction controls.
Purpose
Restores the Collection system-instruction controls to their default values.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
clear_collection_messages ¶
Clear Collection conversation messages.
Purpose
Removes the user and assistant messages retained by Collections mode.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
get_filestore_options ¶
get_filestore_options(
instance: Any,
attr_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get File Search Store options.
Purpose
Returns option values exposed by the Gemini FileSearch wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Active Gemini FileSearch wrapper. |
required |
attr_name
|
str
|
Wrapper property or method containing option values. |
required |
fallback
|
Optional[List[Any]]
|
Values used when the wrapper exposes no options. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported option values. |
Source code in app.py
sanitize_filestore_selection ¶
Sanitize File Search Store selection.
Purpose
Clears a stored selection when it is unsupported by the active wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key containing the selection. |
required |
options
|
List[Any]
|
Provider-supported option values. |
required |
default
|
Any
|
Replacement value for an invalid selection. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
parse_filestore_metadata ¶
Parse File Search Store metadata.
Purpose
Converts optional JSON metadata input into the list of metadata objects accepted by the Gemini File Search Store upload contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Metadata JSON text or existing metadata sequence. |
required |
Returns:
| Type | Description |
|---|---|
Optional[List[Dict[str, Any]]]
|
Optional[List[Dict[str, Any]]]: Provider-ready metadata or None. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when nonempty metadata is not a JSON object or array. |
Source code in app.py
normalize_filestore_object ¶
Normalize File Search Store object.
Purpose
Converts Gemini File Search Store, upload, operation, and deletion responses into a stable dictionary for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Provider response. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized provider response. |
Source code in app.py
13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 | |
get_filestore_items ¶
Get File Search Store items.
Purpose
Extracts store records from Gemini list responses and iterators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Gemini File Search Store list result. |
required |
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Store resource objects. |
Source code in app.py
normalize_filestore_rows ¶
Normalize File Search Store rows.
Purpose
Converts Gemini File Search Store resources into rows used by the management table and selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Gemini list response. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized store rows. |
Source code in app.py
get_selected_filestore_id ¶
Get selected File Search Store identifier.
Purpose
Returns the manually entered store resource name or the current table selection.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Active Gemini File Search Store resource name. |
Source code in app.py
clear_filestore_outputs ¶
Clear File Search Store outputs.
Purpose
Removes File Search Store operation results without changing store selections, request settings, uploaded-file controls, queries, or system instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
clear_filestore_instructions ¶
Clear File Search Stores instructions.
Purpose
Clears File Search Stores system instructions and the selected prompt template.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
convert_filestore_system_instructions ¶
Convert File Search Stores system instructions.
Purpose
Converts File Search Stores instructions between XML blocks and Markdown headings.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
load_filestore_instruction_template ¶
Load File Search Stores instruction template.
Purpose
Loads the selected File Search Stores prompt template into the system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Raises:
| Type | Description |
|---|---|
Error
|
Re-raised after the exception is logged. |
Source code in app.py
reset_filestore_management_settings ¶
Reset File Search Store management settings.
Purpose
Returns store-management controls to their initial values without modifying provider resources or request output.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_filestore_request_settings ¶
Reset File Search Store request settings.
Purpose
Returns supported Gemini File Search query settings to their initial values without clearing stores, uploads, queries, results, or instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
refresh_filestore_table ¶
Refresh File Search Store table.
Purpose
Lists Gemini File Search Stores and stores normalized table rows and display-name mappings.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized File Search Store rows. |
Source code in app.py
create_filestore ¶
Create File Search Store.
Purpose
Creates a Gemini File Search Store using the exact wrapper contract.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized created-store metadata. |
Source code in app.py
retrieve_filestore ¶
Retrieve File Search Store.
Purpose
Retrieves Gemini File Search Store metadata using the exact wrapper contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_id
|
str
|
Required Gemini File Search Store resource name. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized store metadata. |
Source code in app.py
delete_filestore ¶
Delete File Search Store.
Purpose
Deletes a Gemini File Search Store using the exact wrapper contract and explicit force-selection state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_id
|
str
|
Required Gemini File Search Store resource name. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized deletion result. |
Source code in app.py
upload_filestore_file ¶
Upload File Search Store file.
Purpose
Stages and uploads a file through the exact Gemini File Search Store upload contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Streamlit uploaded-file object. |
required |
store_id
|
str
|
Required Gemini File Search Store resource name. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized upload or import-operation result. |
Source code in app.py
search_filestore ¶
Search File Search Store.
Purpose
Executes a grounded Gemini File Search Store query using only parameters implemented by the uploaded wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_id
|
str
|
Required Gemini File Search Store resource name. |
required |
query
|
str
|
Required grounded query. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Gemini grounded response text. |
Source code in app.py
get_bucket_options ¶
get_bucket_options(
instance: Any,
attr_name: str,
fallback: Optional[List[Any]] = None,
) -> List[Any]
Get bucket options.
Purpose
Returns provider-supported values exposed by the Gemini CloudBuckets wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
Any
|
Active Gemini CloudBuckets wrapper. |
required |
attr_name
|
str
|
Wrapper option property or method name. |
required |
fallback
|
Optional[List[Any]]
|
Values used when no wrapper options are exposed. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: Provider-supported option values. |
Source code in app.py
sanitize_bucket_selection ¶
Sanitize bucket selection.
Purpose
Clears a stored single-selection value that is unsupported by the active wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Session-state key containing the selection. |
required |
options
|
List[Any]
|
Provider-supported option values. |
required |
default
|
Any
|
Replacement value for an unsupported selection. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
normalize_bucket_object ¶
Normalize bucket object.
Purpose
Converts Google Cloud Storage bucket and object responses into dictionaries suitable for Streamlit tables and metadata output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Google Cloud Storage bucket, blob, boolean, or dictionary response. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized bucket or object metadata. |
Source code in app.py
14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 | |
normalize_bucket_rows ¶
Normalize bucket rows.
Purpose
Converts Google Cloud Storage object-list responses into stable table rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Google Cloud Storage object collection. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized object metadata rows. |
Source code in app.py
get_selected_bucket_name ¶
Get selected bucket name.
Purpose
Returns the manually entered bucket name or the currently selected configured bucket.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Active Google Cloud Storage bucket name. |
Source code in app.py
save_bucket_upload ¶
Save bucket upload.
Purpose
Writes a Streamlit uploaded file to a temporary local path for Google Cloud Storage upload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Streamlit uploaded-file object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Temporary local file path. |
Source code in app.py
clear_bucket_outputs ¶
Clear bucket outputs.
Purpose
Clears Google Cloud Bucket operation results without changing bucket selections, request settings, uploaded files, queries, or system instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
clear_bucket_instructions ¶
Clear Google Cloud Buckets instructions.
Purpose
Clears the Google Cloud Buckets system-instruction text and selected prompt template without changing the selected category, bucket configuration, results, or uploaded files.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
convert_bucket_system_instructions ¶
Convert Google Cloud Buckets system instructions.
Purpose
Converts the active Google Cloud Buckets system instructions between supported XML-style instruction blocks and Markdown headings.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
load_bucket_instruction_template ¶
Load Google Cloud Buckets instruction template.
Purpose
Loads the selected Google Cloud Buckets prompt template into the mode-specific system-instruction field.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Raises:
| Type | Description |
|---|---|
Error
|
Re-raised after the exception is logged. |
Source code in app.py
reset_bucket_management_settings ¶
Reset bucket management settings.
Purpose
Returns the Google Cloud Bucket management controls to their initial values without clearing provider resources, operation results, request settings, or instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
reset_bucket_request_settings ¶
Reset bucket request settings.
Purpose
Returns the Google Cloud Bucket model, inference, and response controls to their initial values without clearing bucket selections, queries, results, or instructions.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function updates Streamlit session state. |
Source code in app.py
create_cloud_bucket ¶
Create cloud bucket.
Purpose
Creates a Google Cloud Storage bucket using the exact Gemini CloudBuckets contract.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized created-bucket metadata. |
Source code in app.py
retrieve_cloud_bucket ¶
Retrieve cloud bucket.
Purpose
Retrieves Google Cloud Storage bucket or object metadata using the exact wrapper contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name
|
str
|
Required Google Cloud Storage bucket name. |
required |
object_name
|
str
|
Optional object name. |
''
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized bucket or object metadata. |
Source code in app.py
list_cloud_bucket_objects ¶
List cloud bucket objects.
Purpose
Lists Google Cloud Storage object metadata using the exact wrapper contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name
|
str
|
Required Google Cloud Storage bucket name. |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: Normalized object rows. |
Source code in app.py
upload_cloud_bucket_object ¶
Upload cloud bucket object.
Purpose
Uploads a local file to Google Cloud Storage using the exact wrapper contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uploaded_file
|
Any
|
Streamlit uploaded-file object. |
required |
bucket_name
|
str
|
Required Google Cloud Storage bucket name. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Normalized uploaded-object metadata. |
Source code in app.py
delete_cloud_bucket_resource ¶
Delete cloud bucket resource.
Purpose
Deletes a Google Cloud Storage bucket or object using the exact wrapper contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name
|
str
|
Required Google Cloud Storage bucket name. |
required |
object_name
|
str
|
Optional object name. An empty value deletes the bucket. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the deletion request completes. |
Source code in app.py
query_cloud_bucket ¶
Query cloud bucket.
Purpose
Answers a question using supported objects in a Google Cloud Storage bucket through the exact Gemini CloudBuckets search contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bucket_name
|
str
|
Required Google Cloud Storage bucket name. |
required |
query
|
str
|
Required question about bucket content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Gemini answer grounded in supported bucket objects. |
Source code in app.py
get_prompt_connection ¶
Get prompt connection.
Purpose
Creates a SQLite connection to the configured application database for Prompt Engineering read and write operations.
Returns:
| Type | Description |
|---|---|
Connection
|
sqlite3.Connection: Open SQLite connection to the application database. |
Source code in app.py
reset_prompt_page ¶
Reset prompt page.
Purpose
Returns the Prompt Engineering result grid to its first page when a search or sort control changes.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
reset_prompt_selection ¶
Reset prompt selection.
Purpose
Clears the selected Prompt Engineering record and resets the authoritative editor fields without changing search, sorting, or paging controls.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
load_prompt_record ¶
Load prompt record.
Purpose
Loads the selected category-aware prompt record into the authoritative Prompt Engineering editor fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_id
|
int
|
Numeric primary key of the prompt record to load. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
fetch_prompt_editor_categories ¶
Fetch prompt editor categories.
Purpose
Returns the combined set of configured and persisted prompt categories available to the Prompt Engineering editor.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Sorted prompt categories available for record creation and editing. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
validate_prompt_editor ¶
Validate prompt editor.
Purpose
Validates and normalizes the authoritative Prompt Engineering editor values before a prompt record is inserted or updated.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: Normalized Caption, Name, Category, and Prompt values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Raised when a required prompt field is empty. |
Source code in app.py
save_prompt_record ¶
Save prompt record.
Purpose
Creates or updates the authoritative Prompt Engineering record using the canonical category-aware prompt schema.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
delete_prompt_record ¶
Delete prompt record.
Purpose
Deletes the selected Prompt Engineering record and resets the authoritative editor state.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Raises:
| Type | Description |
|---|---|
Exception
|
Re-raises exceptions after recording them with the application logger. |
Source code in app.py
convert_prompt_xml_to_markdown ¶
Convert prompt XML to Markdown.
Purpose
Converts XML-style instruction blocks in the authoritative prompt editor to Markdown.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |
Source code in app.py
convert_prompt_markdown_to_xml ¶
Convert prompt Markdown to XML.
Purpose
Converts Markdown headings in the authoritative prompt editor to XML-style instruction blocks.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function performs its work through side effects and does not return a value. |