SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files10 unmodified lines111213141516171819202122232425267 unmodified lines343536373839405 unmodified lines4647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651 unmodified line16716816917017117217310 unmodified lineselse:groq_client = Groq(api_key=GROQ_API_KEY)# Step 3: Enhance with Groqdef enhance_with_groq(query):"""Enhance the suggestions using Groq."""try:# Perform chat completion using Groqchat_completion = groq_client.chat.completions.create(messages=[{"role": "user", "content": query}],model="llama-3.3-70b-versatile", # Specify model for Groq)return chat_completion.choices[0].message.contentexcept Exception as e:7 unmodified lines- Affordable internet solutions.- Signal boosting tips.- Offline tools for education, healthcare, and business.- More!""")# Sidebar User Inputs5 unmodified lines"Offline Tools","Types of Internet Connections","Educational Resources","Energy-Efficient Connectivity Solutions"])# Fetch and Enhance Suggestionsif st.sidebar.button("Get Suggestions"):if location:# Formulate the query for Groq based on user inputsquery = f"Provide suggestions for {needs} in {location}, especially affordable options and tips."st.subheader(f"Suggestions for {needs} in {location}")# Get response from Groqgroq_response = enhance_with_groq(query)# Display Groq responsest.write("Suggestions from Groq:")st.write(groq_response)else:st.warning("Please enter your location to get recommendations.")# New Features# Types of Internet Connectionsdef types_of_internet_connections():st.subheader("Types of Internet Connections")st.markdown("""In rural areas, you may encounter various types of internet connections. Each has its pros and cons, depending on your needs:- **Satellite Internet**:- Good for remote areas where no other connectivity is available.- Pros: Available almost everywhere.- Cons: Can be expensive and has higher latency.- **4G/5G LTE**:- Increasingly popular in rural areas.- Pros: Affordable, high-speed internet.- Cons: Coverage may be limited in remote regions.- **Fiber Optic**:- The fastest connection type.- Pros: Very fast speeds (up to 1 Gbps).- Cons: Limited availability in rural areas.- **DSL (Digital Subscriber Line)**:- Common in many rural areas.- Pros: Reliable, affordable.- Cons: Slower speeds compared to fiber or LTE.- **Fixed Wireless**:- Uses radio signals to provide internet access.- Pros: Available in remote areas, affordable.- Cons: Speeds vary based on distance from the tower.- **Dial-Up**:- Rarely used nowadays, but still present in some rural areas.- Pros: Available anywhere a phone line exists.- Cons: Very slow speeds, high latency.""")# Educational Resourcesdef educational_resources():st.subheader("Educational Resources on Internet Connectivity")st.markdown("""Here are some useful educational resources to help you understand how internet connectivity works and how it can be improved in rural areas:- **Internet Basics**:- [How the Internet Works](https://www.explainthatstuff.com/how-the-internet-works.html) β A simple guide to understanding the basics of internet technology.- **Improving Rural Connectivity**:- [The State of Rural Broadband](https://www.broadbandnow.com/research/state-of-broadband) β Research on rural broadband and how to improve it.- **Satellite Internet**:- [Satellites for Internet](https://www.explainingthecloud.com/satellite-internet/) β A guide to how satellite internet works.- **Wi-Fi Technology**:- [How Wi-Fi Works](https://www.wi-fi.org/discover-wi-fi) β Learn about the technology behind Wi-Fi and how it can be optimized.- **Internet Safety**:- [Staying Safe Online](https://www.getsafeonline.org/) β A comprehensive resource for understanding internet safety, especially in rural communities where online security might be a concern.""")# Energy-Efficient Connectivity Solutionsdef energy_efficient_connectivity():st.subheader("Energy-Efficient Connectivity Solutions")st.markdown("""In rural areas, where power supply can be inconsistent, energy-efficient internet solutions are important. Here are a few options to consider:- **Solar-Powered Internet Solutions**:- Many rural areas are turning to solar-powered routers and internet infrastructure to provide a sustainable internet connection.- Pros: Green, cost-effective in the long run.- Cons: Initial setup costs, weather dependency.- **Energy-Efficient Modems and Routers**:- Choose modems and routers that are designed to consume less power, especially if you're running a small community network or a home-based system.- Look for Energy Star-certified devices.- **Low Power IoT Devices**:- For rural communities that rely on low-cost, low-power internet, Internet of Things (IoT) devices can be energy-efficient.- Use IoT to monitor remote areas, for smart agriculture, and more.- **Energy-Efficient Data Centers**:- If you are running a local data center in rural areas, look for solutions that use renewable energy (wind, solar) to power your infrastructure.- **Smart Grid Technologies**:- Use smart grid technologies to balance energy usage while maintaining a reliable internet connection. These technologies are being adopted in rural areas to improve energy distribution and reduce energy consumption.""")# Display Additional Featuresif needs == "Types of Internet Connections":types_of_internet_connections()elif needs == "Educational Resources":educational_resources()elif needs == "Energy-Efficient Connectivity Solutions":energy_efficient_connectivity()# Optional Query Box for Additional Questionsst.sidebar.header("Have Another Query?")1 unmodified lineif user_query:st.subheader(f"Your Query: {user_query}")# Get response from Groq for the additional user queryquery_response = enhance_with_groq(user_query)st.write("Response from Groq:")st.write(query_response)10 unmodified lines1112131415161718192021227 unmodified lines303132333435365 unmodified lines4243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091921 unmodified line94959697989910 unmodified lineselse:groq_client = Groq(api_key=GROQ_API_KEY)# Step 3: Function to interact with Groqdef enhance_with_groq(query):try:chat_completion = groq_client.chat.completions.create(messages=[{"role": "user", "content": query}],model="llama-3.3-70b-versatile",)return chat_completion.choices[0].message.contentexcept Exception as e:7 unmodified lines- Affordable internet solutions.- Signal boosting tips.- Offline tools for education, healthcare, and business.- Connectivity recommendations tailored to your needs.""")# Sidebar User Inputs5 unmodified lines"Offline Tools","Types of Internet Connections","Educational Resources","Energy-Efficient Connectivity Solutions","Recommend Connectivity System"])# Fetch and Enhance Suggestionsif needs != "Recommend Connectivity System" and st.sidebar.button("Get Suggestions"):if location:query = f"Provide suggestions for {needs} in {location}, especially affordable options and tips."st.subheader(f"Suggestions for {needs} in {location}")groq_response = enhance_with_groq(query)st.write("Suggestions from Groq:")st.write(groq_response)else:st.warning("Please enter your location to get recommendations.")# "Recommend Connectivity System" Optionif needs == "Recommend Connectivity System":st.subheader("Recommend Connectivity System")st.markdown("Provide the following details to get a personalized recommendation for your connectivity system:")# Inputs from the useruser_budget = st.number_input("Enter your budget (in USD):", min_value=10, step=10)num_users = st.number_input("Number of users:", min_value=1, step=1)connection_preference = st.selectbox("Preferred Connection Type:", ["Satellite Internet","4G/5G LTE","Fiber Optic","DSL","Fixed Wireless","No Preference"])# Get recommendation on button clickif st.button("Get Recommendation"):if user_budget and num_users:recommendation_query = (f"Recommend a suitable connectivity system for a rural area. "f"Budget: ${user_budget}, Number of Users: {num_users}, "f"Connection Preference: {connection_preference}.")recommendation_response = enhance_with_groq(recommendation_query)st.subheader("Recommended Connectivity System")st.write(recommendation_response)else:st.warning("Please fill in all required fields.")# Optional Query Box for Additional Questionsst.sidebar.header("Have Another Query?")1 unmodified lineif user_query:st.subheader(f"Your Query: {user_query}")query_response = enhance_with_groq(user_query)st.write("Response from Groq:")st.write(query_response)
app.py+36-110