Dev#161
Conversation
Add Mistral AI, update docs
Summary by CodeRabbit
WalkthroughThe changes introduce support for the Mistral AI language model provider in the core logic and update relevant documentation and configuration instructions. Several UI text updates, including splash screen revisions and the addition of a Terms and Conditions dialog, were made. Minor formatting and wording improvements were applied throughout, with no changes to public APIs. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant StreamlitApp
participant CoreMain
participant MistralAPI
User->>StreamlitApp: Provide API key and accept Terms
StreamlitApp->>CoreMain: Call llm_creation(api_key)
CoreMain->>CoreMain: Detect provider (e.g., Mistral)
CoreMain->>MistralAPI: Initialize connection with API key
MistralAPI-->>CoreMain: Responds with model access
CoreMain-->>StreamlitApp: Return initialized model
StreamlitApp-->>User: Enable LLM-powered features
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
streamlit_webapp/streamlit_app.py (1)
182-183: Consider simplifying nested with statements.The static analysis tool suggests combining the nested
withstatements for better readability:- with st.expander("Set a OpenAI API Key", expanded=st.session_state.openai_key_expander): - with st.form(key='api_key_form'): + with st.expander("Set a OpenAI API Key", expanded=st.session_state.openai_key_expander), \ + st.form(key='api_key_form'):
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
app/config/params.iniis excluded by!**/*.ini
📒 Files selected for processing (5)
README.md(1 hunks)app/core/main.py(3 hunks)docs/getting-started/installation.md(3 hunks)streamlit_webapp/misc/splash_text.txt(2 hunks)streamlit_webapp/streamlit_app.py(4 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
streamlit_webapp/streamlit_app.py
182-183: Use a single with statement with multiple contexts instead of nested with statements
(SIM117)
🔇 Additional comments (14)
README.md (1)
70-70: LGTM! Clean formatting improvement.Removing trailing whitespace improves code quality and consistency.
docs/getting-started/installation.md (4)
92-98: LGTM! Comprehensive provider support documentation.The expanded list of supported language model providers clearly indicates the growing flexibility of MetaboT's LLM integration.
99-122: Excellent detailed setup instructions for Mistral AI.The step-by-step configuration guide is comprehensive and includes all necessary details: API key acquisition, environment setup, and params.ini configuration. This makes it easy for users to adopt the free Mistral AI option.
126-153: Improved guidance for adding custom LLM providers.The enhanced documentation for adding new models via LiteLLM is much more comprehensive. The explicit reminder to add API keys to the
.envfile and the provider detection example will help users avoid common configuration mistakes.
193-194: Important limitation clearly documented.Good to explicitly note that LiteLLM is not available for the Supervisor agent due to router implementation requirements. This prevents user confusion when configuring different agents.
app/core/main.py (3)
31-31: LGTM! Consistent API key mapping for Mistral AI.The addition follows the established pattern and enables proper environment variable lookup for the Mistral provider.
78-79: LGTM! Provider detection for Mistral models.The conditional logic correctly identifies Mistral models by their ID prefix, maintaining consistency with other provider detection patterns.
132-133: Smart improvement to API key handling.The conditional assignment (
if api_key is None) prevents overwriting explicitly passed API keys while maintaining backward compatibility. This is particularly important for the Streamlit integration where keys are passed explicitly.streamlit_webapp/misc/splash_text.txt (3)
1-7: Improved user onboarding experience.The cleaner title without "Demo" and the prominent Terms and Conditions notice improve the professional appearance and ensure users are aware of important usage terms before starting.
23-29: Better documentation and local setup guidance.The updated links to comprehensive documentation and local installation instructions provide users with clearer paths for different usage scenarios.
31-50: Comprehensive citation section added.The detailed citation information, including DOI badge, author list, and institutional affiliations, properly supports academic usage and gives appropriate credit to the research work.
streamlit_webapp/streamlit_app.py (3)
75-75: Good fallback for environment variable configuration.The fallback to "CONTRIBUTOR_KEY_RFMF" provides deployment flexibility without breaking existing configurations.
153-180: Well-implemented Terms and Conditions dialog.The dialog clearly explains data recording practices with LangSmith and OpenAI, addressing important privacy considerations. The implementation with session state management and rerun triggers works correctly for the Streamlit app flow.
371-371: Correct API key passing to llm_creation.This change aligns with the updated
llm_creationfunction inmain.pythat now accepts explicit API key parameters, ensuring consistent key management across the application.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
streamlit_webapp/streamlit_app.py(3 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
streamlit_webapp/streamlit_app.py
185-186: Use a single with statement with multiple contexts instead of nested with statements
(SIM117)
🔇 Additional comments (5)
streamlit_webapp/streamlit_app.py (5)
75-78: LGTM! Good formatting improvement.The added blank lines improve code readability by visually grouping related environment variable retrievals.
149-149: LGTM! Text update reflects application maturation.The change from "Prototype" to "Demo" appropriately reflects the current status of the application.
188-189: LGTM! Clear instruction text improvement.The updated markdown text provides clearer instructions for users entering their OpenAI API key.
374-380: LGTM! Proper API key passing and UI state management.The explicit passing of the API key to
llm_creation()and the addedst.rerun()after initialization ensure proper integration and UI state updates.
185-186: Nestedwithstatements are appropriate here.The static analysis tool suggests combining the nested
withstatements, but in this case the nesting is semantically correct:
- The outer
withcreates a Streamlit expander UI component- The inner
withcreates a form within that expanderThese serve different purposes and should remain nested to maintain proper UI structure.
| # --- Terms Dialog --- | ||
| @st.dialog("📄 Terms and Conditions") | ||
| def terms_and_conditions_dialog(): | ||
| st.markdown(""" | ||
| #### Terms of Use | ||
|
|
||
| - We **record** and **analyze** all user interactions via [LangSmith](https://www.langchain.com/langsmith) to better understand usage patterns and improve the app experience. | ||
| - If you provide your own **LangSmith API key**, your conversations remain private from us. | ||
| - If you're using **OpenAI models**: | ||
| - OpenAI may store and process your data as per their | ||
| [Privacy Policy](https://openai.com/policies/privacy-policy) and | ||
| [Terms of Service](https://openai.com/policies/terms-of-use). | ||
|
|
||
| We use interaction data solely to analyze user questions, identify common patterns, and enhance the functionality of the app. | ||
|
|
||
|
|
||
| """) | ||
| if st.button("✅ I Agree to the Terms", use_container_width=True): | ||
| st.session_state.terms_accepted = True | ||
| st.success("Thanks! You have accepted the Terms.") | ||
| st.rerun() | ||
|
|
||
|
|
||
| # --- Button to open the Terms dialog --- | ||
| st.markdown("## 📘 Please read the Terms and Conditions.") | ||
| open_terms_dialog = st.button("📘 Terms and Conditions", use_container_width=True) | ||
| if open_terms_dialog: | ||
| terms_and_conditions_dialog() |
There was a problem hiding this comment.
Terms acceptance is not enforced in the application flow.
The Terms and Conditions dialog sets st.session_state.terms_accepted = True but this flag is never checked elsewhere to gate access to application functionality. Users can bypass the terms without accepting them.
Consider integrating terms acceptance into the application flow:
+# Check terms acceptance early in the application flow
+if "terms_accepted" not in st.session_state:
+ st.session_state.terms_accepted = False
+
+# Gate application functionality on terms acceptance
if st.session_state.openai_key_success == True and st.session_state.endpoint_url_success == True:
+ if not st.session_state.terms_accepted:
+ st.warning("Please accept the Terms and Conditions to proceed.")
+ return
if st.session_state.langgraph_app_created == False:Also, fix the extra whitespace in the markdown (line 169):
- We use interaction data solely to analyze user questions, identify common patterns, and enhance the functionality of the app.
+ We use interaction data solely to analyze user questions, identify common patterns, and enhance the functionality of the app.Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In streamlit_webapp/streamlit_app.py between lines 156 and 183, the terms
acceptance flag st.session_state.terms_accepted is set but never checked,
allowing users to bypass accepting the terms. To fix this, add a check early in
the app flow to verify if st.session_state.terms_accepted is True; if not, block
access to main functionality and prompt the user to accept the terms by showing
the dialog or a message. Also, remove the extra whitespace in the markdown
content around line 169 to clean up the formatting.
PR Type
Enhancement, Documentation
Description
Add Mistral AI model support with API key configuration
Implement terms and conditions dialog for user consent
Update contributor key handling with RFMF fallback
Fix API key parameter passing in LangGraph initialization
Diagram Walkthrough
File Walkthrough
main.py
Add Mistral AI model supportapp/core/main.py
llm_creationfunctionstreamlit_app.py
Add terms dialog and improve key handlingstreamlit_webapp/streamlit_app.py
llm_creationfunction callREADME.md
Minor formatting cleanupREADME.md
params.ini
Add Mistral model configurationapp/config/params.ini
mistral/mistral-small-latestas default Mistral model