import streamlit as st from langchain_google_genai import ChatGoogleGenerativeAI from langchain.tools import Tool from langchain_community.tools.google_search import GoogleSearchResults import json # Get API key for Gemini GEMINI_API_KEY = userdata.get("gemini_api") # Configure LangChain LLM with Gemini 2.0 llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", google_api_key=os.getenv("gemini_api")) # Google Search Tool (does not require API key) google_search = GoogleSearchResults() search_tool = Tool( name="Google Search", func=google_search.run, description="Search the web for information.", ) def azure_cert_bot(cert_name): query = f"Microsoft Azure {cert_name} certification curriculum site:microsoft.com" # Perform Google Search search_results = search_tool.run(query) # Generate Q&A using Gemini prompt = ( f"Based on the following curriculum details, generate key questions and answers in markdown format for the {cert_name} certification exam:\n\n{search_results}" ) response = llm.invoke(prompt) try: response_text = response.get("content", "No response generated.") if isinstance(response, dict) else response except Exception as e: response_text = f"Error processing response: {str(e)}" return search_results, response_text # Streamlit UI Enhancements st.set_page_config(page_title="Azure Certification Prep Assistant", layout="wide") # Custom Styling st.markdown(""" """, unsafe_allow_html=True) st.markdown("