LLM Configuration and Propagation Flow#
In this section, we will go through the flow of LLM configurations selected in the SlideDeck AI Streamlit UI and propagated down to the core engine and LiteLLM wrapper to make API calls.
Overview Flow#
Here is the step-by-step pipeline:
+-------------------------------------------------------------+
| app.py (Streamlit Sidebar UI) |
+-------------------------------------------------------------+
|
| (1) Initializes SlideDeckAI / set_model()
v
+-------------------------------------------------------------+
| src/slidedeckai/core.py (SlideDeckAI) |
+-------------------------------------------------------------+
|
| (2) Triggers generate/revise -> _initialize_llm()
v
+-------------------------------------------------------------+
| src/slidedeckai/core.py: _initialize_llm() |
+-------------------------------------------------------------+
|
| (3) Calls get_litellm_llm()
v
+-------------------------------------------------------------+
| src/slidedeckai/helpers/llm_helper.py: get_litellm_llm() |
+-------------------------------------------------------------+
|
| (4) Instantiates
v
+-------------------------------------------------------------+
| src/slidedeckai/helpers/llm_helper.py: |
| LiteLLMWrapper |
+-------------------------------------------------------------+
|
| (5) wrapper.stream() -> stream_litellm_completion()
v
+-------------------------------------------------------------+
| src/slidedeckai/helpers/llm_helper.py: |
| stream_litellm_completion() |
+-------------------------------------------------------------+
|
| (6) Calls litellm.completion()
v
+-------------------------------------------------------------+
| LiteLLM Library Client |
+-------------------------------------------------------------+
Detailed Flow Steps#
1. User Input in UI (app.py)#
In the sidebar, users select the LLM provider/model and fill out parameters:
llm_provider_to_use(e.g.,[az]azure/open-ai)api_key_tokenAzure OpenAI-specific configurations (when using Azure OpenAI):
azure_endpointazure_deploymentapi_version
2. Core Propagation (src/slidedeckai/core.py)#
These configurations are passed directly to the SlideDeckAI core engine:
On Initialization: Inside
app.py, a new instance ofSlideDeckAIis constructed with all selected credentials.On Dynamic Settings Update: If settings are updated in the sidebar,
app.pytriggers theslide_generator.set_model()method to safely update the model, API key, and Azure-specific fields on the active instance.
3. LLM Wrapper Initialization (src/slidedeckai/helpers/llm_helper.py)#
When generation or revision starts:
SlideDeckAIinvokes its internal helper method_initialize_llm()._initialize_llm()callsllm_helper.get_litellm_llm(), passing:provider: Extracted from the model’s bracketed code prefix (e.g.,azfor Azure,ggfor Gemini) usingllm_helper.get_provider_model().model: The specific model name.api_key,azure_endpoint_url,azure_deployment_name,azure_api_version.
llm_helper.get_litellm_llm()instantiates aLiteLLMWrapperholding those credentials.
4. Streaming Execution (llm_helper.py)#
SlideDeckAIinvokes_stream_llm_response(llm, ...)which callsllm.stream(prompt).LiteLLMWrapper.stream()forwards the request tostream_litellm_completion(), providing the target provider, model, messages, and credentials.stream_litellm_completion()performs validation checks (e.g., verifying that the Azure deployment name is not empty for Azure OpenAI) and calls the externallitellm.completion()API to stream chunks back to the client.