├── community-contributions ├── sf-patient-brochure │ └── .gitkeep ├── protocol_summarizer_webapp │ ├── requirements.txt │ ├── .gitignore │ ├── .github │ │ └── copilot-instructions.md │ └── README.md ├── WebScraperApp │ └── requirements.txt ├── playwright-bojan │ ├── requirements.txt │ └── README.md ├── bojan-playwright-scraper │ ├── requirements.txt │ ├── notebooks │ │ ├── huggingface_co_Summary.ipynb │ │ └── deepmind_google_Summary.ipynb │ └── notebook_generator.py ├── multi-agent_gui_with_gradio │ └── README.md └── synthetic-dataset-generator │ └── README.md ├── week6 └── community-contributions │ └── lisekarimi │ └── helpers │ └── __init__.py ├── week8 ├── community_contributions │ ├── lisekarimi │ │ ├── agents │ │ │ ├── __init__.py │ │ │ ├── base_agent.py │ │ │ └── ft_price_agent.py │ │ ├── helpers │ │ │ └── __init__.py │ │ └── modal_services │ │ │ ├── __init__.py │ │ │ └── get_started.py │ ├── pricer_test │ │ ├── pricer │ │ │ ├── __init__.py │ │ │ ├── keep_warm.py │ │ │ └── llama.py │ │ ├── requirements.txt │ │ └── README.md │ ├── images │ │ ├── gui.png │ │ └── metrics.png │ ├── Ensemble_with_xgboost │ │ ├── log_utils.py │ │ ├── agents │ │ │ ├── agent.py │ │ │ ├── specialist_agent.py │ │ │ ├── random_forest_agent.py │ │ │ ├── gradient_boosting_agent.py │ │ │ ├── ensemble_agent.py │ │ │ └── planning_agent.py │ │ └── pricer_ephemeral.py │ └── ensemble-updated │ │ ├── xg_boost_agent.py │ │ └── ensemble_agent.py ├── keep_warm.py ├── hello.py ├── log_utils.py ├── agents │ ├── agent.py │ ├── specialist_agent.py │ ├── random_forest_agent.py │ ├── ensemble_agent.py │ └── planning_agent.py ├── llama.py ├── memory.json ├── pricer_ephemeral.py └── pricer_service.py ├── week3 ├── community-contributions │ ├── ai-web-summarizer │ │ ├── utils │ │ │ ├── __init__.py │ │ │ ├── config.py │ │ │ └── logger.py │ │ ├── summarizer │ │ │ ├── __init__.py │ │ │ └── fetcher.py │ │ ├── requirements.txt │ │ ├── .gitignore │ │ └── main.py │ └── muawiya │ │ └── app │ │ ├── consts.py │ │ └── requirements.txt ├── day3.ipynb ├── day4.ipynb ├── day5.ipynb ├── day2.ipynb └── day1.ipynb ├── voyage.jpg ├── SETUP-PC.pdf ├── SETUP-mac.pdf ├── business.jpg ├── important.jpg ├── resources.jpg ├── thankyou.jpg ├── SETUP-linux.pdf ├── week2 ├── community-contributions │ ├── medical_prescription_to_google_calender │ │ ├── credentials.json │ │ └── src │ │ │ ├── main.py │ │ │ ├── calendar_auth.py │ │ │ ├── ocr.py │ │ │ └── create_calender_events.py │ ├── week2_day2_gradio │ │ ├── readme.txt │ │ ├── settings.json │ │ ├── languages.json │ │ ├── main.py │ │ ├── ollama_utils.py │ │ ├── system_prompt.txt │ │ └── json_handlers.py │ ├── 3_chatbots_Converstion │ │ ├── requirements.txt │ │ ├── Conversation_Outputs.pdf │ │ └── README.md │ ├── chatbot_conversation_robots.jpg │ ├── anatomy_poster_generator │ │ └── README.md │ ├── oh_sheet_its_spark.ipynb │ ├── taskmanagement │ │ └── readme.md │ ├── muawiya │ │ ├── requirements.txt │ │ └── tools.py │ └── AI Gold Investment Assistant │ │ └── demo_test.py └── week2 EXERCISE.ipynb ├── week4 ├── simple.cpp ├── community-contributions │ ├── ai_stock_trading │ │ ├── core │ │ │ └── __init__.py │ │ ├── components │ │ │ └── __init__.py │ │ ├── requirements.txt │ │ └── tools │ │ │ └── __init__.py │ ├── ai_code_converter │ │ └── screenshots │ │ │ ├── codeXchange_1.png │ │ │ ├── codeXchange_2.png │ │ │ ├── codeXchange_3.png │ │ │ ├── codeXchange_4.png │ │ │ └── codeXchange_3_1.png │ └── doc_string_exercise │ │ ├── data │ │ └── original_file.py │ │ └── README.md └── optimized.cpp ├── week5 ├── community-contributions │ ├── Week5_Exercise_Personal_Knowledge │ │ ├── local-knowledge-base │ │ │ ├── text │ │ │ │ ├── MD.md │ │ │ │ ├── text.txt │ │ │ │ ├── PDF.pdf │ │ │ │ ├── Epub.epub │ │ │ │ └── HTML.html │ │ │ ├── image │ │ │ │ └── JPEG.jpg │ │ │ └── ms_office │ │ │ │ ├── excel.xlsx │ │ │ │ ├── word.docx │ │ │ │ ├── LLMGooglePDF.pdf │ │ │ │ └── Presentation.pptx │ │ └── credentials │ │ │ ├── gmail_credentials.json │ │ │ └── google_drive_workspace_credentials.json │ ├── docuSeekAI │ │ ├── doc_upload.png │ │ ├── docuseek1.png │ │ ├── docuseek2.png │ │ ├── docuseek3.png │ │ └── docuseek4.png │ ├── rag_chat_example │ │ ├── img.png │ │ ├── README.md │ │ ├── knowledge_base │ │ │ └── mtsample_dictations │ │ │ │ ├── test_patient_3_m │ │ │ │ └── progress_note.txt │ │ │ │ └── test_patient_2_f │ │ │ │ └── progress_note.txt │ │ └── run_rag_chat.py │ ├── tourist-guide │ │ ├── travel.jpg │ │ ├── requirements.txt │ │ └── style.css │ ├── Personal Knowledge Worker │ │ └── sameer-db │ │ │ └── personal │ │ │ └── sameer.md │ ├── day 4 no_langchain │ │ └── knowledge_collection │ │ │ ├── mountains │ │ │ ├── massif_central.md │ │ │ ├── morvan.md │ │ │ ├── ardennes.md │ │ │ ├── massif_armorican.md │ │ │ ├── vosges.md │ │ │ ├── alpes.md │ │ │ ├── jura.md │ │ │ └── pyrenees.md │ │ │ └── languages │ │ │ ├── alsacien.md │ │ │ ├── breton.md │ │ │ ├── lorrain.md │ │ │ ├── bourguignon.md │ │ │ ├── picard.md │ │ │ ├── languedocien.md │ │ │ ├── provencal.md │ │ │ ├── normand.md │ │ │ └── gascon.md │ └── auto_shop.json └── knowledge-base │ ├── company │ ├── careers.md │ ├── about.md │ └── overview.md │ ├── employees │ ├── Jordan Blake.md │ ├── Oliver Spencer.md │ ├── Alex Thomson.md │ └── Alex Chen.md │ └── contracts │ └── Contract with Roadway Insurance Inc. for Carllm.md ├── week1 └── community-contributions │ ├── reqdoc.docx │ ├── datasheets │ ├── part_new.pdf │ └── part_old.pdf │ ├── llm-page-summarizer-with-pyppeteer │ └── requirements.txt │ ├── Day1_2_Reddit_Analysis │ ├── Day1_Day2_Outputs.pdf │ └── README.md │ ├── Day-1-Text-to-sql │ ├── db.py │ └── ollama-TTSQL.py │ ├── Chat_Summary_Data │ ├── Chat_Examples │ │ ├── Chat2.txt │ │ ├── Chat3.txt │ │ └── Chat1.txt │ └── System_Prompt.txt │ ├── resume.txt │ ├── ag-w1d2-use-local-ollama-url-py │ ├── xss_vulnerable_example.html │ ├── ag-w1d2-use-local-ollama-with-openai.py │ ├── ag-w1d2-use-local-ollama-library.py │ ├── day1_article_world_cup_final.ipynb │ ├── week1-coderesearcher.py │ ├── Playwright_Scrapping_Project │ ├── scraping_script.py │ └── summary.md │ ├── ag-w1d2-ollama-site-summary │ ├── week1-day1_2-bedtime-storyteller.py │ └── OllamaDay1_MailSubjectLine.ipynb ├── requirements.txt ├── environment.yml ├── week7 ├── day1.ipynb ├── day2.ipynb ├── day5.ipynb └── day3 and 4.ipynb ├── LICENSE └── diagnostics.ipynb /community-contributions/sf-patient-brochure/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /week6/community-contributions/lisekarimi/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /week8/community_contributions/lisekarimi/agents/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /week8/community_contributions/lisekarimi/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /week8/community_contributions/pricer_test/pricer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /week8/community_contributions/lisekarimi/modal_services/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/summarizer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /voyage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/voyage.jpg -------------------------------------------------------------------------------- /SETUP-PC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/SETUP-PC.pdf -------------------------------------------------------------------------------- /SETUP-mac.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/SETUP-mac.pdf -------------------------------------------------------------------------------- /business.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/business.jpg -------------------------------------------------------------------------------- /important.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/important.jpg -------------------------------------------------------------------------------- /resources.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/resources.jpg -------------------------------------------------------------------------------- /thankyou.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/thankyou.jpg -------------------------------------------------------------------------------- /SETUP-linux.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/SETUP-linux.pdf -------------------------------------------------------------------------------- /week2/community-contributions/medical_prescription_to_google_calender/credentials.json: -------------------------------------------------------------------------------- 1 | "Your google auth credentials." -------------------------------------------------------------------------------- /community-contributions/protocol_summarizer_webapp/requirements.txt: -------------------------------------------------------------------------------- 1 | streamlit 2 | openai 3 | requests 4 | python-dotenv 5 | -------------------------------------------------------------------------------- /week4/simple.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() { 5 | std::cout << "Hello"; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/MD.md: -------------------------------------------------------------------------------- 1 | Zephyr won ZMD award 2 | -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/text.txt: -------------------------------------------------------------------------------- 1 | Zephyr won ZTXT award -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/readme.txt: -------------------------------------------------------------------------------- 1 | Just run the main.py script after activating conda environment 'llms' -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/requirements.txt: -------------------------------------------------------------------------------- 1 | openai 2 | requests 3 | beautifulsoup4 4 | python-dotenv 5 | -------------------------------------------------------------------------------- /week4/community-contributions/ai_stock_trading/core/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Core module for AI Stock Trading Platform 3 | """ 4 | -------------------------------------------------------------------------------- /week2/community-contributions/3_chatbots_Converstion/requirements.txt: -------------------------------------------------------------------------------- 1 | IPython 2 | anthropic 3 | dotenv 4 | ollama 5 | openai 6 | os -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/settings.json: -------------------------------------------------------------------------------- 1 | {"Advanced Settings": {"temperature": 0.0, "top_k": 40.0, "top_p": 0.9}} -------------------------------------------------------------------------------- /week1/community-contributions/reqdoc.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week1/community-contributions/reqdoc.docx -------------------------------------------------------------------------------- /week4/community-contributions/ai_stock_trading/components/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | UI Components for the Stock Trading Platform 3 | """ 4 | -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/languages.json: -------------------------------------------------------------------------------- 1 | [ 2 | "German", 3 | "English", 4 | "Spanish", 5 | "French" 6 | ] -------------------------------------------------------------------------------- /week8/community_contributions/pricer_test/requirements.txt: -------------------------------------------------------------------------------- 1 | huggingface 2 | torch 3 | transformers 4 | bitsandbytes 5 | accelerate 6 | peft 7 | -------------------------------------------------------------------------------- /week8/community_contributions/images/gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week8/community_contributions/images/gui.png -------------------------------------------------------------------------------- /week8/community_contributions/images/metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week8/community_contributions/images/metrics.png -------------------------------------------------------------------------------- /community-contributions/WebScraperApp/requirements.txt: -------------------------------------------------------------------------------- 1 | PyQt5>=5.15.0 2 | PyQtWebEngine>=5.15.0 3 | urllib3==2.0.7 4 | openai>=1.0.0 5 | python-dotenv>=1.0.0 -------------------------------------------------------------------------------- /week1/community-contributions/datasheets/part_new.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week1/community-contributions/datasheets/part_new.pdf -------------------------------------------------------------------------------- /week1/community-contributions/datasheets/part_old.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week1/community-contributions/datasheets/part_old.pdf -------------------------------------------------------------------------------- /week5/community-contributions/docuSeekAI/doc_upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/docuSeekAI/doc_upload.png -------------------------------------------------------------------------------- /week5/community-contributions/docuSeekAI/docuseek1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/docuSeekAI/docuseek1.png -------------------------------------------------------------------------------- /week5/community-contributions/docuSeekAI/docuseek2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/docuSeekAI/docuseek2.png -------------------------------------------------------------------------------- /week5/community-contributions/docuSeekAI/docuseek3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/docuSeekAI/docuseek3.png -------------------------------------------------------------------------------- /week5/community-contributions/docuSeekAI/docuseek4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/docuSeekAI/docuseek4.png -------------------------------------------------------------------------------- /week5/community-contributions/rag_chat_example/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/rag_chat_example/img.png -------------------------------------------------------------------------------- /week5/community-contributions/tourist-guide/travel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/tourist-guide/travel.jpg -------------------------------------------------------------------------------- /week2/community-contributions/chatbot_conversation_robots.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week2/community-contributions/chatbot_conversation_robots.jpg -------------------------------------------------------------------------------- /week1/community-contributions/llm-page-summarizer-with-pyppeteer/requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4 2 | openai 3 | dotenv 4 | requests 5 | rich 6 | pyppeteer 7 | pyppeteer_stealth -------------------------------------------------------------------------------- /community-contributions/playwright-bojan/requirements.txt: -------------------------------------------------------------------------------- 1 | playwright>=1.43.0 2 | openai>=1.14.2 3 | prometheus-client>=0.19.0 4 | diskcache>=5.6.1 5 | python-dotenv>=1.0.1 6 | nest_asyncio>=1.6.0 7 | -------------------------------------------------------------------------------- /community-contributions/bojan-playwright-scraper/requirements.txt: -------------------------------------------------------------------------------- 1 | playwright>=1.43.0 2 | openai>=1.14.2 3 | prometheus-client>=0.19.0 4 | diskcache>=5.6.1 5 | python-dotenv>=1.0.1 6 | nest_asyncio>=1.6.0 7 | -------------------------------------------------------------------------------- /week1/community-contributions/Day1_2_Reddit_Analysis/Day1_Day2_Outputs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week1/community-contributions/Day1_2_Reddit_Analysis/Day1_Day2_Outputs.pdf -------------------------------------------------------------------------------- /week3/community-contributions/muawiya/app/consts.py: -------------------------------------------------------------------------------- 1 | # Models 2 | GPT = 'gpt2' 3 | FALCON = "tiiuae/falcon-rw-1b" 4 | MISTRAL = "mistralai/Mistral-7B-Instruct-v0.1" 5 | Databricks = "databricks/dolly-v2-3b" -------------------------------------------------------------------------------- /week2/community-contributions/3_chatbots_Converstion/Conversation_Outputs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week2/community-contributions/3_chatbots_Converstion/Conversation_Outputs.pdf -------------------------------------------------------------------------------- /week3/community-contributions/muawiya/app/requirements.txt: -------------------------------------------------------------------------------- 1 | huggingface_hub==0.30.2 2 | ipython==8.12.3 3 | openai==1.76.2 4 | protobuf==6.30.2 5 | Requests==2.32.3 6 | torch==2.6.0+cu124 7 | transformers==4.51.3 -------------------------------------------------------------------------------- /week4/community-contributions/ai_code_converter/screenshots/codeXchange_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week4/community-contributions/ai_code_converter/screenshots/codeXchange_1.png -------------------------------------------------------------------------------- /week4/community-contributions/ai_code_converter/screenshots/codeXchange_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week4/community-contributions/ai_code_converter/screenshots/codeXchange_2.png -------------------------------------------------------------------------------- /week4/community-contributions/ai_code_converter/screenshots/codeXchange_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week4/community-contributions/ai_code_converter/screenshots/codeXchange_3.png -------------------------------------------------------------------------------- /week4/community-contributions/ai_code_converter/screenshots/codeXchange_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week4/community-contributions/ai_code_converter/screenshots/codeXchange_4.png -------------------------------------------------------------------------------- /week4/community-contributions/ai_code_converter/screenshots/codeXchange_3_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week4/community-contributions/ai_code_converter/screenshots/codeXchange_3_1.png -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/PDF.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/PDF.pdf -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/image/JPEG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/image/JPEG.jpg -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/Epub.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/Epub.epub -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/text/HTML.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My First Web Page 5 | 6 | 7 |

Zephyr won ZHTML award

8 | 9 | -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/excel.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/excel.xlsx -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/word.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/word.docx -------------------------------------------------------------------------------- /week5/knowledge-base/company/careers.md: -------------------------------------------------------------------------------- 1 | # Careers at Insurellm 2 | 3 | Insurellm is hiring! We are looking for talented software engineers, data scientists and account executives to join our growing team. Come be a part of our movement to disrupt the insurance sector. -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/LLMGooglePDF.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/LLMGooglePDF.pdf -------------------------------------------------------------------------------- /week4/community-contributions/ai_stock_trading/requirements.txt: -------------------------------------------------------------------------------- 1 | yfinance>=0.2.10 2 | openai>=1.0.0 3 | pandas>=1.5.0 4 | matplotlib>=3.5.0 5 | streamlit>=1.28.0 6 | requests>=2.28.0 7 | beautifulsoup4>=4.11.0 8 | numpy>=1.21.0 9 | python-dotenv>=1.0.0 10 | plotly>=5.15.0 -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Todo/llm_engineering/main/week5/community-contributions/Week5_Exercise_Personal_Knowledge/local-knowledge-base/ms_office/Presentation.pptx -------------------------------------------------------------------------------- /week8/keep_warm.py: -------------------------------------------------------------------------------- 1 | import time 2 | import modal 3 | from datetime import datetime 4 | 5 | Pricer = modal.Cls.lookup("pricer-service", "Pricer") 6 | pricer = Pricer() 7 | while True: 8 | reply = pricer.wake_up.remote() 9 | print(f"{datetime.now()}: {reply}") 10 | time.sleep(30) -------------------------------------------------------------------------------- /week5/community-contributions/tourist-guide/requirements.txt: -------------------------------------------------------------------------------- 1 | openai>=1.0.0 2 | gradio>=4.0.0 3 | python-dotenv>=1.0.0 4 | pydub>=0.25.1 5 | pypdf>=4.0.0 6 | langchain>=0.1.0 7 | langchain-openai>=0.0.5 8 | langchain-community>=0.0.13 9 | faiss-cpu>=1.7.4 10 | tiktoken>=0.5.2 11 | requests>=2.31.0 -------------------------------------------------------------------------------- /week1/community-contributions/Day-1-Text-to-sql/db.py: -------------------------------------------------------------------------------- 1 | import mysql.connector 2 | 3 | def get_connection(): 4 | conn = mysql.connector.connect( 5 | host="127.0.0.1", 6 | user="root", 7 | password="xyz", 8 | database="your_database" 9 | ) 10 | return conn 11 | -------------------------------------------------------------------------------- /week1/community-contributions/Chat_Summary_Data/Chat_Examples/Chat2.txt: -------------------------------------------------------------------------------- 1 | Client: Hello I would like to order a chicken ranch pizza 2 | Restaurant: I am so sorry, but chicken ranch is currently unavailable on our menu 3 | Client: Okay thanks 4 | Restaurant: Would you like to order something else? 5 | Client: No thank you 6 | -------------------------------------------------------------------------------- /week8/community_contributions/pricer_test/pricer/keep_warm.py: -------------------------------------------------------------------------------- 1 | import time 2 | import modal 3 | from datetime import datetime 4 | 5 | Pricer = modal.Cls.lookup("pricer-service", "Pricer") 6 | pricer = Pricer() 7 | while True: 8 | reply = pricer.wake_up.remote() 9 | print(f"{datetime.now()}: {reply}") 10 | time.sleep(30) -------------------------------------------------------------------------------- /week8/community_contributions/lisekarimi/modal_services/get_started.py: -------------------------------------------------------------------------------- 1 | import sys, modal 2 | 3 | app = modal.App("example-hello-world") 4 | 5 | @app.function() 6 | def f(i: int) -> int: 7 | if i % 2 == 0: 8 | print("hello", i) 9 | else: 10 | print("world", i, file=sys.stderr) 11 | 12 | return i * i 13 | -------------------------------------------------------------------------------- /week1/community-contributions/resume.txt: -------------------------------------------------------------------------------- 1 | John Doe 2 | Software Engineer 3 | Experience: 4 | - Developed web applications using Python and JavaScript. 5 | - Collaborated with cross-functional teams to deliver projects on time. 6 | Education: 7 | - B.S. in Computer Science from XYZ University. 8 | Skills: 9 | - Python, JavaScript, React, SQL 10 | 11 | -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/utils/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | from dotenv import load_dotenv 3 | 4 | # Load environment variables from .env file 5 | load_dotenv() 6 | 7 | class Config: 8 | OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") 9 | 10 | if __name__ == "__main__": 11 | print("Your OpenAI Key is:", Config.OPENAI_API_KEY) -------------------------------------------------------------------------------- /week5/knowledge-base/company/about.md: -------------------------------------------------------------------------------- 1 | # About Insurellm 2 | 3 | Insurellm was founded by Avery Lancaster in 2015 as an insurance tech startup designed to disrupt an industry in need of innovative products. It's first product was Markellm, the marketplace connecting consumers with insurance providers. 4 | It rapidly expanded, adding new products and clients, reaching 200 emmployees by 2024 with 12 offices across the US. -------------------------------------------------------------------------------- /community-contributions/protocol_summarizer_webapp/.gitignore: -------------------------------------------------------------------------------- 1 | updates.md 2 | .env 3 | __pycache__/ 4 | *.py[cod] 5 | *$py.class 6 | *.so 7 | .Python 8 | env/ 9 | build/ 10 | develop-eggs/ 11 | dist/ 12 | downloads/ 13 | eggs/ 14 | .eggs/ 15 | lib/ 16 | lib64/ 17 | parts/ 18 | sdist/ 19 | var/ 20 | *.egg-info/ 21 | .installed.cfg 22 | *.egg 23 | venv/ 24 | ENV/ 25 | .streamlit/ 26 | .idea/ 27 | .vscode/ 28 | *.swp 29 | *.swo 30 | .DS_Store 31 | -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/credentials/gmail_credentials.json: -------------------------------------------------------------------------------- 1 | // delete key 2 | 3 | {"installed":{"client_id":"196620306719-vr5i30l44mqmkmnp7j96iavjfqsfl41f.apps.googleusercontent.com","project_id":"llms-personal-knowledge","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","redirect_uris":["http://localhost"]}} -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/utils/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | # Setup logging configuration 4 | logging.basicConfig( 5 | level=logging.INFO, 6 | format="%(asctime)s - %(levelname)s - %(message)s", 7 | handlers=[ 8 | logging.FileHandler("app.log"), 9 | logging.StreamHandler() 10 | ] 11 | ) 12 | 13 | logger = logging.getLogger(__name__) 14 | 15 | if __name__ == "__main__": 16 | logger.info("Logger is working correctly.") -------------------------------------------------------------------------------- /week5/community-contributions/Week5_Exercise_Personal_Knowledge/credentials/google_drive_workspace_credentials.json: -------------------------------------------------------------------------------- 1 | // delete key 2 | 3 | {"installed":{"client_id":"196620306719-7qvdhd86sau3ngmrrlcb1314us9nuli4.apps.googleusercontent.com","project_id":"llms-personal-knowledge","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","redirect_uris":["http://localhost"]}} -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Python 3 | __pycache__/ 4 | *.py[cod] 5 | *.pyo 6 | *.pyd 7 | .Python 8 | env/ 9 | venv/ 10 | *.env 11 | *.ini 12 | *.log 13 | 14 | # VSCode 15 | .vscode/ 16 | 17 | # IDE files 18 | .idea/ 19 | 20 | # System files 21 | .DS_Store 22 | Thumbs.db 23 | 24 | # Environment variables 25 | .env 26 | 27 | # Jupyter notebook checkpoints 28 | .ipynb_checkpoints 29 | 30 | # Dependencies 31 | *.egg-info/ 32 | dist/ 33 | build/ 34 | -------------------------------------------------------------------------------- /week5/knowledge-base/company/overview.md: -------------------------------------------------------------------------------- 1 | # Overview of Insurellm 2 | 3 | Insurellm is an innovative insurance tech firm with 200 employees across the US. 4 | Insurellm offers 4 insurance software products: 5 | - Carllm, a portal for auto insurance companies 6 | - Homellm, a portal for home insurance companies 7 | - Rellm, an enterprise platform for the reinsurance sector 8 | - Marketllm, a marketplace for connecting consumers with insurance providers 9 | 10 | Insurellm has more than 300 clients worldwide. -------------------------------------------------------------------------------- /community-contributions/protocol_summarizer_webapp/.github/copilot-instructions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | This is a Streamlit web application for clinical trial protocol summarization. Use Streamlit best practices for UI and Python for backend logic. Integrate with ClinicalTrials.gov v2 API for study search and OpenAI for summarization. 4 | -------------------------------------------------------------------------------- /week2/community-contributions/anatomy_poster_generator/README.md: -------------------------------------------------------------------------------- 1 | # Anatomy Poster Generator 2 | 3 | This tool generates AI-powered wall art of human anatomy, designed to support meaningful conversations in clinical spaces. 4 | 5 | Built with: 6 | - DALL·E 3 for image generation 7 | - Python + Gradio for a simple UI 8 | - Hugging Face Spaces for easy sharing (https://huggingface.co/spaces/sukihealth/wallanatomypostergenerator) 9 | 10 | See full repo: [github.com/sukihealth/retro-pop-art-anatomy](https://github.com/sukihealth/retro-pop-art-anatomy) 11 | -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/main.py: -------------------------------------------------------------------------------- 1 | from json_handlers import SettingsHandler, LanguagesHandler 2 | from ollama_utils import get_downloaded_models 3 | from gradio_ui import GradioUI 4 | 5 | settings_json = "settings.json" 6 | languages_json = "languages.json" 7 | 8 | if __name__ == "__main__": 9 | settings = SettingsHandler(settings_json) 10 | languages = LanguagesHandler(languages_json) 11 | 12 | models = get_downloaded_models() 13 | 14 | gradio_ui = GradioUI(models, settings, languages) 15 | gradio_ui.build_and_launch() 16 | -------------------------------------------------------------------------------- /week4/community-contributions/doc_string_exercise/data/original_file.py: -------------------------------------------------------------------------------- 1 | 2 | def calculate(iterations, param1, param2): 3 | result = 1.0 4 | for i in range(1, iterations+1): 5 | j = i * param1 - param2 6 | result -= (1/j) 7 | j = i * param1 + param2 8 | result += (1/j) 9 | return result 10 | 11 | 12 | def calculate_2(iterations, param1, param2): 13 | result = 1.0 14 | for i in range(1, iterations+1): 15 | j = i * param1 - param2 16 | result -= (1/j) 17 | j = i * param1 + param2 18 | result += (1/j) 19 | return result -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | python-dotenv 2 | jupyterlab 3 | ipywidgets 4 | requests 5 | numpy 6 | pandas 7 | scipy 8 | scikit-learn 9 | matplotlib 10 | gensim 11 | torch 12 | transformers 13 | tqdm 14 | openai 15 | gradio 16 | langchain 17 | langchain-core 18 | langchain-text-splitters 19 | langchain-openai 20 | langchain-chroma 21 | langchain-community 22 | datasets==3.6.0 23 | matplotlib 24 | google-generativeai 25 | anthropic 26 | chromadb 27 | plotly 28 | jupyter-dash 29 | beautifulsoup4 30 | pydub 31 | modal 32 | ollama 33 | psutil 34 | setuptools 35 | speedtest-cli 36 | sentence_transformers 37 | feedparser 38 | protobuf==3.20.2 39 | -------------------------------------------------------------------------------- /week1/community-contributions/ag-w1d2-use-local-ollama-url-py: -------------------------------------------------------------------------------- 1 | import ollama 2 | import requests 3 | from IPython.display import Markdown, display 4 | 5 | OLLAMA_API = "http://localhost:11434/api/chat" 6 | HEADERS = {"Content-Type": "application/json"} 7 | MODEL = "llama3.2" 8 | 9 | # Create a messages list (Note that "system" role is not required) 10 | messages = [ 11 | { "role": "user", "content": "Describe some of the business applications of Generative AI"} 12 | ] 13 | 14 | payload = { 15 | "model": MODEL, 16 | "messages": messages, 17 | "stream": False 18 | } 19 | 20 | response = requests.post(OLLAMA_API, json=payload, headers=HEADERS) 21 | print(response.json()['message']['content']) 22 | 23 | -------------------------------------------------------------------------------- /week2/community-contributions/oh_sheet_its_spark.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "## Repo link to a LLM App that can help you convert any Excel Spreadsheet with formulas into Pyspark equivalent transformations in a matter of few clicks " 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "https://github.com/jasjyotsinghjaswal/llm_custom_apps" 15 | ] 16 | }, 17 | { 18 | "cell_type": "markdown", 19 | "metadata": {}, 20 | "source": [] 21 | } 22 | ], 23 | "metadata": { 24 | "language_info": { 25 | "name": "python" 26 | } 27 | }, 28 | "nbformat": 4, 29 | "nbformat_minor": 2 30 | } 31 | -------------------------------------------------------------------------------- /week1/community-contributions/xss_vulnerable_example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | XSS Vulnerability Example 6 | 7 | 8 |

Leave a Comment

9 |
10 | 11 | 12 |
13 | 14 |

Your Comment:

15 |

16 | 17 | 18 | 22 |

23 | 24 | -------------------------------------------------------------------------------- /week8/hello.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from modal import App, Image 3 | 4 | # Setup 5 | 6 | app = modal.App("hello") 7 | image = Image.debian_slim().pip_install("requests") 8 | 9 | # Hello! 10 | 11 | @app.function(image=image) 12 | def hello() -> str: 13 | import requests 14 | 15 | response = requests.get('https://ipinfo.io/json') 16 | data = response.json() 17 | city, region, country = data['city'], data['region'], data['country'] 18 | return f"Hello from {city}, {region}, {country}!!" 19 | 20 | # New - added thanks to student Tue H.! 21 | 22 | @app.function(image=image, region="eu") 23 | def hello_europe() -> str: 24 | import requests 25 | 26 | response = requests.get('https://ipinfo.io/json') 27 | data = response.json() 28 | city, region, country = data['city'], data['region'], data['country'] 29 | return f"Hello from {city}, {region}, {country}!!" 30 | -------------------------------------------------------------------------------- /week4/community-contributions/doc_string_exercise/README.md: -------------------------------------------------------------------------------- 1 | # Script Overview 2 | 3 | The documentation will show you how to run the python script generate_doc_string.py. It is designed to take input 4 | from an existing python file and create a new one with a suffix ('claude' or 'gpt'). If you do not specify and llm 5 | model, it will default to claude. 6 | 7 | # How to run 8 | 9 | ```powershell 10 | conda activate llms 11 | cd 12 | python generate_doc_string -fp -llm 13 | ``` 14 | 15 | # Show Help Instructions 16 | 17 | ```shell 18 | python generate_doc_string --help 19 | ``` 20 | 21 | # Error Checking 22 | 23 | 1) File Path Existence 24 | 25 | If the file path doesn't exist, the script will stop running and print out an error. 26 | 27 | 2) LLM Model Choice 28 | 29 | If you choose something other than 'gpt' or 'claude', it will show and assertion error. -------------------------------------------------------------------------------- /week8/log_utils.py: -------------------------------------------------------------------------------- 1 | # Foreground colors 2 | RED = '\033[31m' 3 | GREEN = '\033[32m' 4 | YELLOW = '\033[33m' 5 | BLUE = '\033[34m' 6 | MAGENTA = '\033[35m' 7 | CYAN = '\033[36m' 8 | WHITE = '\033[37m' 9 | 10 | # Background color 11 | BG_BLACK = '\033[40m' 12 | BG_BLUE = '\033[44m' 13 | 14 | # Reset code to return to default color 15 | RESET = '\033[0m' 16 | 17 | mapper = { 18 | BG_BLACK+RED: "#dd0000", 19 | BG_BLACK+GREEN: "#00dd00", 20 | BG_BLACK+YELLOW: "#dddd00", 21 | BG_BLACK+BLUE: "#0000ee", 22 | BG_BLACK+MAGENTA: "#aa00dd", 23 | BG_BLACK+CYAN: "#00dddd", 24 | BG_BLACK+WHITE: "#87CEEB", 25 | BG_BLUE+WHITE: "#ff7800" 26 | } 27 | 28 | 29 | def reformat(message): 30 | for key, value in mapper.items(): 31 | message = message.replace(key, f'') 32 | message = message.replace(RESET, '') 33 | return message 34 | 35 | -------------------------------------------------------------------------------- /week8/agents/agent.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | class Agent: 4 | """ 5 | An abstract superclass for Agents 6 | Used to log messages in a way that can identify each Agent 7 | """ 8 | 9 | # Foreground colors 10 | RED = '\033[31m' 11 | GREEN = '\033[32m' 12 | YELLOW = '\033[33m' 13 | BLUE = '\033[34m' 14 | MAGENTA = '\033[35m' 15 | CYAN = '\033[36m' 16 | WHITE = '\033[37m' 17 | 18 | # Background color 19 | BG_BLACK = '\033[40m' 20 | 21 | # Reset code to return to default color 22 | RESET = '\033[0m' 23 | 24 | name: str = "" 25 | color: str = '\033[37m' 26 | 27 | def log(self, message): 28 | """ 29 | Log this as an info message, identifying the agent 30 | """ 31 | color_code = self.BG_BLACK + self.color 32 | message = f"[{self.name}] {message}" 33 | logging.info(color_code + message + self.RESET) -------------------------------------------------------------------------------- /week2/community-contributions/taskmanagement/readme.md: -------------------------------------------------------------------------------- 1 | This code implements a Gradio chat application that integrates with OpenAI models for the chat functionality, with special handling for ABCD tasks. 2 | 3 | # Main Features 4 | 1. **General Chat**: Use OpenAI's GPT to handle normal conversation. 5 | 2. **Task Checking**: When users mention "check ABCD tasks" (or similar phrases), the app calls the abcd_taskTool() function. 6 | 3. **Account Number Masking**: Masks the first four digits of account number with "XXXX". 7 | 4. **Task Display**: in HTML table. 8 | 5. **Support Notification**: Offers to notify support team and calls abcd_NotifyTool() if user confirms. 9 | 6. **Cheerful Responses**: Provides rando encouraging messages when no tasks are found. 10 | 11 | ## Screenshot 12 | ![Chat1](https://github.com/sngo/llms-practice/blob/main/taskmanagement/chat1.png) 13 | ![Chat2](https://github.com/sngo/llms-practice/blob/main/taskmanagement/chat2.png) 14 | -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/log_utils.py: -------------------------------------------------------------------------------- 1 | # Foreground colors 2 | RED = '\033[31m' 3 | GREEN = '\033[32m' 4 | YELLOW = '\033[33m' 5 | BLUE = '\033[34m' 6 | MAGENTA = '\033[35m' 7 | CYAN = '\033[36m' 8 | WHITE = '\033[37m' 9 | 10 | # Background color 11 | BG_BLACK = '\033[40m' 12 | BG_BLUE = '\033[44m' 13 | 14 | # Reset code to return to default color 15 | RESET = '\033[0m' 16 | 17 | mapper = { 18 | BG_BLACK+RED: "#dd0000", 19 | BG_BLACK+GREEN: "#00dd00", 20 | BG_BLACK+YELLOW: "#dddd00", 21 | BG_BLACK+BLUE: "#0000ee", 22 | BG_BLACK+MAGENTA: "#aa00dd", 23 | BG_BLACK+CYAN: "#00dddd", 24 | BG_BLACK+WHITE: "#87CEEB", 25 | BG_BLUE+WHITE: "#ff7800" 26 | } 27 | 28 | 29 | def reformat(message): 30 | for key, value in mapper.items(): 31 | message = message.replace(key, f'') 32 | message = message.replace(RESET, '') 33 | return message 34 | 35 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: llms 2 | channels: 3 | - conda-forge 4 | - defaults 5 | dependencies: 6 | - python=3.11 7 | - pip 8 | - python-dotenv 9 | - requests 10 | - numpy 11 | - pandas 12 | - scipy 13 | - pytorch 14 | - jupyterlab 15 | - ipywidgets 16 | - matplotlib 17 | - scikit-learn 18 | - chromadb 19 | - jupyter-dash 20 | - pyarrow 21 | - pip: 22 | - beautifulsoup4 23 | - plotly 24 | - transformers 25 | - sentence-transformers 26 | - datasets==3.6.0 27 | - openai 28 | - anthropic 29 | - google-generativeai 30 | - gradio 31 | - gensim 32 | - modal 33 | - ollama 34 | - psutil 35 | - setuptools 36 | - speedtest-cli 37 | - langchain 38 | - langchain-core 39 | - langchain-text-splitters 40 | - langchain-openai 41 | - langchain-chroma 42 | - langchain-community 43 | - feedparser 44 | - twilio 45 | - pydub 46 | - protobuf==3.20.2 47 | -------------------------------------------------------------------------------- /week8/community_contributions/lisekarimi/agents/base_agent.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | class Agent: 4 | """ 5 | An abstract superclass for Agents 6 | Used to log messages in a way that can identify each Agent 7 | """ 8 | 9 | # Foreground colors 10 | RED = '\033[31m' 11 | GREEN = '\033[32m' 12 | YELLOW = '\033[33m' 13 | BLUE = '\033[34m' 14 | MAGENTA = '\033[35m' 15 | CYAN = '\033[36m' 16 | WHITE = '\033[37m' 17 | 18 | # Background color 19 | BG_BLACK = '\033[40m' 20 | 21 | # Reset code to return to default color 22 | RESET = '\033[0m' 23 | 24 | name: str = "" 25 | color: str = '\033[37m' 26 | 27 | def log(self, message): 28 | """ 29 | Log this as an info message, identifying the agent 30 | """ 31 | color_code = self.BG_BLACK + self.color 32 | message = f"[{self.name}] {message}" 33 | logging.info(color_code + message + self.RESET) -------------------------------------------------------------------------------- /week5/community-contributions/Personal Knowledge Worker/sameer-db/personal/sameer.md: -------------------------------------------------------------------------------- 1 | # Sameer Khadatkar 2 | 3 | Hi, I am **Sameer Khadatkar**, born and brought up in **Nagpur**. 4 | 5 | I completed my schooling from **Dinanath Junior College and High School, Nagpur** up to 12th standard. After that, I moved to **Amravati** for my Bachelor's degree. 6 | 7 | ### Academic Journey 8 | I prepared for the **GATE Mechanical Engineering (ME)** exam: 9 | - **2020**: Rank **377** 10 | 11 | With this rank, I secured admission to the prestigious **Indian Institute of Science (IISc), Bangalore**. 12 | 13 | ### Career 14 | I later got placed at **Wells Fargo**, Hyderabad. 15 | 16 | ### Personal Life 17 | - I got married to my batchmate from Government College of Engineering Amravati. 18 | 19 | ### Hobbies & Interests 20 | I played **Cycle Polo** up to my 8th standard and even competed at the **national level**. 21 | 22 | ### Family 23 | - Parents, elder sister and wife. 24 | -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/agents/agent.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | class Agent: 4 | """ 5 | An abstract superclass for Agents 6 | Used to log messages in a way that can identify each Agent 7 | """ 8 | 9 | # Foreground colors 10 | RED = '\033[31m' 11 | GREEN = '\033[32m' 12 | YELLOW = '\033[33m' 13 | BLUE = '\033[34m' 14 | MAGENTA = '\033[35m' 15 | CYAN = '\033[36m' 16 | WHITE = '\033[37m' 17 | 18 | # Background color 19 | BG_BLACK = '\033[40m' 20 | 21 | # Reset code to return to default color 22 | RESET = '\033[0m' 23 | 24 | name: str = "" 25 | color: str = '\033[37m' 26 | 27 | def log(self, message): 28 | """ 29 | Log this as an info message, identifying the agent 30 | """ 31 | color_code = self.BG_BLACK + self.color 32 | message = f"[{self.name}] {message}" 33 | logging.info(color_code + message + self.RESET) -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/summarizer/fetcher.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | 4 | def fetch_web_content(url): 5 | try: 6 | response = requests.get(url) 7 | response.raise_for_status() 8 | 9 | # Parse the HTML content 10 | soup = BeautifulSoup(response.text, 'html.parser') 11 | 12 | # Extract readable text from the web page (ignoring scripts, styles, etc.) 13 | page_text = soup.get_text(separator=' ', strip=True) 14 | 15 | return page_text[:5000] # Limit to 5000 chars (API limitation) 16 | except requests.exceptions.RequestException as e: 17 | print(f"Error fetching the webpage: {e}") 18 | return None 19 | 20 | if __name__ == "__main__": 21 | url = "https://en.wikipedia.org/wiki/Natural_language_processing" 22 | content = fetch_web_content(url) 23 | print(content[:500]) # Print a sample of the content 24 | -------------------------------------------------------------------------------- /week2/community-contributions/3_chatbots_Converstion/README.md: -------------------------------------------------------------------------------- 1 | 2 | # 3 Way Chatbot Conversation 3 | Making the different models from Anthropic, OpenAI and Ollama converse with each other. 4 | 5 | ## Contents 6 | 7 | - `Conversation_Day1.ipynb`: The notebook file with all code and explanations for the first day. 8 | - `Conversation_Outputs`: The chatbots conversations for each topic 9 | - `requirements.txt`:For installing the dependencies 10 | - `README.md`: This file. 11 | 12 | ## How to Run 13 | 14 | 1. Clone this repository. 15 | 2. I'm using 'Python 3.11.13' with Jupyter Notebook or JupyterLab. 16 | 3. Install dependencies (see below). 17 | 4. Open the notebook using Jupyter: 18 | 19 | ```bash 20 | jupyter notebook Conversation_Day1.ipynb 21 | ``` 22 | 23 | ## Dependencies 24 | 25 | Install the required Python libraries using: 26 | 27 | ```bash 28 | pip install -r requirements.txt 29 | ``` 30 | 31 | --- 32 | 33 | ### Author 34 | 35 | Mustafa Kashif 36 | 37 | -------------------------------------------------------------------------------- /week3/day3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "61f56afc-bc15-46a4-8eb1-d940c332cf52", 6 | "metadata": {}, 7 | "source": [ 8 | "# Tokenizers\n", 9 | "\n", 10 | "Please can I bring you back to the wonderful Google Colab where we'll look at different Tokenizers:\n", 11 | "\n", 12 | "https://colab.research.google.com/drive/1WD6Y2N7ctQi1X9wa6rpkg8UfyA4iSVuz?usp=sharing" 13 | ] 14 | } 15 | ], 16 | "metadata": { 17 | "kernelspec": { 18 | "display_name": "Python 3 (ipykernel)", 19 | "language": "python", 20 | "name": "python3" 21 | }, 22 | "language_info": { 23 | "codemirror_mode": { 24 | "name": "ipython", 25 | "version": 3 26 | }, 27 | "file_extension": ".py", 28 | "mimetype": "text/x-python", 29 | "name": "python", 30 | "nbconvert_exporter": "python", 31 | "pygments_lexer": "ipython3", 32 | "version": "3.11.11" 33 | } 34 | }, 35 | "nbformat": 4, 36 | "nbformat_minor": 5 37 | } 38 | -------------------------------------------------------------------------------- /week1/community-contributions/ag-w1d2-use-local-ollama-with-openai.py: -------------------------------------------------------------------------------- 1 | from openai import OpenAI 2 | 3 | MODEL = "llama3.2" 4 | 5 | messages = [ 6 | { "role": "user", "content": "Describe some of the business applications of Generative AI"} 7 | ] 8 | 9 | # The python class OpenAI is simply code written by OpenAI engineers that 10 | # makes calls over the internet to an endpoint. 11 | ollama_via_openai = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama') 12 | 13 | # When we call openai.chat.completions.create(), this python code just makes 14 | # a web request to: "https://api.openai.com/v1/chat/completions" 15 | # Code like this is known as a "client library" - it's just wrapper code that 16 | # runs on your machine to make web requests. The actual power of GPT is running 17 | # on OpenAI's cloud behind this API, not on your computer 18 | response = ollama_via_openai.chat.completions.create( 19 | model=MODEL, 20 | messages=messages 21 | ) 22 | 23 | print(response.choices[0].message.content) 24 | -------------------------------------------------------------------------------- /week7/day1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "c25e5705-7078-4d4a-9fa2-8aaa528ffced", 6 | "metadata": {}, 7 | "source": [ 8 | "# Week 7 Day 1\n", 9 | "\n", 10 | "Fine-tune an open-source model to Predict Product Prices\n", 11 | "\n", 12 | "Please see this notebook in Google Colab:\n", 13 | "\n", 14 | "https://colab.research.google.com/drive/15rqdMTJwK76icPBxNoqhI7Ww8UM-Y7ni?usp=sharing" 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 3 (ipykernel)", 21 | "language": "python", 22 | "name": "python3" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 3 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython3", 34 | "version": "3.11.11" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 5 39 | } 40 | -------------------------------------------------------------------------------- /week7/day2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "c25e5705-7078-4d4a-9fa2-8aaa528ffced", 6 | "metadata": {}, 7 | "source": [ 8 | "# Week 7 Day 2\n", 9 | "\n", 10 | "Fine-tune an open-source model to Predict Product Prices\n", 11 | "\n", 12 | "Please see this notebook in Google Colab:\n", 13 | "\n", 14 | "https://colab.research.google.com/drive/1T72pbfZw32fq-clQEp-p8YQ4_qFKv4TP?usp=sharing" 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 3 (ipykernel)", 21 | "language": "python", 22 | "name": "python3" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 3 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython3", 34 | "version": "3.11.11" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 5 39 | } 40 | -------------------------------------------------------------------------------- /week7/day5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "c25e5705-7078-4d4a-9fa2-8aaa528ffced", 6 | "metadata": {}, 7 | "source": [ 8 | "# Week 7 Days 5\n", 9 | "\n", 10 | "Fine-tune an open-source model to Predict Product Prices\n", 11 | "\n", 12 | "Please see this notebook in Google Colab:\n", 13 | "\n", 14 | "https://colab.research.google.com/drive/1igA0HF0gvQqbdBD4GkcK3GpHtuDLijYn?usp=sharing" 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 3 (ipykernel)", 21 | "language": "python", 22 | "name": "python3" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 3 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython3", 34 | "version": "3.11.11" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 5 39 | } 40 | -------------------------------------------------------------------------------- /week7/day3 and 4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "c25e5705-7078-4d4a-9fa2-8aaa528ffced", 6 | "metadata": {}, 7 | "source": [ 8 | "# Week 7 Days 3 and 4\n", 9 | "\n", 10 | "Fine-tune an open-source model to Predict Product Prices\n", 11 | "\n", 12 | "Please see this notebook in Google Colab:\n", 13 | "\n", 14 | "https://colab.research.google.com/drive/1csEdaECRtjV_1p9zMkaKKjCpYnltlN3M?usp=sharing" 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 3 (ipykernel)", 21 | "language": "python", 22 | "name": "python3" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 3 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython3", 34 | "version": "3.11.11" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 5 39 | } 40 | -------------------------------------------------------------------------------- /week1/community-contributions/ag-w1d2-use-local-ollama-library.py: -------------------------------------------------------------------------------- 1 | import ollama 2 | from IPython.display import Markdown, display 3 | 4 | MODEL = "llama3.2" 5 | 6 | # Create a messages list (Note that "system" role is not required) 7 | messages = [ 8 | { "role": "user", "content": "Describe some of the business applications of Generative AI"} 9 | ] 10 | 11 | """ 12 | #under the covers calls this API with specified payload 13 | 14 | OLLAMA_API = "http://local_host:11434/api/chat" 15 | payload = { 16 | "model": MODEL, 17 | "messages": messages, 18 | "stream": False 19 | } 20 | response = requests.post(OLLAMA_API, json=payload, headers=HEADERS) 21 | 22 | """ 23 | response = ollama.chat(model=MODEL, messages=messages) 24 | #print(response['message']['content']) 25 | answer = response['message']['content'] 26 | 27 | #Note that markdown will not display in VSCode but only in Jupyter 28 | #to view in markdown in VSCode, save output to .md file and then oipen in VSCode 29 | display(Markdown(answer)) 30 | print(answer) 31 | 32 | 33 | -------------------------------------------------------------------------------- /week3/day4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "61f56afc-bc15-46a4-8eb1-d940c332cf52", 6 | "metadata": {}, 7 | "source": [ 8 | "# Models\n", 9 | "\n", 10 | "And now - this colab unveils the heart (or the brains?) of the transformers library - the models:\n", 11 | "\n", 12 | "https://colab.research.google.com/drive/1hhR9Z-yiqjUe7pJjVQw4c74z_V3VchLy?usp=sharing\n", 13 | "\n", 14 | "This should run nicely on a low-cost or free T4 box." 15 | ] 16 | } 17 | ], 18 | "metadata": { 19 | "kernelspec": { 20 | "display_name": "Python 3 (ipykernel)", 21 | "language": "python", 22 | "name": "python3" 23 | }, 24 | "language_info": { 25 | "codemirror_mode": { 26 | "name": "ipython", 27 | "version": 3 28 | }, 29 | "file_extension": ".py", 30 | "mimetype": "text/x-python", 31 | "name": "python", 32 | "nbconvert_exporter": "python", 33 | "pygments_lexer": "ipython3", 34 | "version": "3.11.11" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 5 39 | } 40 | -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/ollama_utils.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import ollama 4 | 5 | 6 | def get_downloaded_models(): 7 | models_raw = requests.get("http://localhost:11434/api/tags").content 8 | models_dict = json.loads(models_raw) 9 | models = [model["name"] for model in models_dict["models"]] 10 | return models 11 | 12 | def get_ollama_response(model, prompt, translte_from, translte_to, options): 13 | def get_system_prompt(): 14 | with open('system_prompt.txt', 'r') as file: 15 | system_prompt = file.read() 16 | return system_prompt 17 | 18 | system_prompt = get_system_prompt() 19 | user_prompt = f"Translate from {translte_from} to {translte_to}: {prompt}" 20 | messages = [ 21 | {"role": "system", "content": system_prompt}, 22 | {"role": "user", "content": user_prompt} 23 | ] 24 | 25 | response = ollama.chat(model, messages, options=options, stream=True) 26 | for chunck in response: 27 | 28 | yield chunck["message"]["content"] 29 | -------------------------------------------------------------------------------- /week8/agents/specialist_agent.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from agents.agent import Agent 3 | 4 | 5 | class SpecialistAgent(Agent): 6 | """ 7 | An Agent that runs our fine-tuned LLM that's running remotely on Modal 8 | """ 9 | 10 | name = "Specialist Agent" 11 | color = Agent.RED 12 | 13 | def __init__(self): 14 | """ 15 | Set up this Agent by creating an instance of the modal class 16 | """ 17 | self.log("Specialist Agent is initializing - connecting to modal") 18 | Pricer = modal.Cls.from_name("pricer-service", "Pricer") 19 | self.pricer = Pricer() 20 | self.log("Specialist Agent is ready") 21 | 22 | def price(self, description: str) -> float: 23 | """ 24 | Make a remote call to return the estimate of the price of this item 25 | """ 26 | self.log("Specialist Agent is calling remote fine-tuned model") 27 | result = self.pricer.price.remote(description) 28 | self.log(f"Specialist Agent completed - predicting ${result:.2f}") 29 | return result 30 | -------------------------------------------------------------------------------- /week3/community-contributions/ai-web-summarizer/main.py: -------------------------------------------------------------------------------- 1 | from summarizer.fetcher import fetch_web_content 2 | from summarizer.summarizer import summarize_text 3 | from utils.logger import logger 4 | 5 | def main(): 6 | url = input("Enter a URL to summarize: ") 7 | 8 | logger.info(f"Fetching content from: {url}") 9 | content = fetch_web_content(url) 10 | 11 | if content: 12 | logger.info("Content fetched successfully. Sending to OpenAI for summarization...") 13 | # summary = summarize_text(content,'gpt-4o-mini', engine="openai") 14 | # summary = summarize_text(content, 'deepseek-r1:1.5B', engine="ollama-lib") 15 | summary = summarize_text(content, 'deepseek-r1:1.5B', engine="ollama-api") 16 | 17 | 18 | if summary: 19 | logger.info("Summary generated successfully.") 20 | print("\nSummary of the page:\n") 21 | print(summary) 22 | else: 23 | logger.error("Failed to generate summary.") 24 | else: 25 | logger.error("Failed to fetch web content.") 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/agents/specialist_agent.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from agents.agent import Agent 3 | 4 | 5 | class SpecialistAgent(Agent): 6 | """ 7 | An Agent that runs our fine-tuned LLM that's running remotely on Modal 8 | """ 9 | 10 | name = "Specialist Agent" 11 | color = Agent.RED 12 | 13 | def __init__(self): 14 | """ 15 | Set up this Agent by creating an instance of the modal class 16 | """ 17 | self.log("Specialist Agent is initializing - connecting to modal") 18 | Pricer = modal.Cls.from_name("pricer-service", "Pricer") 19 | self.pricer = Pricer() 20 | self.log("Specialist Agent is ready") 21 | 22 | def price(self, description: str) -> float: 23 | """ 24 | Make a remote call to return the estimate of the price of this item 25 | """ 26 | self.log("Specialist Agent is calling remote fine-tuned model") 27 | result = self.pricer.price.remote(description) 28 | self.log(f"Specialist Agent completed - predicting ${result:.2f}") 29 | return result 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Ed Donner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /week1/community-contributions/Chat_Summary_Data/Chat_Examples/Chat3.txt: -------------------------------------------------------------------------------- 1 | Client: Hello. What is the most selling pizza on your menu? 2 | Restaurant: Hello! Chicken Ranch pizza is our most selling pizza. Also our special pepperoni pizza got some amazing reviews 3 | Client: Okay. I want to order a pepperoni pizza 4 | Restaurant: Sure. Do you want it small, medium, or large? 5 | Client: Large 6 | Restaurant: Okay. This will be 210 LE. Would you like to order something else? 7 | Client: Yes. Do you have onion rings? 8 | Restaurant: Yes 9 | Client: Okay I would like to add onion rings. 10 | Restaurant: Sure. This will be 250 LE 11 | Client: Thanks 12 | Restaurant: Anytime 13 | Client: I have been waiting for too long and the order hasn't arrived yet 14 | Restaurant: Sorry to hear that. But it appears that the order is on its way to you. 15 | Restaurant: The order is supposed to be arrived by now. 16 | Client: Yes it is arrived. 17 | Restaurant: How is your experience? 18 | Client: Your pizza tastes soooooo good. The order took too long to arrive but when I tasted the pizza, I was really enjoying it and forgot everything about the delay. 19 | Restaurant: We are so glad to hear that -------------------------------------------------------------------------------- /week2/community-contributions/medical_prescription_to_google_calender/src/main.py: -------------------------------------------------------------------------------- 1 | from ocr import * 2 | from calendar_auth import * 3 | from create_calender_events import * 4 | from parsing_json import * 5 | from preprocess import * 6 | 7 | image_path = r"C:\Users\Legion\Desktop\projects\medical_prescription_to_google_calender\test_data\prescription_page-0001.jpg" 8 | 9 | extracted_text = extract_text_from_image(image_path=image_path) 10 | print(extracted_text) 11 | cleaned_text = clean_text(extracted_text) 12 | print(cleaned_text) 13 | structured_data = preprocess_extracted_text(cleaned_text) 14 | print(structured_data) 15 | final_structured_data = process_dates(structured_data) 16 | print(final_structured_data) 17 | formatted_calender_events = format_calendar_events(final_structured_data) 18 | print(formatted_calender_events) 19 | validated_events = [validate_event(event) for event in formatted_calender_events] 20 | for event in validated_events[:5]: 21 | print(json.dumps(event, indent=2)) 22 | service = authenticate_google_calender() 23 | gcal_events = convert_to_gcal_events(validated_events) 24 | 25 | for event in gcal_events: 26 | create_event(service, event) 27 | -------------------------------------------------------------------------------- /week1/community-contributions/Chat_Summary_Data/System_Prompt.txt: -------------------------------------------------------------------------------- 1 | You are an assistant working for the customer service department in a pizza restaurant. 2 | You are to receive a chat between a client and the restaurant's customer service. 3 | You should generate your responses based on the following criteria: 4 | - What did the client order? 5 | - How much did it cost? 6 | - If the client changed their mind just keep their final order and the final cost 7 | - Mention the client's experience only if they ordered anything as follows: (Positive/Negative/Neutral/Unknown) 8 | - If the client did not order anything do not mention their sentiment or experience 9 | - If the client's experience is positive or negative only, provide a brief summary about their sentiment 10 | - Do not provide brief summary about their sentiment if their experience was neutral or unknown. 11 | - Your answers should be clear, straight to the point, and do not use long sentences 12 | - Your answers should be displayed in bullet points 13 | - Your answers should be displayed in markdown 14 | - If the client did not order anything provide a brief summary why that might happened 15 | - Do not mention cost if the client did not order anything -------------------------------------------------------------------------------- /week5/community-contributions/rag_chat_example/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This uses de-identified medical dictation data supplied by [mtsamples](https://mtsamples.com). The data from the mtsamples 4 | website was download from [kaggle](https://www.kaggle.com/datasets/tboyle10/medicaltranscriptions). There are four 5 | sample notes in different directories (see knowledge_base/mtsamples_dictations) that will added to a chromaDb 6 | vector database and will be available during chat using RAG (Retrieval Augmented Generation). 7 | 8 | # How to run 9 | 10 | - Run example 11 | 12 | ```shell 13 | conda activate 14 | cd 15 | python run_rag_chat.py 16 | ``` 17 | 18 | # Chat example 19 | 20 | ![Chat Example](img.png) 21 | 22 | # Questions to ask? 23 | 24 | 1) How old is Ms. Connor? 25 | 2) What are Ms. Connor's vital signs? 26 | 3) How old is Ms. Mouse? 27 | 4) What is Ms. Mouse concerned about? 28 | 5) What are Ms. Mouse's vital signs? 29 | 6) How old is Mr. Duck? 30 | 7) Why did Mr. Duck go to the doctor? 31 | 8) How old is Ms. Barbara? 32 | 9) Why did Ms. Barbara go to the doctor? 33 | 10) Is Ms. Barbara allergic to anything? 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /week8/community_contributions/lisekarimi/agents/ft_price_agent.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from agents.base_agent import Agent 3 | 4 | 5 | class FTPriceAgent(Agent): 6 | """ 7 | An Agent that runs the fine-tuned LLM that's running remotely on Modal 8 | """ 9 | 10 | name = "FTPrice Agent" 11 | color = Agent.RED 12 | 13 | def __init__(self): 14 | """ 15 | Set up this Agent by creating an instance of the modal class 16 | """ 17 | self.log("FTPrice Agent is initializing - connecting to modal") 18 | Pricer = modal.Cls.from_name("llm-ft-pricer", "Pricer") # 1st API call: to fetch Pricer (remote class) 19 | self.pricer = Pricer() 20 | self.log("FTPrice Agent is ready") 21 | 22 | def price(self, description: str) -> float: 23 | """ 24 | Make a remote call to return the estimate of the price of this item 25 | """ 26 | self.log("FTPrice Agent is calling remote fine-tuned model") 27 | result = self.pricer.price.remote(description) # 2nd API call: to run the price method in the remote Pricer class 28 | self.log(f"FTPrice Agent completed - predicting ${result:.2f}") 29 | return result -------------------------------------------------------------------------------- /community-contributions/multi-agent_gui_with_gradio/README.md: -------------------------------------------------------------------------------- 1 | # 🧠 Agentic Voice/Text Support Chatbot 2 | 3 | A multimodal chatbot interface with support for **text and voice input**, **multiple large language models (LLMs)**, and **context memory persistence** — all in a single Gradio-based GUI. 4 | 5 | ## 🚀 Features 6 | 7 | - 🔄 **Multi-LLM switching**: Dynamically switch between OpenAI, Anthropic Claude, and Meta LLaMA (via Ollama) 8 | - 🎤 **Voice input**: Use your microphone with live speech-to-text transcription 9 | - 💬 **Contextual memory**: Maintain chat history even when switching models 10 | - 🧪 **Prototype-ready**: Built with Gradio for rapid GUI testing and development 11 | 12 | ## 🛠️ Technologies Used 13 | 14 | - [Gradio](https://www.gradio.app/) – GUI interface 15 | - [OpenAI API](https://platform.openai.com/) 16 | - [Anthropic Claude API](https://www.anthropic.com/) 17 | - [Ollama](https://ollama.com/) – Local LLaMA inference 18 | - [`speech_recognition`](https://pypi.org/project/SpeechRecognition/) – Voice-to-text 19 | - `sounddevice`, `numpy` – Audio recording 20 | - `.env` – Environment variable management 21 | 22 | ## You’ll also need: 23 | - API keys for OpenAI and Claude 24 | - Ollama installed locally to run LLaMA models 25 | - A .env file with the necessary API keys 26 | -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/system_prompt.txt: -------------------------------------------------------------------------------- 1 | You are a translator. 2 | You should translate the prompts according to the following criteria: 3 | - You should respond in a clear and straight to the point responses. 4 | - Your response should have a good structure and good linguistic features. 5 | - You should translate the sentence as it is. Do not add extra sentences or phrases on your own. 6 | - Do not answer questions even if the prompt is a question, you should translate the question and do not anwer it. 7 | - If you do not understand the prompt, do not say that you do not understand, just echo the prompt. 8 | - Do not include in the response phrases like 'here is the translation' or any phrases like that 9 | Here are some examples for good responses: 10 | < 11 | Prompt: 'Translate from French to English: Hier, j'ai passé toute la journée à explorer la ville avec mes amis, et nous avons visité plusieurs musées avant de nous arrêter pour un délicieux dîner dans un restaurant local.' 12 | Response: 'Yesterday, I spent the whole day exploring the city with my friends, and we visited several museums before stopping for a delicious dinner at a local restaurant.' 13 | > 14 | < 15 | Prompt: 'Translate from Spanish to English: vdaiughadvlkj' 16 | Response: 'vdaiughadvlkj' 17 | > 18 | -------------------------------------------------------------------------------- /week8/community_contributions/pricer_test/README.md: -------------------------------------------------------------------------------- 1 | # Run Continuous Integration (CI) Tests on Modal 2 | 3 | ## Unit testing 4 | Unit test strategy created like in 5 | [This example repo](https://github.com/modal-labs/ci-on-modal) 6 | 7 | ## Usage 8 | 9 | All commands below are run from the root of the repository (this directory). 10 | _Note_: I removed modal-decorators from pricer.ci-module to be able to run unit tests. 11 | 12 | ### Run tests remotely on Modal 13 | 14 | ```bash 15 | modal run pricer.ci::pytest 16 | ``` 17 | 18 | On the first execution, the [container image](https://modal.com/docs/guide/custom-container) 19 | for your application will be built. 20 | 21 | This image will be cached on Modal and only rebuilt if one of its dependencies, 22 | like the `requirements.txt` file, changes. 23 | 24 | ### Debug tests running remotely 25 | 26 | To debug the tests, you can open a shell 27 | in the exact same environment that the tests are run in: 28 | 29 | ```bash 30 | modal shell pricer.ci::pytest 31 | ``` 32 | 33 | _Note_: On the Modal worker, the `pytest` command is run from the home directory, `/root`, 34 | which contains the `tests` folder, but the `modal shell` command will 35 | drop you at the top of the filesystem, `/`. 36 | 37 | To run test: 38 | ```bash 39 | cd root 40 | pytest 41 | ``` -------------------------------------------------------------------------------- /week8/agents/random_forest_agent.py: -------------------------------------------------------------------------------- 1 | # imports 2 | 3 | import os 4 | import re 5 | from typing import List 6 | from sentence_transformers import SentenceTransformer 7 | import joblib 8 | from agents.agent import Agent 9 | 10 | 11 | 12 | class RandomForestAgent(Agent): 13 | 14 | name = "Random Forest Agent" 15 | color = Agent.MAGENTA 16 | 17 | def __init__(self): 18 | """ 19 | Initialize this object by loading in the saved model weights 20 | and the SentenceTransformer vector encoding model 21 | """ 22 | self.log("Random Forest Agent is initializing") 23 | self.vectorizer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') 24 | self.model = joblib.load('random_forest_model.pkl') 25 | self.log("Random Forest Agent is ready") 26 | 27 | def price(self, description: str) -> float: 28 | """ 29 | Use a Random Forest model to estimate the price of the described item 30 | :param description: the product to be estimated 31 | :return: the price as a float 32 | """ 33 | self.log("Random Forest Agent is starting a prediction") 34 | vector = self.vectorizer.encode([description]) 35 | result = max(0, self.model.predict(vector)[0]) 36 | self.log(f"Random Forest Agent completed - predicting ${result:.2f}") 37 | return result -------------------------------------------------------------------------------- /week3/day5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "61f56afc-bc15-46a4-8eb1-d940c332cf52", 6 | "metadata": {}, 7 | "source": [ 8 | "# Meeting minutes creator\n", 9 | "\n", 10 | "In this colab, we make a meeting minutes program.\n", 11 | "\n", 12 | "It includes useful code to connect your Google Drive to your colab.\n", 13 | "\n", 14 | "Upload your own audio to make this work!!\n", 15 | "\n", 16 | "https://colab.research.google.com/drive/1KSMxOCprsl1QRpt_Rq0UqCAyMtPqDQYx?usp=sharing\n", 17 | "\n", 18 | "This should run nicely on a low-cost or free T4 box." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "id": "e9289ba7-200c-43a9-b67a-c5ce826c9537", 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [] 28 | } 29 | ], 30 | "metadata": { 31 | "kernelspec": { 32 | "display_name": "Python 3 (ipykernel)", 33 | "language": "python", 34 | "name": "python3" 35 | }, 36 | "language_info": { 37 | "codemirror_mode": { 38 | "name": "ipython", 39 | "version": 3 40 | }, 41 | "file_extension": ".py", 42 | "mimetype": "text/x-python", 43 | "name": "python", 44 | "nbconvert_exporter": "python", 45 | "pygments_lexer": "ipython3", 46 | "version": "3.11.11" 47 | } 48 | }, 49 | "nbformat": 4, 50 | "nbformat_minor": 5 51 | } 52 | -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/agents/random_forest_agent.py: -------------------------------------------------------------------------------- 1 | # imports 2 | 3 | import os 4 | import re 5 | from typing import List 6 | from sentence_transformers import SentenceTransformer 7 | import joblib 8 | from agents.agent import Agent 9 | 10 | 11 | 12 | class RandomForestAgent(Agent): 13 | 14 | name = "Random Forest Agent" 15 | color = Agent.MAGENTA 16 | 17 | def __init__(self): 18 | """ 19 | Initialize this object by loading in the saved model weights 20 | and the SentenceTransformer vector encoding model 21 | """ 22 | self.log("Random Forest Agent is initializing") 23 | self.vectorizer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') 24 | self.model = joblib.load('random_forest_model.pkl') 25 | self.log("Random Forest Agent is ready") 26 | 27 | def price(self, description: str) -> float: 28 | """ 29 | Use a Random Forest model to estimate the price of the described item 30 | :param description: the product to be estimated 31 | :return: the price as a float 32 | """ 33 | self.log("Random Forest Agent is starting a prediction") 34 | vector = self.vectorizer.encode([description]) 35 | result = max(0, self.model.predict(vector)[0]) 36 | self.log(f"Random Forest Agent completed - predicting ${result:.2f}") 37 | return result -------------------------------------------------------------------------------- /week4/community-contributions/ai_stock_trading/tools/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | AI Stock Trading Tools 3 | 4 | This package contains all the core tools for the AI Stock Trading platform: 5 | - fetching: Stock data fetching and market data 6 | - analysis: Technical analysis and stock metrics 7 | - trading_decisions: AI-powered trading recommendations 8 | - sharia_compliance: Islamic finance compliance checking 9 | - charting: Interactive charts and visualizations 10 | """ 11 | 12 | __version__ = "1.0.0" 13 | __author__ = "AI Stock Trading Platform" 14 | 15 | # Import main classes and functions for easy access 16 | from .fetching import StockDataFetcher, stock_fetcher, fetch_stock_data, get_available_stocks 17 | from .analysis import StockAnalyzer, stock_analyzer, analyze_stock 18 | from .trading_decisions import TradingDecisionEngine, trading_engine, get_trading_recommendation 19 | from .sharia_compliance import ShariaComplianceChecker, sharia_checker, check_sharia_compliance 20 | from .charting import StockChartGenerator, chart_generator, create_price_chart 21 | 22 | __all__ = [ 23 | 'StockDataFetcher', 'stock_fetcher', 'fetch_stock_data', 'get_available_stocks', 24 | 'StockAnalyzer', 'stock_analyzer', 'analyze_stock', 25 | 'TradingDecisionEngine', 'trading_engine', 'get_trading_recommendation', 26 | 'ShariaComplianceChecker', 'sharia_checker', 'check_sharia_compliance', 27 | 'StockChartGenerator', 'chart_generator', 'create_price_chart' 28 | ] 29 | -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/agents/gradient_boosting_agent.py: -------------------------------------------------------------------------------- 1 | # imports 2 | 3 | import os 4 | import re 5 | from typing import List 6 | from sentence_transformers import SentenceTransformer 7 | import joblib 8 | from agents.agent import Agent 9 | 10 | 11 | 12 | class GradientBoostingAgent(Agent): 13 | 14 | name = "Gradient Boosting Agent" 15 | color = Agent.MAGENTA 16 | 17 | def __init__(self): 18 | """ 19 | Initialize this object by loading in the saved model weights 20 | and the SentenceTransformer vector encoding model 21 | """ 22 | self.log("Gradient Boosting Agent is initializing") 23 | self.vectorizer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') 24 | self.model = joblib.load('gradient_boosting_model.pkl') 25 | self.log("Gradient Boosting Agent is ready") 26 | 27 | def price(self, description: str) -> float: 28 | """ 29 | Use a Random Forest model to estimate the price of the described item 30 | :param description: the product to be estimated 31 | :return: the price as a float 32 | """ 33 | self.log("Gradient Boosting Agent is starting a prediction") 34 | vector = self.vectorizer.encode([description]) 35 | result = max(0, self.model.predict(vector)[0]) 36 | self.log(f"Gradient Boosting Agent completed - predicting ${result:.2f}") 37 | return result -------------------------------------------------------------------------------- /week3/day2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "1f2ed49d-7873-4a03-bdc8-bda1c23cb979", 6 | "metadata": {}, 7 | "source": [ 8 | "# HuggingFace pipelines\n", 9 | "\n", 10 | "For this session we head to Google Colab and use this Notebook to explore the HuggingFace High Level API, pipelines.\n", 11 | "\n", 12 | "https://colab.research.google.com/drive/1aMaEw8A56xs0bRM4lu8z7ou18jqyybGm?usp=sharing\n", 13 | "\n", 14 | "You can use a low cost (or free) T4 GPU runtime for this notebook - and the results look great!\n", 15 | "\n", 16 | "There are instructions in the notebook for setting up your HuggingFace Token and including it as a secret in the notebook." 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": null, 22 | "id": "d5d84b78-0a02-4a35-8f10-e3f7451d352f", 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [] 26 | } 27 | ], 28 | "metadata": { 29 | "kernelspec": { 30 | "display_name": "Python 3 (ipykernel)", 31 | "language": "python", 32 | "name": "python3" 33 | }, 34 | "language_info": { 35 | "codemirror_mode": { 36 | "name": "ipython", 37 | "version": 3 38 | }, 39 | "file_extension": ".py", 40 | "mimetype": "text/x-python", 41 | "name": "python", 42 | "nbconvert_exporter": "python", 43 | "pygments_lexer": "ipython3", 44 | "version": "3.11.11" 45 | } 46 | }, 47 | "nbformat": 4, 48 | "nbformat_minor": 5 49 | } 50 | -------------------------------------------------------------------------------- /week3/day1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "61f56afc-bc15-46a4-8eb1-d940c332cf52", 6 | "metadata": {}, 7 | "source": [ 8 | "# Introducing Colab\n", 9 | "\n", 10 | "Learn about Google Colab and set up a Google account (if you don't already have one) [here](https://colab.research.google.com/)\n", 11 | "\n", 12 | "You should be able to use the free tier or minimal spend to complete all the projects in the class. I personally signed up for Colab Pro+ and I'm loving it - but it's not required.\n", 13 | "\n", 14 | "To see some of what Colab can do, please follow the link below!\n", 15 | "\n", 16 | "https://colab.research.google.com/drive/1DjcrYDZldAXKJ08x1uYIVCtItoLPk1Wr?usp=sharing" 17 | ] 18 | }, 19 | { 20 | "cell_type": "code", 21 | "execution_count": null, 22 | "id": "e9289ba7-200c-43a9-b67a-c5ce826c9537", 23 | "metadata": {}, 24 | "outputs": [], 25 | "source": [] 26 | } 27 | ], 28 | "metadata": { 29 | "kernelspec": { 30 | "display_name": "Python 3 (ipykernel)", 31 | "language": "python", 32 | "name": "python3" 33 | }, 34 | "language_info": { 35 | "codemirror_mode": { 36 | "name": "ipython", 37 | "version": 3 38 | }, 39 | "file_extension": ".py", 40 | "mimetype": "text/x-python", 41 | "name": "python", 42 | "nbconvert_exporter": "python", 43 | "pygments_lexer": "ipython3", 44 | "version": "3.11.11" 45 | } 46 | }, 47 | "nbformat": 4, 48 | "nbformat_minor": 5 49 | } 50 | -------------------------------------------------------------------------------- /week2/community-contributions/medical_prescription_to_google_calender/src/calendar_auth.py: -------------------------------------------------------------------------------- 1 | import os 2 | from google.oauth2.credentials import Credentials 3 | from google_auth_oauthlib.flow import InstalledAppFlow 4 | from google.auth.transport.requests import Request 5 | from googleapiclient.discovery import build # Add this import 6 | 7 | SCOPES = ["https://www.googleapis.com/auth/calendar.events"] 8 | 9 | def authenticate_google_calender(): 10 | creds = None 11 | token_path = r"C:\Users\Legion\Desktop\projects\medical_prescription_to_google_calender\token.json" 12 | 13 | if os.path.exists(token_path): 14 | creds = Credentials.from_authorized_user_file(token_path, SCOPES) 15 | 16 | if not creds or not creds.valid: 17 | if creds and creds.expired and creds.refresh_token: 18 | creds.refresh(Request()) 19 | else: 20 | flow = InstalledAppFlow.from_client_secrets_file(r"C:\Users\Legion\Desktop\projects\medical_prescription_to_google_calender\credentials.json", SCOPES) 21 | creds = flow.run_local_server(port=0) 22 | 23 | with open(token_path, "w") as token_file: 24 | token_file.write(creds.to_json()) 25 | 26 | # Build and return the service instead of just credentials 27 | try: 28 | service = build('calendar', 'v3', credentials=creds) 29 | return service 30 | except Exception as e: 31 | print(f"Error building service: {e}") 32 | return None 33 | 34 | if __name__ == "__main__": 35 | authenticate_google_calender() -------------------------------------------------------------------------------- /week8/llama.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from modal import App, Volume, Image 3 | 4 | # Setup 5 | 6 | app = modal.App("llama") 7 | image = Image.debian_slim().pip_install("torch", "transformers", "bitsandbytes", "accelerate") 8 | secrets = [modal.Secret.from_name("hf-secret")] 9 | GPU = "T4" 10 | MODEL_NAME = "meta-llama/Meta-Llama-3.1-8B" # "google/gemma-2-2b" 11 | 12 | 13 | 14 | @app.function(image=image, secrets=secrets, gpu=GPU, timeout=1800) 15 | def generate(prompt: str) -> str: 16 | import os 17 | import torch 18 | from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, set_seed 19 | 20 | # Quant Config 21 | quant_config = BitsAndBytesConfig( 22 | load_in_4bit=True, 23 | bnb_4bit_use_double_quant=True, 24 | bnb_4bit_compute_dtype=torch.bfloat16, 25 | bnb_4bit_quant_type="nf4" 26 | ) 27 | 28 | # Load model and tokenizer 29 | 30 | tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) 31 | tokenizer.pad_token = tokenizer.eos_token 32 | tokenizer.padding_side = "right" 33 | 34 | model = AutoModelForCausalLM.from_pretrained( 35 | MODEL_NAME, 36 | quantization_config=quant_config, 37 | device_map="auto" 38 | ) 39 | 40 | set_seed(42) 41 | inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda") 42 | attention_mask = torch.ones(inputs.shape, device="cuda") 43 | outputs = model.generate(inputs, attention_mask=attention_mask, max_new_tokens=5, num_return_sequences=1) 44 | return tokenizer.decode(outputs[0]) 45 | -------------------------------------------------------------------------------- /week1/community-contributions/Chat_Summary_Data/Chat_Examples/Chat1.txt: -------------------------------------------------------------------------------- 1 | Client: Hello I would like to order a pizza 2 | Restaurant: Sure. What pizza would you like to order from our menu? 3 | Client: Chicken Ranch 4 | Restaurant: I am so sorry, but chicken ranch is currently unavailable on our menu 5 | Client: AHHHHH. Do you have chicken BBQ? 6 | Restaurant: Yes! Do you want it small, medium, or large? 7 | Client: Medium 8 | Restaurant: Ok. This will be 180 LE 9 | Client: Thanks 10 | Restaurant: Anytime. 11 | Client: AHHHH I forgot. I want to add a new chicken BBQ pizza 12 | Restaurant: No problem. Do you also want it medium? 13 | Client: Yes 14 | Restaurant: Okay this will be 380 LE 15 | Client: Okay Thanks 16 | Client: Wait a minute. Isn't 180 * 2 = 360? 17 | Restaurant: It seems that there might be a misunderstanding. We add an extra 20 LE for every extra pizza ordered. 18 | Client: NOBODY TOLD ME THAT.. AND WHY ON EARTH WOULD YOU DO SOMETHING LIKE THAT? 19 | Restaurant: We are sorry but this is our policy. 20 | Client: Okay then I don't want your pizza. 21 | Restaurant: We are so sorry to hear that. We can make a 10% discount on the total price so it would be 342 LE 22 | Client: Fine 23 | Restaurant: Thank you for ordering 24 | Restaurant: Pizza is delivered. How is your experience? 25 | Client: Your pizza doesn't taste good 26 | Restaurant: We are so sorry to hear that. Do you have any suggestions you would like to make? 27 | Client: Make good pizza 28 | Restaurant: Thanks for your review. We will make sure to improve our pizza in the future. Your opinion really matters. 29 | -------------------------------------------------------------------------------- /week1/community-contributions/Day-1-Text-to-sql/ollama-TTSQL.py: -------------------------------------------------------------------------------- 1 | import ollama 2 | from db import get_connection 3 | import mysql.connector 4 | 5 | def text_to_sql(user_query): 6 | prompt = f""" 7 | Convert the following natural language query into an SQL statement for MySQL: 8 | 9 | Query: "{user_query}" 10 | 11 | Ensure the query is syntactically correct and does not contain harmful operations. 12 | Only return the SQL query without any explanation. 13 | """ 14 | 15 | # Update the model name to 'llama3.2:latest' 16 | response = ollama.chat(model="llama3.2:latest", messages=[{"role": "user", "content": prompt}]) 17 | sql_query = response['message']['content'].strip() 18 | return sql_query 19 | 20 | 21 | # Uncomment this section if you wish to connect with mysql and fill out your credentials in db.py 22 | '''def execute_sql_query(user_query): 23 | sql_query = text_to_sql(user_query) 24 | 25 | try: 26 | conn = get_connection() 27 | cursor = conn.cursor() 28 | cursor.execute(sql_query) 29 | result = cursor.fetchall() 30 | except mysql.connector.Error as e: 31 | return {"error": f"MySQL Error: {e}"} 32 | except Exception as e: 33 | return {"error": str(e)} 34 | finally: 35 | conn.close() # Ensure connection is closed even if an error occurs 36 | 37 | return result''' 38 | 39 | # Example usage 40 | if __name__ == "__main__": 41 | user_input = "Show me all users whose first name starts with the letter j in the first_name column." 42 | print(text_to_sql(user_input)) 43 | -------------------------------------------------------------------------------- /week2/community-contributions/muawiya/requirements.txt: -------------------------------------------------------------------------------- 1 | aiofiles==24.1.0 2 | annotated-types==0.7.0 3 | anyio==4.9.0 4 | asttokens==3.0.0 5 | certifi==2025.1.31 6 | charset-normalizer==3.4.1 7 | click==8.1.8 8 | colorama==0.4.6 9 | decorator==5.2.1 10 | distro==1.9.0 11 | executing==2.2.0 12 | fastapi==0.115.12 13 | ffmpy==0.5.0 14 | filelock==3.18.0 15 | fsspec==2025.3.2 16 | gradio==5.25.2 17 | gradio_client==1.8.0 18 | groovy==0.1.2 19 | h11==0.14.0 20 | httpcore==1.0.8 21 | httpx==0.28.1 22 | huggingface-hub==0.30.2 23 | idna==3.10 24 | ipython==8.35.0 25 | ipython_pygments_lexers==1.1.1 26 | jedi==0.19.2 27 | Jinja2==3.1.6 28 | jiter==0.9.0 29 | markdown-it-py==3.0.0 30 | MarkupSafe==3.0.2 31 | matplotlib-inline==0.1.7 32 | mdurl==0.1.2 33 | numpy==2.2.4 34 | openai==1.74.0 35 | orjson==3.10.16 36 | packaging==24.2 37 | pandas==2.2.3 38 | parso==0.8.4 39 | pillow==11.2.1 40 | prompt_toolkit==3.0.51 41 | pure_eval==0.2.3 42 | pydantic==2.11.3 43 | pydantic_core==2.33.1 44 | pydub==0.25.1 45 | pygame==2.6.1 46 | Pygments==2.19.1 47 | python-dateutil==2.9.0.post0 48 | python-dotenv==1.1.0 49 | python-multipart==0.0.20 50 | pytz==2025.2 51 | PyYAML==6.0.2 52 | requests==2.32.3 53 | rich==14.0.0 54 | ruff==0.11.5 55 | safehttpx==0.1.6 56 | semantic-version==2.10.0 57 | shellingham==1.5.4 58 | six==1.17.0 59 | sniffio==1.3.1 60 | stack-data==0.6.3 61 | starlette==0.46.2 62 | tomlkit==0.13.2 63 | tqdm==4.67.1 64 | traitlets==5.14.3 65 | typer==0.15.2 66 | typing-inspection==0.4.0 67 | typing_extensions==4.13.2 68 | tzdata==2025.2 69 | urllib3==2.4.0 70 | uvicorn==0.34.1 71 | wcwidth==0.2.13 72 | websockets==15.0.1 73 | -------------------------------------------------------------------------------- /week8/community_contributions/pricer_test/pricer/llama.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from modal import App, Volume, Image 3 | 4 | # Setup 5 | 6 | app = modal.App("llama") 7 | image = Image.debian_slim().pip_install("torch", "transformers", "bitsandbytes", "accelerate") 8 | secrets = [modal.Secret.from_name("hf-secret")] 9 | GPU = "T4" 10 | MODEL_NAME = "meta-llama/Meta-Llama-3.1-8B" # "google/gemma-2-2b" 11 | 12 | 13 | 14 | @app.function(image=image, secrets=secrets, gpu=GPU, timeout=1800) 15 | def generate(prompt: str) -> str: 16 | import os 17 | import torch 18 | from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, set_seed 19 | 20 | # Quant Config 21 | quant_config = BitsAndBytesConfig( 22 | load_in_4bit=True, 23 | bnb_4bit_use_double_quant=True, 24 | bnb_4bit_compute_dtype=torch.bfloat16, 25 | bnb_4bit_quant_type="nf4" 26 | ) 27 | 28 | # Load model and tokenizer 29 | 30 | tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME) 31 | tokenizer.pad_token = tokenizer.eos_token 32 | tokenizer.padding_side = "right" 33 | 34 | model = AutoModelForCausalLM.from_pretrained( 35 | MODEL_NAME, 36 | quantization_config=quant_config, 37 | device_map="auto" 38 | ) 39 | 40 | set_seed(42) 41 | inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda") 42 | attention_mask = torch.ones(inputs.shape, device="cuda") 43 | outputs = model.generate(inputs, attention_mask=attention_mask, max_new_tokens=5, num_return_sequences=1) 44 | return tokenizer.decode(outputs[0]) 45 | -------------------------------------------------------------------------------- /week8/community_contributions/ensemble-updated/xg_boost_agent.py: -------------------------------------------------------------------------------- 1 | # imports 2 | 3 | import os 4 | import re 5 | from typing import List 6 | from sentence_transformers import SentenceTransformer 7 | import joblib 8 | from agents.agent import Agent 9 | import xgboost as xgb 10 | 11 | 12 | 13 | 14 | class XGBoostAgent(Agent): 15 | 16 | name = "XG Boost Agent" 17 | color = Agent.BRIGHT_MAGENTA 18 | 19 | def __init__(self): 20 | """ 21 | Initialize this object by loading in the saved model weights 22 | and the SentenceTransformer vector encoding model 23 | """ 24 | self.log("XG Boost Agent is initializing") 25 | self.vectorizer = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') 26 | self.model = joblib.load('xg_boost_model.pkl') 27 | self.log("XG Boost Agent is ready") 28 | 29 | def price(self, description: str) -> float: 30 | """ 31 | Use an XG Boost model to estimate the price of the described item 32 | :param description: the product to be estimated 33 | :return: the price as a float 34 | """ 35 | self.log("XG Boost Agent is starting a prediction") 36 | vector = self.vectorizer.encode([description]) 37 | vector = vector.reshape(1, -1) 38 | # Convert the vector to DMatrix 39 | dmatrix = xgb.DMatrix(vector) 40 | # Predict the price using the model 41 | result = max(0, self.model.predict(dmatrix)[0]) 42 | self.log(f"XG Boost Agent completed - predicting ${result:.2f}") 43 | return result 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /week5/community-contributions/rag_chat_example/knowledge_base/mtsample_dictations/test_patient_3_m/progress_note.txt: -------------------------------------------------------------------------------- 1 | SUBJECTIVE: 2 | 3 | Mr. Duck is a 29-year-old white male who is a patient of Dr. XYZ and he comes in today 4 | complaining that he was stung by a Yellow Jacket Wasp yesterday and now has a lot of 5 | swelling in his right hand and right arm. He says that he has been stung by wasps before and had similar 6 | reactions. He just said that he wanted to catch it early before he has too bad of a severe reaction like he has had in the past. 7 | He has had a lot of swelling, but no anaphylaxis-type reactions in the past; no shortness of breath or difficultly with his 8 | throat feeling like it is going to close up or anything like that in the past; no racing heart beat or anxiety feeling, 9 | just a lot of localized swelling where the sting occurs. 10 | 11 | OBJECTIVE: 12 | 13 | Vitals: His temperature is 98.4. Respiratory rate is 18. Weight is 250 pounds. 14 | Extremities: Examination of his right hand and forearm reveals that he has an apparent sting just around his 15 | wrist region on his right hand on the medial side as well as significant swelling in his hand and his right forearm; 16 | extending up to the elbow. He says that it is really not painful or anything like that. It is really not all that 17 | red and no signs of infection at this time. 18 | 19 | ASSESSMENT:, Wasp sting to the right wrist area. 20 | 21 | PLAN: 22 | 23 | 1. Solu-Medrol 125 mg IM X 1. 24 | 2. Over-the-counter Benadryl, ice and elevation of that extremity. 25 | 3. Follow up with Dr. XYZ if any further evaluation is needed. -------------------------------------------------------------------------------- /week8/memory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "deal": { 4 | "product_description": "The Samsung Galaxy Watch Ultra is a premium 47mm LTE Titanium smartwatch designed for both style and functionality. It features a circular display made with durable materials suitable for outdoor activities, providing GPS tracking, health monitoring, and custom apps for various needs. The robust design integrates a range of smart features including notifications, music control, and heart rate tracking, making it an ideal companion for fitness enthusiasts and tech-savvy users alike.", 5 | "price": 350.0, 6 | "url": "https://www.dealnews.com/Samsung-Galaxy-Watch-Ultra-47-mm-LTE-Titanium-Smartwatch-up-to-350-off-w-Trade-in-free-shipping/21663266.html?iref=rss-c142" 7 | }, 8 | "estimate": 773.8138460593241, 9 | "discount": 423.8138460593241 10 | }, 11 | { 12 | "deal": { 13 | "product_description": "The Refurbished Unlocked Apple iPhone 14 Pro Max offers an impressive 256GB storage and a huge display, perfect for both media consumption and productivity. Enjoy advanced camera technology for stunning photos. This model is designed to provide a seamless user experience with 5G capabilities for faster downloads and streaming. Refurbished to high standards, it comes in various colors and can support all the latest apps from the App Store, accommodating any Apple enthusiast's needs.", 14 | "price": 705.0, 15 | "url": "https://www.dealnews.com/products/Apple/Unlocked-Apple-iPhone-14-Pro-Max-256-GB-Smartphone/462808.html?iref=rss-c142" 16 | }, 17 | "estimate": 930.8824204895075, 18 | "discount": 225.88242048950747 19 | } 20 | ] -------------------------------------------------------------------------------- /diagnostics.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "73287ed4-81e3-496a-9e47-f0e8c3770ce9", 6 | "metadata": {}, 7 | "source": [ 8 | "# Gathering Essential Diagnostic information\n", 9 | "\n", 10 | "## Please run this next cell to gather some important data\n", 11 | "\n", 12 | "Please run the next cell; it should take a minute or so to run (mostly the network test).\n", 13 | "Rhen email me the output of the last cell to ed@edwarddonner.com. \n", 14 | "Alternatively: this will create a file called report.txt - just attach the file to your email." 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": null, 20 | "id": "ed8056e8-efa2-4b6f-a4bb-e7ceb733c517", 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "# Run my diagnostics report to collect key information for debugging\n", 25 | "# Please email me the results. Either copy & paste the output, or attach the file report.txt\n", 26 | "\n", 27 | "!pip install -q requests speedtest-cli psutil setuptools\n", 28 | "from diagnostics import Diagnostics\n", 29 | "Diagnostics().run()" 30 | ] 31 | } 32 | ], 33 | "metadata": { 34 | "kernelspec": { 35 | "display_name": "Python 3 (ipykernel)", 36 | "language": "python", 37 | "name": "python3" 38 | }, 39 | "language_info": { 40 | "codemirror_mode": { 41 | "name": "ipython", 42 | "version": 3 43 | }, 44 | "file_extension": ".py", 45 | "mimetype": "text/x-python", 46 | "name": "python", 47 | "nbconvert_exporter": "python", 48 | "pygments_lexer": "ipython3", 49 | "version": "3.11.10" 50 | } 51 | }, 52 | "nbformat": 4, 53 | "nbformat_minor": 5 54 | } 55 | -------------------------------------------------------------------------------- /week1/community-contributions/day1_article_world_cup_final.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "2c4ce468", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "# imports\n", 11 | "from openai import OpenAI\n", 12 | "\n", 13 | "openai = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')\n", 14 | "\n", 15 | "# Step 1: Create your prompts\n", 16 | "\n", 17 | "system_prompt = \"You are a sports journalist.\"\n", 18 | "user_prompt = \"\"\"\n", 19 | " Write a sports article in less than 500 words describing the FIFA World Cup Final 2022.\n", 20 | "\"\"\"\n", 21 | "\n", 22 | "# Step 2: Make the messages list\n", 23 | "\n", 24 | "messages = [\n", 25 | " {\"role\": \"system\", \"content\": system_prompt},\n", 26 | " {\"role\": \"user\", \"content\": user_prompt}\n", 27 | "]\n", 28 | "\n", 29 | "# Step 3: Call OpenAI\n", 30 | "\n", 31 | "response = openai.chat.completions.create(model=\"llama3.2\", messages=messages)\n", 32 | "\n", 33 | "# Step 4: print the result\n", 34 | "\n", 35 | "print(response.choices[0].message.content)" 36 | ] 37 | } 38 | ], 39 | "metadata": { 40 | "kernelspec": { 41 | "display_name": "llms", 42 | "language": "python", 43 | "name": "python3" 44 | }, 45 | "language_info": { 46 | "codemirror_mode": { 47 | "name": "ipython", 48 | "version": 3 49 | }, 50 | "file_extension": ".py", 51 | "mimetype": "text/x-python", 52 | "name": "python", 53 | "nbconvert_exporter": "python", 54 | "pygments_lexer": "ipython3", 55 | "version": "3.12.10" 56 | } 57 | }, 58 | "nbformat": 4, 59 | "nbformat_minor": 5 60 | } 61 | -------------------------------------------------------------------------------- /week2/week2 EXERCISE.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "d006b2ea-9dfe-49c7-88a9-a5a0775185fd", 6 | "metadata": {}, 7 | "source": [ 8 | "# Additional End of week Exercise - week 2\n", 9 | "\n", 10 | "Now use everything you've learned from Week 2 to build a full prototype for the technical question/answerer you built in Week 1 Exercise.\n", 11 | "\n", 12 | "This should include a Gradio UI, streaming, use of the system prompt to add expertise, and the ability to switch between models. Bonus points if you can demonstrate use of a tool!\n", 13 | "\n", 14 | "If you feel bold, see if you can add audio input so you can talk to it, and have it respond with audio. ChatGPT or Claude can help you, or email me if you have questions.\n", 15 | "\n", 16 | "I will publish a full solution here soon - unless someone beats me to it...\n", 17 | "\n", 18 | "There are so many commercial applications for this, from a language tutor, to a company onboarding solution, to a companion AI to a course (like this one!) I can't wait to see your results." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "id": "a07e7793-b8f5-44f4-aded-5562f633271a", 25 | "metadata": {}, 26 | "outputs": [], 27 | "source": [] 28 | } 29 | ], 30 | "metadata": { 31 | "kernelspec": { 32 | "display_name": "Python 3 (ipykernel)", 33 | "language": "python", 34 | "name": "python3" 35 | }, 36 | "language_info": { 37 | "codemirror_mode": { 38 | "name": "ipython", 39 | "version": 3 40 | }, 41 | "file_extension": ".py", 42 | "mimetype": "text/x-python", 43 | "name": "python", 44 | "nbconvert_exporter": "python", 45 | "pygments_lexer": "ipython3", 46 | "version": "3.11.11" 47 | } 48 | }, 49 | "nbformat": 4, 50 | "nbformat_minor": 5 51 | } 52 | -------------------------------------------------------------------------------- /week1/community-contributions/week1-coderesearcher.py: -------------------------------------------------------------------------------- 1 | import ollama, os 2 | from openai import OpenAI 3 | from dotenv import load_dotenv 4 | from IPython.display import Markdown, display 5 | 6 | load_dotenv() 7 | 8 | open_key = os.getenv("OPENAI_API_KEY") 9 | 10 | OPEN_MODEL = "gpt-4-turbo" 11 | ollama_model = "llama3.2" 12 | openai = OpenAI() 13 | 14 | system_prompt = "You are an assistant that focuses on the reason for each code, analysing and interpreting what the code does and how it could be improved, \ 15 | Give your answer in markdown down with two different topics namely: Explanation and Code Improvement. However if you think there is no possible improvement \ 16 | to said code, simply state 'no possible improvement '" 17 | 18 | def user_prompt(): 19 | custom_message = input("Write your prompt message: ") 20 | return custom_message 21 | 22 | def explain(): 23 | response = openai.chat.completions.create(model=OPEN_MODEL, 24 | messages = [ 25 | {"role":"system", "content":system_prompt}, 26 | {"role": "user", "content":user_prompt()} 27 | ]) 28 | result = response.choices[0].message.content 29 | display(Markdown(result)) 30 | 31 | # explain() run this to get the openai output with peronalized input 32 | 33 | #With ollama 34 | 35 | ollama_api = "https://localhost:11434/api/chat" 36 | 37 | def explainer_with_ollama(): 38 | response = ollama.chat(model=ollama_model, messages=[ 39 | {"role":"system", "content":system_prompt}, 40 | {"role":"user", "content":user_prompt()} 41 | ]) 42 | result = response["message"]["content"] 43 | display(Markdown(result)) 44 | 45 | #explainer_with_ollama() run for ollama output with same personalized input 46 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/massif_central.md: -------------------------------------------------------------------------------- 1 | # Overview of Massif Central 2 | 3 | ## General Information 4 | - **Location**: South-central France 5 | - **Area**: Approximately 85,000 km² 6 | - **Highest Peak**: Puy de Sancy (1,885 meters) 7 | - **Geological Composition**: Primarily volcanic and sedimentary rocks 8 | 9 | ## Geography 10 | - **Regions Covered**: Spans across several French departments including Cantal, Puy-de-Dôme, Haute-Loire, and Lozère. 11 | - **Landscape**: Characterized by plateaus, volcanic cones, deep valleys, and rivers. 12 | 13 | ## Climate 14 | - **Type**: Predominantly oceanic climate with a continental influence. 15 | - **Precipitation**: Higher rainfall in the western regions, often resulting in lush landscapes. 16 | 17 | ## Flora and Fauna 18 | - **Biodiversity**: Home to various ecosystems, including grasslands, forests, and wetlands. 19 | - **Protected Areas**: Includes several national parks and nature reserves, such as the Parc Naturel Régional des Volcans d'Auvergne. 20 | 21 | ## Cultural Significance 22 | - **History**: Affected by various historical events and populations, including the Gauls and the Roman Empire. 23 | - **Heritage**: Rich cultural heritage with medieval towns, castles, and traditional practices. 24 | 25 | ## Economic Importance 26 | - **Agriculture**: Known for agriculture, particularly cheese production (e.g., Saint-Nectaire, Cantal). 27 | - **Tourism**: Popular destination for outdoor activities such as hiking, skiing, and exploring natural parks. 28 | 29 | ## Notable Features 30 | - **Volcanic Activity**: The region contains many extinct volcanoes, with some still showing geothermal activity. 31 | - **Natural Attractions**: Features stunning sites like the Gorges de la Loire and the Chaîne des Puys, a UNESCO World Heritage site. 32 | 33 | ## Accessibility 34 | - **Transport**: Well-connected by road and rail, with several towns providing access points for visitors. -------------------------------------------------------------------------------- /community-contributions/playwright-bojan/README.md: -------------------------------------------------------------------------------- 1 | # 🧠 Community Contribution: Async Playwright-based OpenAI Scraper 2 | 3 | This contribution presents a fully asynchronous, headless-browser-based scraper for [https://openai.com](https://openai.com) using **Playwright** — an alternative to Selenium. 4 | 5 | Developed by: [lakovicb](https://github.com/lakovicb) 6 | IDE used: WingIDE Pro (Jupyter compatibility via `nest_asyncio`) 7 | 8 | --- 9 | 10 | ## 📦 Features 11 | 12 | - 🧭 Simulates human-like interactions (mouse movement, scrolling) 13 | - 🧠 GPT-based analysis using OpenAI's API 14 | - 🧪 Works inside **JupyterLab** using `nest_asyncio` 15 | - 📊 Prometheus metrics for scraping observability 16 | - ⚡ Smart content caching via `diskcache` 17 | 18 | --- 19 | 20 | ## 🚀 How to Run 21 | 22 | ### 1. Install dependencies 23 | 24 | ```bash 25 | pip install -r requirements.txt 26 | ``` 27 | 28 | > Ensure [Playwright is installed & browsers are downloaded](https://playwright.dev/python/docs/intro) 29 | 30 | ```bash 31 | playwright install 32 | ``` 33 | 34 | ### 2. Set environment variables in `.env` 35 | 36 | ```env 37 | OPENAI_API_KEY=your_openai_key 38 | BROWSER_PATH=/usr/bin/chromium-browser 39 | ``` 40 | 41 | You can also define optional proxy/login params if needed. 42 | 43 | --- 44 | 45 | ## 📘 Notebooks Included 46 | 47 | | Notebook | Description | 48 | |----------|-------------| 49 | | `Playwright_Solution_JupyterAsync.ipynb` | Executes async scraper directly inside Jupyter | 50 | | `Playwright_Solution_Showcase_Formatted.ipynb` | Nicely formatted output for human reading | 51 | 52 | --- 53 | 54 | ## 🔁 Output Example 55 | 56 | - GPT-generated summary 57 | - Timeline of updates 58 | - Entities and projects mentioned 59 | - Structured topics & themes 60 | 61 | ✅ *Can be extended with PDF export, LangChain pipeline, or vector store ingestion.* 62 | 63 | --- 64 | 65 | ## 🙏 Thanks 66 | 67 | Huge thanks to Ed Donner for the amazing course and challenge inspiration! 68 | -------------------------------------------------------------------------------- /week5/community-contributions/rag_chat_example/run_rag_chat.py: -------------------------------------------------------------------------------- 1 | import gradio as gr 2 | from langchain_chroma import Chroma 3 | from pathlib import Path 4 | from utils import create_vector_db, Rag, get_chunks, get_conversation_chain, get_local_vector_db 5 | 6 | 7 | def chat(question, history) -> str: 8 | 9 | """ 10 | Get the chat data need for the gradio app 11 | 12 | :param question: 13 | The question being asked in the chat app. 14 | :type question: str 15 | :param history: 16 | A list of the conversation questions and answers. 17 | :type history: list 18 | :return: 19 | The answer from the current question. 20 | """ 21 | 22 | result = conversation_chain.invoke({"question": question}) 23 | answer = result['answer'] 24 | 25 | # include source documents if they exist 26 | # grab the first one as that should be related to the answer 27 | source_doc = "" 28 | if result.get('source_documents'): 29 | source_doc = result['source_documents'][0] 30 | 31 | response = f"{answer}\n\n**Source:**\n{source_doc.metadata.get('source', 'Source')}" \ 32 | if source_doc \ 33 | else answer 34 | return response 35 | 36 | 37 | def main(): 38 | 39 | gr.ChatInterface(chat, type="messages").launch(inbrowser=True) 40 | 41 | 42 | if __name__ == '__main__': 43 | 44 | create_new_db = False if Path('vector_db').exists() else True 45 | 46 | if create_new_db: 47 | folders = Path('knowledge_base').glob('*') 48 | chunks = get_chunks(folders=folders) 49 | vector_store = create_vector_db(chunks=chunks, db_name=Rag.DB_NAME.value, embeddings=Rag.EMBED_MODEL.value) 50 | else: 51 | client = get_local_vector_db(path='../rag_chat_example/vector_db') 52 | vector_store = Chroma(client=client, embedding_function=Rag.EMBED_MODEL.value) 53 | 54 | conversation_chain = get_conversation_chain(vectorstore=vector_store) 55 | 56 | main() 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/morvan.md: -------------------------------------------------------------------------------- 1 | # Overview of the Morvan Mountain Range 2 | 3 | ## Location 4 | - **Country**: France 5 | - **Region**: Burgundy (Bourgogne) 6 | - **Department**: Nièvre, Saône-et-Loire, Côte-d'Or 7 | 8 | ## Geography 9 | - **Coordinates**: Approximately 47°10′N 3°55′E 10 | - **Highest Peak**: Mont Beuvray 11 | - **Elevation**: 821 meters (2,700 feet) 12 | - **Area**: Approximately 3,500 square kilometers 13 | - **Major Rivers**: Cure, Yonne, and Loing flow through the region. 14 | 15 | ## Geology 16 | - Composed primarily of granitic and metamorphic rocks. 17 | - The landscape features rolling hills, valleys, and plateaus. 18 | - Known for its rich biodiversity and varied ecosystems. 19 | 20 | ## Climate 21 | - **Type**: Temperate continental climate. 22 | - **Weather**: Mild summers and cold winters with occasional snowfall. 23 | 24 | ## History 25 | - The Morvan area has a rich history dating back to prehistoric times. 26 | - Notable archaeological sites include the remnants of the Gallic tribe of the Aedui in Mont Beuvray. 27 | - The region was significant during the Roman conquest of Gaul. 28 | 29 | ## Culture and Economy 30 | - The Morvan is known for its traditional rural lifestyle and local crafts. 31 | - Main industries include agriculture, forestry, and tourism. 32 | - Famous for Morvan cheese and wines from the surrounding Burgundy region. 33 | 34 | ## Tourism 35 | - Offers a variety of outdoor activities such as hiking, cycling, and fishing. 36 | - Home to the Morvan Regional Natural Park, established in 1970, which promotes conservation and sustainable tourism. 37 | - Attractions include ancient ruins, beautiful landscapes, and charming villages. 38 | 39 | ## Wildlife 40 | - Habitat for various species, including deer, wild boars, and numerous bird species. 41 | - Rich flora with many endemic plant species. 42 | 43 | ## Conservation 44 | - The region emphasizes environmental protection and sustainability in its natural park initiatives. -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/alsacien.md: -------------------------------------------------------------------------------- 1 | # Overview of Alsacien Language 2 | 3 | ## Definition 4 | Alsacien, also known as Alsatian or Alsatian German, is a variety of the Alemannic branch of the Germanic languages spoken predominantly in Alsace, France. 5 | 6 | ## Geographic Distribution 7 | - Primarily spoken in Alsace, a region in northeastern France. 8 | - Communities of Alsacien speakers can also be found in neighboring regions of Germany and Switzerland. 9 | 10 | ## Linguistic Classification 11 | - **Language Family**: Indo-European 12 | - **Subfamily**: Germanic 13 | - **Group**: West Germanic 14 | - **Branch**: High German 15 | 16 | ## Speakers 17 | - Estimates of native speakers range from 500,000 to 1 million, though use has declined due to factors like urbanization and language shift towards French. 18 | 19 | ## Dialectal Variations 20 | - Alsacien includes multiple dialects, which may vary significantly from one locality to another. 21 | - Two main dialects: 22 | - **Haut-Rhin** (Upper Rhine) 23 | - **Bas-Rhin** (Lower Rhine) 24 | 25 | ## Characteristics 26 | - Strongly influenced by both French and standard German, leading to unique vocabulary and pronunciation. 27 | - Grammar and syntax retain features of Middle High German. 28 | 29 | ## Cultural Significance 30 | - Acts as a marker of regional identity for the people of Alsace. 31 | - Extensively used in local media, literature, and music, particularly folk traditions. 32 | 33 | ## Status 34 | - Considered a vulnerable language by UNESCO. 35 | - Efforts are ongoing for revitalization, including teaching in schools and cultural associations promoting its use. 36 | 37 | ## Related Languages 38 | - Closely related to Swiss German and other Alemannic dialects. 39 | - Influenced by and influences neighboring languages, particularly French. 40 | 41 | ## Conclusion 42 | Alsacien is a vital part of the cultural heritage of the Alsace region, with ongoing efforts aimed at preserving and promoting its use among younger generations. -------------------------------------------------------------------------------- /community-contributions/synthetic-dataset-generator/README.md: -------------------------------------------------------------------------------- 1 | # LLM-Powered Dataset Synthesizer: LLaMA 3 + Gradio Demo 2 | 3 | This interactive demo showcases a synthetic dataset generation pipeline powered by Meta's LLaMA 3.1 8B-Instruct model, running in 4-bit quantized mode. Users can input natural language prompts describing the structure and logic of a desired dataset, and the model will generate tabular data accordingly. 4 | 5 | ## ✨ Description 6 | 7 | Modern LLMs are capable of reasoning over structured data formats and generating realistic, constrained datasets. This demo leverages the LLaMA 3.1 instruct model, combined with prompt engineering, to generate high-quality synthetic tabular data from plain-language descriptions. 8 | 9 | Key components: 10 | - **LLaMA 3.1 8B-Instruct** via Hugging Face Transformers 11 | - **4-bit quantized loading** with `bitsandbytes` for memory efficiency 12 | - **Custom prompt framework** for schema + value constraints 13 | - **Interactive interface** built with Gradio for user-friendly data generation 14 | 15 | ## 🚀 Functionality 16 | 17 | With this tool, you can: 18 | - Generate synthetic datasets by describing the column names, data types, value logic, and number of rows 19 | - Apply constraints based on age, gender, matching conditions, and more (e.g., “females over 40; males under 40”) 20 | - Preview the raw model output or extract structured JSON/tabular results 21 | - Interactively explore and copy generated datasets from the Gradio UI 22 | 23 | ## 🛠️ Under the Hood 24 | 25 | - The model prompt template includes both a **system message** and user instruction 26 | - Output is parsed to extract valid JSON objects 27 | - The generated data is displayed in the Gradio interface and downloadable as CSV 28 | 29 | ## 📦 Requirements 30 | 31 | - Python (Colab recommended) 32 | - `transformers`, `bitsandbytes`, `accelerate`, `gradio`, `torch` 33 | - Hugging Face access token with permission to load LLaMA 3.1 34 | 35 | --- 36 | 37 | Ready to generate smart synthetic datasets with just a sentence? Try it! 38 | -------------------------------------------------------------------------------- /week8/agents/ensemble_agent.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.linear_model import LinearRegression 3 | import joblib 4 | 5 | from agents.agent import Agent 6 | from agents.specialist_agent import SpecialistAgent 7 | from agents.frontier_agent import FrontierAgent 8 | from agents.random_forest_agent import RandomForestAgent 9 | 10 | class EnsembleAgent(Agent): 11 | 12 | name = "Ensemble Agent" 13 | color = Agent.YELLOW 14 | 15 | def __init__(self, collection): 16 | """ 17 | Create an instance of Ensemble, by creating each of the models 18 | And loading the weights of the Ensemble 19 | """ 20 | self.log("Initializing Ensemble Agent") 21 | self.specialist = SpecialistAgent() 22 | self.frontier = FrontierAgent(collection) 23 | self.random_forest = RandomForestAgent() 24 | self.model = joblib.load('ensemble_model.pkl') 25 | self.log("Ensemble Agent is ready") 26 | 27 | def price(self, description: str) -> float: 28 | """ 29 | Run this ensemble model 30 | Ask each of the models to price the product 31 | Then use the Linear Regression model to return the weighted price 32 | :param description: the description of a product 33 | :return: an estimate of its price 34 | """ 35 | self.log("Running Ensemble Agent - collaborating with specialist, frontier and random forest agents") 36 | specialist = self.specialist.price(description) 37 | frontier = self.frontier.price(description) 38 | random_forest = self.random_forest.price(description) 39 | X = pd.DataFrame({ 40 | 'Specialist': [specialist], 41 | 'Frontier': [frontier], 42 | 'RandomForest': [random_forest], 43 | 'Min': [min(specialist, frontier, random_forest)], 44 | 'Max': [max(specialist, frontier, random_forest)], 45 | }) 46 | y = max(0, self.model.predict(X)[0]) 47 | self.log(f"Ensemble Agent complete - returning ${y:.2f}") 48 | return y -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/breton.md: -------------------------------------------------------------------------------- 1 | # Overview of the Breton Language 2 | 3 | ## General Information 4 | - **Name**: Breton (Brezhoneg) 5 | - **Language Family**: Celtic, part of the Brythonic branch 6 | - **Region**: Brittany (Breizh), France 7 | 8 | ## Historical Background 9 | - **Origins**: Breton is derived from the Brythonic Celtic languages that were spoken in Great Britain. It arrived in Brittany with settlers from Britain during the early medieval period. 10 | - **First Documented Evidence**: The earliest written examples of Breton date back to the 8th century. 11 | 12 | ## Linguistic Features 13 | - **Dialects**: There are three main dialects of Breton: 14 | - **Gouèze** (Western) 15 | - **Kerne** (Central) 16 | - **Leoneg** (Eastern) 17 | - **Alphabet**: The modern Breton alphabet uses the Latin script with some diacritics. 18 | 19 | ## Current Status 20 | - **Speakers**: Approximately 200,000 to 300,000 speakers as of recent estimates. 21 | - **Recognition**: Breton is recognized as a regional language in France, but it does not hold official status. 22 | - **Revitalization Efforts**: There are ongoing initiatives to promote the language, including bilingual education and media in Breton. 23 | 24 | ## Cultural Significance 25 | - **Literature and Music**: Breton has a rich oral tradition, including folklore, songs, and poetry. Contemporary literature and music often embrace the language. 26 | - **Festivals**: Events like Fest-Noz (night festivals) celebrate Breton culture and often feature music and dance in the Breton language. 27 | 28 | ## Challenges 29 | - **Decline**: The number of native speakers has declined significantly due to historical policies and the dominance of French. 30 | - **Education**: Breton is not widely taught in schools, although there are some bilingual programs and immersion schools. 31 | 32 | ## Conclusion 33 | Breton is a vibrant Celtic language with a rich history and cultural heritage, facing challenges in the modern age but supported by revitalization efforts and community engagement. -------------------------------------------------------------------------------- /week1/community-contributions/Playwright_Scrapping_Project/scraping_script.py: -------------------------------------------------------------------------------- 1 | import os 2 | import openai 3 | from IPython.display import Markdown, display 4 | from dotenv import load_dotenv 5 | from playwright.sync_api import sync_playwright 6 | from bs4 import BeautifulSoup 7 | 8 | load_dotenv() 9 | openai.api_key = os.getenv("OPENAI_API_KEY") # Or set it directly 10 | 11 | def scrape_website(url): 12 | # Code to scrape a website using Playwright 13 | with sync_playwright() as p: 14 | browser = p.chromium.launch(headless=True) 15 | page = browser.new_page() 16 | page.goto(url) 17 | content = page.content() 18 | browser.close() 19 | return content 20 | 21 | def summarize_content(html_content): 22 | #Get only the text parts of the webpage 23 | soup = BeautifulSoup(html_content, 'html.parser') 24 | summary_text = soup.get_text(separator=' ', strip=True) 25 | # Code to summarize using OpenAI API 26 | system_prompt = ("You summarize html content as markdown.") 27 | user_prompt = ( 28 | "You are a helpful assistant. Summarize the following HTML webpage content in markdown with simple terms:\n\n" 29 | + summary_text 30 | ) 31 | response = openai.chat.completions.create( 32 | model="gpt-4o", 33 | messages=[{"role": "user", "content": user_prompt}] 34 | ) 35 | return response.choices[0].message.content 36 | 37 | def save_markdown(summary, filename="summary.md", url=None): 38 | #Open the file summary.md 39 | with open(filename, "w", encoding="utf-8") as f: 40 | if url: 41 | f.write(f"# Summary of [{url}]({url})\n\n") 42 | else: 43 | f.write("# Summary\n\n") 44 | f.write(summary.strip()) 45 | 46 | # 4. Main Logic 47 | def main(): 48 | url = input("Enter the URL to summarize: ").strip() 49 | html = scrape_website(url) 50 | summary = summarize_content(html) 51 | save_markdown(summary, filename="summary.md", url=url) 52 | print("✅ Summary saved to summary.md") 53 | 54 | # 5. Entry Point 55 | if __name__ == "__main__": 56 | main() -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/ardennes.md: -------------------------------------------------------------------------------- 1 | # Overview of the Ardennes Mountain Range 2 | 3 | ## Location 4 | - The Ardennes is a region located in the northeastern part of France, extending into Belgium and Luxembourg. 5 | 6 | ## Geography 7 | - The Ardennes is characterized by dense forests, deep valleys, and rolling hills. 8 | - The highest peak in the French Ardennes is Le Signal de Botrange, which reaches an elevation of about 2,277 feet (694 meters), although it is situated in Belgium. 9 | 10 | ## Geology 11 | - The area is known for its rugged terrain and is primarily composed of sedimentary rocks such as limestone and sandstone. 12 | - The landscape has been shaped by glacial and river erosion over millennia. 13 | 14 | ## Climate 15 | - The Ardennes has a temperate maritime climate, with cool summers and mild winters. 16 | - Precipitation is relatively high, leading to lush vegetation. 17 | 18 | ## Flora and Fauna 19 | - The region is home to diverse wildlife, including deer, wild boar, and various bird species. 20 | - Dense forests are dominated by beech and fir trees, and many areas are protected as nature reserves. 21 | 22 | ## Human Activity 23 | - The Ardennes has a rich history, having been inhabited since prehistoric times. 24 | - It has significance in World War I and II, particularly during the Battle of the Bulge. 25 | - The region is known for outdoor activities such as hiking, cycling, and kayaking. 26 | 27 | ## Cultural Aspects 28 | - The Ardennes is dotted with picturesque villages and towns, showcasing traditional architecture. 29 | - The area is known for its beer production, particularly in Belgium, with many breweries operating in the region. 30 | 31 | ## Tourism 32 | - Key attractions include the Semois River, the fortress of Bouillon, and the expansive forests of the Ardennes. 33 | - The region offers several trails and parks, attracting nature lovers and adventure enthusiasts. 34 | 35 | ## Conclusion 36 | The Ardennes is a unique blend of natural beauty, historical significance, and cultural richness, making it an important region in France and beyond. -------------------------------------------------------------------------------- /week5/knowledge-base/employees/Jordan Blake.md: -------------------------------------------------------------------------------- 1 | # HR Record 2 | 3 | # Jordan Blake 4 | 5 | ## Summary 6 | - **Date of Birth:** March 15, 1993 7 | - **Job Title:** Sales Development Representative (SDR) 8 | - **Location:** Austin, Texas 9 | 10 | ## Insurellm Career Progression 11 | - **2021-06:** Joined Insurellm as an Entry-Level SDR 12 | - **2022-02:** Promoted to Junior SDR after exceeding quarterly targets by 25% 13 | - **2022-12:** Recognized as SDR of the Month for three consecutive months 14 | - **2023-05:** Participated in the Insurellm Leadership Training Program 15 | 16 | ## Annual Performance History 17 | - **2021:** First year at Insurellm; achieved 90% of monthly targets. 18 | - **Feedback:** Strong potential shown in lead generation; needs improvement in follow-up techniques. 19 | - **2022:** Achieved 120% of targets; pioneered outreach strategies that increased customer engagement. 20 | - **Feedback:** Jordan's innovative approach contributed significantly to team success; recommended for leadership training. 21 | - **2023:** Set to exceed annual targets by 30% in Q3; initiated successful partnerships that broadened market reach. 22 | - **Feedback:** Exceptional communicator; exemplifies the values of Insurellm and promotes team collaboration. 23 | 24 | ## Compensation History 25 | - **2021-06:** Starting Salary: $50,000 26 | - **2022-04:** Merit-based increase: $55,000 (based on performance review) 27 | - **2023-06:** Performance bonus awarded: $5,000 (for exceeding goals as recognized in annual review) 28 | - **2023-09:** Salary adjustment due to promotion to Senior SDR: $65,000 29 | 30 | ## Other HR Notes 31 | - Jordan has shown an interest in continuing education, actively participating in company-sponsored sales webinars. 32 | - Notable for involvement in the Insurellm volunteer program, assisting local charity events related to financial literacy. 33 | - Employee wellness advocate, consistently promotes team bonding activities and stress-relief workshops. 34 | - Plans to enroll in a course for advanced sales strategies in Q4 2023, aiming to further enhance his skills at Insurellm. -------------------------------------------------------------------------------- /week1/community-contributions/Playwright_Scrapping_Project/summary.md: -------------------------------------------------------------------------------- 1 | # Summary of [https://www.willwight.com/](https://www.willwight.com/) 2 | 3 | # Will Wight - New York Times Best-Selling Author 4 | 5 | ### Overview 6 | Will Wight is a renowned author known for the "Cradle" series, alongside other works like "The Last Horizon" and "The Traveler's Gate Trilogy." He combines humor and storytelling in his blog and engages actively with his readers. 7 | 8 | ### Books 9 | - **The Last Horizon**: Currently ongoing series. 10 | - **Cradle**: A 12-book series, now complete. 11 | - **The Traveler's Gate Trilogy**: Completed series. 12 | - **The Elder Empire**: Consists of two trilogies with stories happening simultaneously, totaling 6 books. 13 | 14 | ### Recent Highlights 15 | - **The Pilot Release**: The fourth book in "The Last Horizon" series, celebrated on July 4th, 2025. The 26th book by Will, marking a milestone as his next book will be his 27th. 16 | - **Barnes & Noble Success**: A significant achievement of getting Will's books stocked nationwide in Barnes & Noble, marking a breakthrough for indie publishing. 17 | 18 | ### Blog Highlights 19 | - Will shares personal anecdotes and behind-the-scenes insights into his creative process. 20 | - A humorous tone is used, including whimsical stories about his life and writing challenges. 21 | - Recent experiences at Epic Universe theme park with thoughts on its design and offerings. 22 | 23 | ### Connect 24 | - **Mailing List**: Over 15,000 fans subscribe to receive updates on new stories and releases. 25 | - **Hidden Gnome Publishing**: The entity behind Will's publications, working to bring his books to wider audiences. 26 | 27 | ### Extras 28 | - **Merch**: Available for fans wanting to support and connect with Will's universe. 29 | - **Podcast**: Offers sneak peeks, discussions, and insights into Will's works. 30 | 31 | ### Humorous Note 32 | Will humorously describes himself transforming into a "monstrous mongoose" during a full moon, adding a quirky touch to his persona. 33 | 34 | For more detailed information on books, blogs, and extras, visit Will's website and explore his engaging world of storytelling! -------------------------------------------------------------------------------- /week2/community-contributions/week2_day2_gradio/json_handlers.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | 4 | class SettingsHandler: 5 | def __init__(self, json_filename): 6 | self.json_filename = json_filename 7 | self.advanced_settings = self.load_current_settings() 8 | 9 | def load_current_settings(self) -> dict: 10 | with open(self.json_filename, "r") as file: 11 | settings_dict = json.load(file) 12 | 13 | advanced_settings = settings_dict["Advanced Settings"] 14 | 15 | return advanced_settings 16 | 17 | def update_advanced_settings(self, updated_advanced_settings: dict): 18 | new_dict = { 19 | "Advanced Settings": updated_advanced_settings 20 | } 21 | 22 | print(new_dict) 23 | 24 | with open(self.json_filename, "w") as file: 25 | json.dump(new_dict, file) 26 | 27 | self.advanced_settings = updated_advanced_settings 28 | 29 | def update_advanced_settings_param(self, key: str, new_val): 30 | if self.get_advanced_setting_param(key) is not None: 31 | update_advanced_settings_dict = self.advanced_settings 32 | update_advanced_settings_dict[key] = new_val 33 | self.update_advanced_settings(update_advanced_settings_dict) 34 | 35 | def get_advanced_settings(self): 36 | return self.advanced_settings 37 | 38 | def get_advanced_setting_param(self, key: str): 39 | return self.advanced_settings.get(key) 40 | 41 | 42 | class LanguagesHandler: 43 | def __init__(self, json_filename): 44 | self.json_filename = json_filename 45 | self.langs = self.load_languages() 46 | 47 | def load_languages(self) -> list: 48 | with open(self.json_filename, "r") as file: 49 | langs = json.load(file) 50 | 51 | if type(langs) != list: 52 | raise RuntimeError("Languages must be provided as lists") 53 | if len(langs) < 2: 54 | raise RuntimeError("At least 2 languages must be supported") 55 | 56 | return langs 57 | 58 | def get_supported_languages(self): 59 | return self.langs 60 | 61 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/massif_armorican.md: -------------------------------------------------------------------------------- 1 | # Overview of the Massif Armorican 2 | 3 | ## Location 4 | - **Region**: Brittany, France 5 | - **Coordinates**: Approximately 47° N latitude and 2° W longitude 6 | 7 | ## Geography 8 | - **Type**: Mountain range and geological massif 9 | - **Area**: Covers parts of the departments of Ille-et-Vilaine, Morbihan, and Finistère 10 | - **Elevation**: The highest peak, **Montagnes Noires**, reaches around 600 meters (1,969 feet) 11 | 12 | ## Geology 13 | - **Formation**: Primarily composed of ancient metamorphic rocks and granite formations, dating back to the Precambrian and Paleozoic eras 14 | - **Tectonic Activity**: Influenced by the Variscan orogeny, which caused significant geological changes 15 | 16 | ## Flora and Fauna 17 | - **Biodiversity**: Home to diverse ecosystems, including heathlands, forests, and wetlands 18 | - **Protected Areas**: Parts of the massif are designated as natural parks and reserves, promoting conservation efforts 19 | 20 | ## Culture and History 21 | - **Historical Significance**: The area is rich in megalithic structures and archaeological sites, reflecting ancient Celtic culture 22 | - **Tourism**: Popular for hiking, cycling, and exploring its historical sites, contributing to local economies 23 | 24 | ## Climate 25 | - **Climate Type**: Maritime temperate climate, characterized by mild winters and cool summers 26 | - **Precipitation**: Receives a significant amount of rainfall throughout the year, supporting its lush vegetation 27 | 28 | ## Attractions 29 | - **Sites of Interest**: Includes historic towns, châteaux, and picturesque landscapes, attracting visitors for both natural beauty and cultural heritage 30 | - **Outdoor Activities**: Offers opportunities for outdoor sports such as hiking, horseback riding, and nature observation 31 | 32 | ## Transportation 33 | - **Accessibility**: Well-connected by road and rail, making it easily accessible from major urban centers in Brittany 34 | 35 | This overview encapsulates the essential aspects of the Massif Armorican, highlighting its geographical, geological, and cultural significance in France. -------------------------------------------------------------------------------- /community-contributions/bojan-playwright-scraper/notebooks/huggingface_co_Summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "3069b0e8", 6 | "metadata": {}, 7 | "source": [ 8 | "\n", 9 | "# Summary for https://huggingface.co\n", 10 | "\n", 11 | "This notebook contains an AI-generated summary of the website content.\n", 12 | "\n", 13 | "**URL**: `https://huggingface.co`\n", 14 | "\n", 15 | "---\n", 16 | "**Analysis**:\n", 17 | "Based on the provided content snippet, here is an analysis structured under the requested headings:\n", 18 | "\n", 19 | "### Summary\n", 20 | "The information provided is insufficient to determine the exact purpose of the website. However, the name \"Dia-1.6B\" suggests it might be related to a project or software version.\n", 21 | "\n", 22 | "### Entities\n", 23 | "No specific individuals or organizations are mentioned in the provided content.\n", 24 | "\n", 25 | "### Updates\n", 26 | "The content was updated 1 day ago, indicating recent activity or changes. However, the nature of these updates is not specified.\n", 27 | "\n", 28 | "### Topics\n", 29 | "The snippet does not provide enough information to identify primary subjects or themes.\n", 30 | "\n", 31 | "### Features\n", 32 | "The content does not detail any specific projects or initiatives.\n", 33 | "\n", 34 | "**Note:** The analysis is limited due to the lack of detailed information in the provided content snippet. More comprehensive content would be required for a complete analysis.\n" 35 | ] 36 | } 37 | ], 38 | "metadata": { 39 | "kernelspec": { 40 | "display_name": "Python (WSL-Lakov)", 41 | "language": "python", 42 | "name": "lakov-wsl" 43 | }, 44 | "language_info": { 45 | "codemirror_mode": { 46 | "name": "ipython", 47 | "version": 3 48 | }, 49 | "file_extension": ".py", 50 | "mimetype": "text/x-python", 51 | "name": "python", 52 | "nbconvert_exporter": "python", 53 | "pygments_lexer": "ipython3", 54 | "version": "3.12.7" 55 | } 56 | }, 57 | "nbformat": 4, 58 | "nbformat_minor": 5 59 | } 60 | -------------------------------------------------------------------------------- /community-contributions/protocol_summarizer_webapp/README.md: -------------------------------------------------------------------------------- 1 | # Protocol Summarizer Webapp 2 | 3 | A Streamlit web application for searching and summarizing clinical trial protocols from ClinicalTrials.gov using Large Language Models. This tool enables researchers and clinical professionals to quickly extract key information from clinical trial protocols. 4 | 5 | ## Features 6 | - Search for clinical trials by keyword 7 | - Display a list of studies with title and NCT number 8 | - Select a study to summarize 9 | - Fetch the protocol's brief summary from ClinicalTrials.gov API 10 | - Automatically summarize the protocol using OpenAI's LLM 11 | - Extract structured information like study design, population, interventions, and endpoints 12 | 13 | ## Installation 14 | 15 | 1. Clone this repository: 16 | ```sh 17 | git clone https://github.com/albertoclemente/protocol_summarizer.git 18 | cd protocol_summarizer/protocol_summarizer_webapp 19 | ``` 20 | 21 | 2. Install dependencies: 22 | ```sh 23 | pip install -r requirements.txt 24 | ``` 25 | 26 | 3. Create a `.env` file in the project root with your OpenAI API key: 27 | ``` 28 | OPENAI_API_KEY=your_api_key_here 29 | ``` 30 | 31 | ## Usage 32 | 33 | 1. Run the Streamlit app: 34 | ```sh 35 | streamlit run app.py 36 | ``` 37 | 38 | 2. In your browser: 39 | - Enter a disease, condition, or keyword in the search box 40 | - Select the number of results to display 41 | - Click the "Search" button 42 | - Select a study from the results 43 | - Click "Summarize Protocol" to generate a structured summary 44 | 45 | ## Technical Details 46 | 47 | - Uses ClinicalTrials.gov API v2 to retrieve study information 48 | - Implements fallback methods to handle API changes or failures 49 | - Extracts protocol brief summaries using reliable JSON parsing 50 | - Generates structured summaries using OpenAI's GPT models 51 | 52 | ## Requirements 53 | 54 | - Python 3.7+ 55 | - Streamlit 56 | - Requests 57 | - OpenAI Python library 58 | - python-dotenv 59 | 60 | ## Contribution 61 | 62 | Contributions are welcome! Please feel free to submit a Pull Request. 63 | 64 | ## License 65 | 66 | MIT License 67 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/lorrain.md: -------------------------------------------------------------------------------- 1 | # Overview of the Lorrain Language 2 | 3 | ## General Information 4 | - **Language Family**: Lorrain is part of the Langue d'Oïl languages, which are a subgroup of the Romance languages. 5 | - **Region**: Primarily spoken in the Lorraine region of northeastern France. 6 | - **Dialects**: There are various dialects of Lorrain, including certain variations influenced by local languages and cultures. 7 | 8 | ## Historical Context 9 | - **Origins**: The language has roots dating back to the medieval period and was influenced by the historical presence of the Duchy of Lorraine. 10 | - **Language Shift**: Over the 19th and 20th centuries, Lorrain saw a decline in usage due to the dominance of French, leading many speakers to shift to French. 11 | 12 | ## Linguistic Features 13 | - **Phonology**: Lorrain phonetics include distinct sounds that differentiate it from standard French and other Langue d'Oïl languages. 14 | - **Vocabulary**: The lexicon of Lorrain retains several archaic words and expressions that have disappeared from modern French. 15 | - **Grammar**: Similar to French but with unique grammatical structures and conjugations, reflecting its distinct identity. 16 | 17 | ## Cultural Significance 18 | - **Traditions**: Lorrain is often associated with local folklore, songs, and literature, which contribute to the cultural identity of Lorraine. 19 | - **Preservation Efforts**: Various initiatives have been undertaken to promote and preserve the Lorrain language, including cultural festivals and educational programs. 20 | 21 | ## Current Status 22 | - **Speaker Population**: The number of active speakers has significantly decreased, with many older speakers and limited transmission to younger generations. 23 | - **Revitalization**: Recent efforts are being made to revive interest in Lorrain among younger populations through workshops, classes, and media. 24 | 25 | ## Conclusion 26 | Lorrain is a unique language that embodies the rich cultural heritage of the Lorraine region. While it faces challenges, ongoing efforts aim to preserve and revitalize this historical language for future generations. -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/vosges.md: -------------------------------------------------------------------------------- 1 | # Vosges Mountains Overview 2 | 3 | ## Geography 4 | - **Location**: Northeastern France, bordering Germany to the east. 5 | - **Length**: Approximately 150 kilometers (93 miles) from north to south. 6 | - **Elevation**: The highest peak is **Haut du Tôt**, which reaches an elevation of **1,424 meters** (4,672 feet). 7 | 8 | ## Natural Features 9 | - **Landscape**: Characterized by rolling hills, dense forests, and numerous lakes and streams. 10 | - **Geology**: Composed mainly of granite and sandstone, along with some limestone. 11 | - **Flora and Fauna**: Home to diverse ecosystems, including coniferous and deciduous forests, and various wildlife such as deer, wild boar, and a range of bird species. 12 | 13 | ## Climate 14 | - **Influence**: The Vosges mountains create a rainshadow effect, leading to varied climates on either side of the range. 15 | - **Weather**: Generally humid, with abundant rainfall, particularly in the western slopes. 16 | 17 | ## Culture and History 18 | - **Human Settlement**: Historically inhabited by Celtic tribes, later significant in both the Roman Empire and medieval periods. 19 | - **Tourism**: Popular for hiking, skiing, and outdoor activities, with many marked trails and ski resorts. 20 | - **Cultural Heritage**: Known for traditional villages, local cuisine, and the Alsace wine route. 21 | 22 | ## Notable Locations 23 | - **Ballons des Vosges Regional Nature Park**: A protected area showcasing the natural beauty of the mountains. 24 | - **Colmar and Gérardmer**: Prominent towns known for their cultural significance and as tourist destinations. 25 | - **Route des Crêtes**: A scenic road that offers breathtaking views of the Vosges and surrounding regions. 26 | 27 | ## Activities 28 | - **Hiking**: Numerous trails, including the famous GR5 long-distance path. 29 | - **Skiing**: Various ski resorts, particularly in the higher altitudes. 30 | - **Cycling**: The region is cyclist-friendly with several bike routes. 31 | 32 | ## Accessibility 33 | - **Transport**: Well-connected by road and rail, making it accessible from major French cities and neighboring countries. -------------------------------------------------------------------------------- /week4/optimized.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | class LCG { 8 | private: 9 | uint64_t value; 10 | const uint64_t a = 1664525; 11 | const uint64_t c = 1013904223; 12 | const uint64_t m = 1ULL << 32; 13 | 14 | public: 15 | LCG(uint64_t seed) : value(seed) {} 16 | 17 | uint64_t next() { 18 | value = (a * value + c) % m; 19 | return value; 20 | } 21 | }; 22 | 23 | int64_t max_subarray_sum(int n, uint64_t seed, int min_val, int max_val) { 24 | LCG lcg(seed); 25 | std::vector random_numbers(n); 26 | for (int i = 0; i < n; ++i) { 27 | random_numbers[i] = static_cast(lcg.next() % (max_val - min_val + 1) + min_val); 28 | } 29 | 30 | int64_t max_sum = std::numeric_limits::min(); 31 | int64_t current_sum = 0; 32 | for (int i = 0; i < n; ++i) { 33 | current_sum = std::max(static_cast(random_numbers[i]), current_sum + random_numbers[i]); 34 | max_sum = std::max(max_sum, current_sum); 35 | } 36 | return max_sum; 37 | } 38 | 39 | int64_t total_max_subarray_sum(int n, uint64_t initial_seed, int min_val, int max_val) { 40 | int64_t total_sum = 0; 41 | LCG lcg(initial_seed); 42 | for (int i = 0; i < 20; ++i) { 43 | uint64_t seed = lcg.next(); 44 | total_sum += max_subarray_sum(n, seed, min_val, max_val); 45 | } 46 | return total_sum; 47 | } 48 | 49 | int main() { 50 | int n = 10000; 51 | uint64_t initial_seed = 42; 52 | int min_val = -10; 53 | int max_val = 10; 54 | 55 | auto start_time = std::chrono::high_resolution_clock::now(); 56 | int64_t result = total_max_subarray_sum(n, initial_seed, min_val, max_val); 57 | auto end_time = std::chrono::high_resolution_clock::now(); 58 | 59 | auto duration = std::chrono::duration_cast(end_time - start_time); 60 | 61 | std::cout << "Total Maximum Subarray Sum (20 runs): " << result << std::endl; 62 | std::cout << "Execution Time: " << std::fixed << std::setprecision(6) << duration.count() / 1e6 << " seconds" << std::endl; 63 | 64 | return 0; 65 | } -------------------------------------------------------------------------------- /week1/community-contributions/ag-w1d2-ollama-site-summary: -------------------------------------------------------------------------------- 1 | import ollama 2 | import requests 3 | from bs4 import BeautifulSoup 4 | from IPython.display import Markdown, display 5 | 6 | MODEL = "llama3.2" 7 | 8 | #headers and class for website to summarize 9 | headers = { 10 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" 11 | } 12 | class Website: 13 | def __init__(self, url): 14 | self.url = url 15 | response = requests.get(url, headers=headers) 16 | soup = BeautifulSoup(response.content, 'html.parser') 17 | self.title = soup.title.string if soup.title else "No title found" 18 | for irrelevant in soup.body(["script", "style", "img", "input"]): 19 | irrelevant.decompose() 20 | self.text = soup.body.get_text(separator="\n", strip=True) 21 | 22 | #define prompts 23 | system_prompt = "You are an assistant that analyzes the contents of a website \ 24 | and provides a short summary, ignoring text that might be navigation related. \ 25 | Respond in markdown." 26 | 27 | def user_prompt_for(website): 28 | user_prompt = f"You are looking at a website titled {website.title}" 29 | user_prompt += "\nThe content of this website is as follows; \ 30 | please provide a short summary of this website in markdown. \ 31 | If it includes news or announcements, then summarize these too.\n\n" 32 | user_prompt += website.text 33 | return user_prompt 34 | 35 | #prepare message for use in OpenAI call 36 | def messages_for(website): 37 | return [ 38 | {"role": "system", "content": system_prompt}, 39 | {"role": "user", "content": user_prompt_for(website)} 40 | ] 41 | 42 | #define function to summarize a given website 43 | def summarize(url): 44 | website = Website(url) 45 | response = ollama.chat(model=MODEL, messages=messages_for(website)) 46 | return response['message']['content'] 47 | 48 | #function to display summary in markdown format 49 | def display_summary(url): 50 | summary = summarize(url) 51 | display(Markdown(summary)) 52 | print(summary) 53 | 54 | url = "https://edwarddonner.com" 55 | display_summary(url) -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/alpes.md: -------------------------------------------------------------------------------- 1 | # Overview of the French Alps 2 | 3 | ## General Information 4 | - **Location:** Southeastern France, extending into Switzerland and Italy. 5 | - **Length:** Approximately 1,200 kilometers (750 miles). 6 | - **Highest Peak:** Mont Blanc, standing at 4,808 meters (15,774 feet). 7 | - **Mountain Chain:** Part of the larger Alpine range that spans across several European countries. 8 | 9 | ## Geography 10 | - **Geological Composition:** Primarily composed of limestone and granite. 11 | - **Major Valleys:** Includes the Rhône and Isère valleys. 12 | - **Natural Parks:** Home to several national parks, including Écrins National Park and Vanoise National Park. 13 | 14 | ## Climate 15 | - **Variety:** Alpine climate with large variations; cold winters and mild summers. 16 | - **Snowfall:** Heavy snowfall in winter makes it a prime destination for winter sports. 17 | 18 | ## Flora and Fauna 19 | - **Biodiversity:** Rich diversity of species; includes both alpine and Mediterranean flora. 20 | - **Wildlife:** Encounters with species such as chamois, ibex, and golden eagles. 21 | 22 | ## Activities 23 | - **Winter Sports:** Skiing and snowboarding are popular, with famous resorts like Chamonix, Courchevel, and Val d’Isère. 24 | - **Summer Activities:** Hiking, mountaineering, and mountain biking attract visitors during the warmer months. 25 | - **Paragliding:** Known as a hotspot for paragliding due to favorable winds and stunning views. 26 | 27 | ## Cultural Significance 28 | - **Local Communities:** Home to various Alpine villages and cultures, each with unique traditions and languages. 29 | - **Gastronomy:** Famous for local cheeses (like Beaufort and Reblochon), charcuterie, and dishes such as fondue and raclette. 30 | 31 | ## Historical Aspects 32 | - **Cultural Heritage:** Influenced by Roman and medieval settlements, with significant archaeological sites. 33 | - **Tourism:** Became a major tourist destination in the 19th century. 34 | 35 | ## Importance 36 | - **Economic Significance:** Tourism is a vital part of the local economy, alongside agriculture and forestry. 37 | - **Sustainability Focus:** Growing emphasis on sustainable tourism practices to protect the fragile alpine ecosystem. -------------------------------------------------------------------------------- /week8/community_contributions/ensemble-updated/ensemble_agent.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.linear_model import LinearRegression 3 | import joblib 4 | 5 | from agents.agent import Agent 6 | from agents.specialist_agent import SpecialistAgent 7 | from agents.frontier_agent import FrontierAgent 8 | from agents.random_forest_agent import RandomForestAgent 9 | from agents.xg_boost_agent import XGBoostAgent 10 | 11 | class EnsembleAgent(Agent): 12 | 13 | name = "Ensemble Agent" 14 | color = Agent.YELLOW 15 | 16 | def __init__(self, collection): 17 | """ 18 | Create an instance of Ensemble, by creating each of the models 19 | And loading the weights of the Ensemble 20 | """ 21 | self.log("Initializing Ensemble Agent") 22 | self.specialist = SpecialistAgent() 23 | self.frontier = FrontierAgent(collection) 24 | self.random_forest = RandomForestAgent() 25 | self.xg_boost = XGBoostAgent() 26 | self.model = joblib.load('ensemble_model.pkl') 27 | self.log("Ensemble Agent is ready") 28 | 29 | def price(self, description: str) -> float: 30 | """ 31 | Run this ensemble model 32 | Ask each of the models to price the product 33 | Then use the Linear Regression model to return the weighted price 34 | :param description: the description of a product 35 | :return: an estimate of its price 36 | """ 37 | self.log("Running Ensemble Agent - collaborating with specialist, frontier, xg boost and random forest agents") 38 | specialist = self.specialist.price(description) 39 | frontier = self.frontier.price(description) 40 | random_forest = self.random_forest.price(description) 41 | xg_boost = self.xg_boost.price(description) 42 | X = pd.DataFrame({ 43 | 'Specialist': [specialist], 44 | 'Frontier': [frontier], 45 | 'RandomForest': [random_forest], 46 | 'XGBoost' : [xg_boost], 47 | 'Min': [min(specialist, frontier, random_forest, xg_boost)], 48 | 'Max': [max(specialist, frontier, random_forest, xg_boost)], 49 | }) 50 | y = max(0, self.model.predict(X)[0]) 51 | self.log(f"Ensemble Agent complete - returning ${y:.2f}") 52 | return y -------------------------------------------------------------------------------- /community-contributions/bojan-playwright-scraper/notebook_generator.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import nbformat 4 | from nbformat.v4 import new_notebook, new_markdown_cell 5 | import asyncio 6 | from dotenv import load_dotenv 7 | import logging 8 | 9 | # Loading .env variables 10 | load_dotenv() 11 | 12 | # Setting up logging 13 | logging.basicConfig( 14 | level=os.getenv("LOG_LEVEL", "INFO").upper(), 15 | format="%(asctime)s - %(levelname)s - %(message)s" 16 | ) 17 | 18 | # Adding project directory to sys.path 19 | project_dir = os.path.join( 20 | "/home/lakov/projects/llm_engineering", 21 | "community-contributions/playwright-bojan" 22 | ) 23 | if project_dir not in sys.path: 24 | sys.path.insert(0, project_dir) 25 | 26 | # Importing analyze_content from playwright_ai_scraper.py 27 | try: 28 | from playwright_ai_scraper import analyze_content 29 | except ModuleNotFoundError as e: 30 | logging.error(f"Error importing module: {e}") 31 | sys.exit(1) 32 | 33 | # Function to save the notebook 34 | 35 | 36 | def save_notebook(url, content): 37 | output_dir = os.path.join(project_dir, "notebooks") 38 | os.makedirs(output_dir, exist_ok=True) 39 | 40 | # Extracting the domain from the URL 41 | domain = url.split("//")[-1].split("/")[0].replace(".", "_") 42 | filename = f"{domain}_Summary.ipynb" 43 | path = os.path.join(output_dir, filename) 44 | 45 | nb = new_notebook() 46 | intro = f""" 47 | # Summary for {url} 48 | 49 | This notebook contains an AI-generated summary of the website content. 50 | 51 | **URL**: `{url}` 52 | 53 | --- 54 | **Analysis**: 55 | {content} 56 | """ 57 | nb.cells.append(new_markdown_cell(intro)) 58 | 59 | with open(path, 'w', encoding='utf-8') as f: 60 | nbformat.write(nb, f) 61 | 62 | logging.info(f"Notebook saved to: {path}") 63 | return path 64 | 65 | # Main function 66 | 67 | 68 | async def main(): 69 | url = input("Enter URL to scrape: ") 70 | try: 71 | result = await analyze_content(url, headless=True) 72 | save_notebook(url, result) 73 | print(f"Summary for {url}:\n{result}") 74 | except Exception as e: 75 | logging.error(f"Failed to process {url}: {e}") 76 | print(f"Error: {e}") 77 | 78 | if __name__ == "__main__": 79 | asyncio.run(main()) 80 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/bourguignon.md: -------------------------------------------------------------------------------- 1 | # Overview of the Bourguignon Language 2 | 3 | ## General Information 4 | - **Name**: Bourguignon 5 | - **Region**: Primarily spoken in the Burgundy region of France 6 | - **Language Family**: Romance languages 7 | - **Classification**: It is part of the Langue d'oïl group, which also includes languages like French, Norman, and Picard. 8 | 9 | ## Historical Context 10 | - **Origin**: Derived from Vulgar Latin, Bourguignon developed in the medieval period and reflects the linguistic evolution of the region. 11 | - **Influence**: Historically influenced by Old French, as well as regional dialects and neighboring languages. 12 | 13 | ## Features 14 | - **Dialects**: Bourguignon comprises several dialects, often differing significantly from one another. 15 | - **Phonetics**: The phonetic system exhibits distinct sounds not found in Standard French. 16 | - **Vocabulary**: Contains unique vocabulary and expressions that may not be understood by standard French speakers. 17 | 18 | ## Current Status 19 | - **Speaker Population**: The number of speakers has declined over the years, with estimates suggesting only a few thousand fluent speakers today. 20 | - **Recognition**: Bourguignon is not an official language in France, but there are efforts to preserve and promote its use among local communities. 21 | 22 | ## Cultural Significance 23 | - **Folklore and Literature**: Bourguignon has a rich tradition of oral literature, including folk tales and songs that reflect the cultural heritage of Burgundy. 24 | - **Festivals and Events**: Local festivals often include performances in Bourguignon, celebrating the language's place in regional identity. 25 | 26 | ## Modern Efforts 27 | - **Revitalization**: Initiatives to teach Bourguignon in schools and promote its use in cultural activities aim to preserve the language for future generations. 28 | - **Media Presence**: Some local media, including radio stations and publications, feature Bourguignon, fostering a sense of community among speakers. 29 | 30 | ## Conclusion 31 | Bourguignon remains an important part of the cultural identity of the Burgundy region, reflecting the historical and linguistic diversity of France. Efforts to revive and sustain the language highlight its significance within the local heritage. -------------------------------------------------------------------------------- /week1/community-contributions/Day1_2_Reddit_Analysis/README.md: -------------------------------------------------------------------------------- 1 | # Reddit Post Analyzer – GPT & Open Source Approaches 2 | 3 | This project consists of two Jupyter notebooks that demonstrate different methods for analyzing Reddit post data: 4 | 5 | - **Day 1:** `Day1_RedditAnalysis_gpt.ipynb` – Uses GPT-based sentiment and insight extraction from Reddit posts and comments. 6 | - **Day 2:** `day2_RedditAnalysis_opensource.ipynb` – Implements an open-source alternative for Reddit data processing and basic sentiment/thematic analysis. 7 | 8 | --- 9 | 10 | ## 📌 Features 11 | 12 | - Reddit post and comment scraping using PRAW 13 | - GPT-based sentiment summarization and insight structuring (Day 1) 14 | - Open-source sentiment and thematic analysis pipeline (Day 2) 15 | - Markdown-formatted output suitable for reporting 16 | 17 | --- 18 | 19 | ## 🛠️ Setup Instructions 20 | 21 | ### Reddit API Credentials Setup 22 | 23 | To access Reddit data, you need to create a Reddit app and obtain credentials: 24 | 25 | #### Steps to Get Your Reddit API Keys: 26 | 27 | 1. Go to [https://www.reddit.com/prefs/apps](https://www.reddit.com/prefs/apps). 28 | 2. Scroll to the bottom and click **“create another app”** or **“create app”**. 29 | 3. Choose the **“script”** option. 30 | 4. Fill in the following fields: 31 | - **name:** e.g., Reddit Analyzer 32 | - **redirect uri:** `http://localhost:8080` 33 | - **description:** *(optional)* 34 | 5. After creating the app, you will get: 35 | - **client ID** (displayed under the app name) 36 | - **client secret** 37 | 6. Keep note of your Reddit **username** and **password** (these are used with script apps) 38 | 39 | #### Store your credentials in a `.env` file: 40 | 41 | Create a `.env` file in the root directory with the following format: 42 | 43 | ```env 44 | REDDIT_CLIENT_ID=your_client_id 45 | REDDIT_CLIENT_SECRET=your_client_secret 46 | REDDIT_USER_AGENT=your_custom_user_agent 47 | REDDIT_USERNAME=your_reddit_username 48 | REDDIT_PASSWORD=your_reddit_password 49 | ``` 50 | 51 | These will be securely loaded into your script using the `dotenv` package. 52 | 53 | --- 54 | 55 | ## 🚀 Running the Notebooks 56 | 57 | Make sure to activate your virtual environment (if applicable), install dependencies, and run the notebooks cell by cell in **Jupyter Lab** or **VS Code**. 58 | 59 | --- 60 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/jura.md: -------------------------------------------------------------------------------- 1 | # Overview of the Jura Mountain Range in France 2 | 3 | ## Location 4 | - The Jura Mountains are located along the border between France and Switzerland. 5 | - They stretch approximately 365 kilometers (227 miles) from the Rhône River in the south to the Rhine River in the north. 6 | 7 | ## Geography 8 | - The Jura is characterized by its rugged terrain, with numerous peaks, plateaus, and deep valleys. 9 | - The highest peak in the French Jura is Crêt de la Neige, which rises to an elevation of 1,720 meters (5,643 feet). 10 | 11 | ## Geology 12 | - The range is primarily composed of limestone, which has been shaped by erosion, creating unique karst formations, caves, and cliffs. 13 | - The Jura Mountains were formed during the Jurassic period, which is reflected in their name. 14 | 15 | ## Climate 16 | - The climate in the Jura varies from humid in the west to drier conditions in the east. 17 | - The area experiences significant snowfall in winter, making it popular for winter sports. 18 | 19 | ## Flora and Fauna 20 | - The Jura is home to diverse ecosystems, including forests, alpine meadows, and wetlands. 21 | - Wildlife includes species such as deer, chamois, marmots, and a variety of bird species. 22 | 23 | ## Activities 24 | - The Jura Mountains offer various outdoor activities, including hiking, skiing, and mountain biking. 25 | - The region is known for its beautiful landscapes and natural parks, attracting tourists and nature enthusiasts. 26 | 27 | ## Cultural Significance 28 | - The Jura region is also known for its traditional cheese production, particularly Comté cheese. 29 | - Numerous charming villages and towns, such as Arbois and Clairvaux-les-Lacs, showcase the cultural heritage of the area. 30 | 31 | ## History 32 | - The Jura Mountains have historical significance, having served as a natural barrier and route for trade and exploration. 33 | - The region has witnessed various historical events, including battles during the French Revolutionary Wars and the Napoleonic Wars. 34 | 35 | ## Accessibility 36 | - The Jura is accessible from major cities like Geneva, Lyon, and Besançon, making it a popular destination for both locals and tourists. 37 | - Several scenic routes and parks are maintained to facilitate exploration and enjoyment of the natural beauty. -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/picard.md: -------------------------------------------------------------------------------- 1 | # Overview of the Picard Language 2 | 3 | ## General Information 4 | - **Language Family**: Romance, specifically a part of the West Oïl languages, which also includes French. 5 | - **Region**: Primarily spoken in the historic region of Picardy in northern France, as well as in parts of Belgium and historically in the areas of the nearby Nord-Pas-de-Calais. 6 | 7 | ## Linguistic Characteristics 8 | - **Dialects**: There are several dialects of Picard, including Amiénois, Beauvaisis, and Hesdinois. 9 | - **Vocabulary**: Shares many lexical items with French but also retains unique words and expressions. Some vocabulary is influenced by local historical interactions with Dutch and German. 10 | 11 | ## Historical Context 12 | - **Origins**: Evolved from Latin, like other Romance languages. Roots trace back to the Vulgar Latin spoken in the region during the Roman Empire. 13 | - **Literary Tradition**: Has a rich but lesser-known literary tradition, with poetry and prose dating back to the Middle Ages. 14 | 15 | ## Current Status 16 | - **Speakers**: The number of speakers has declined significantly over the 20th century due to the dominance of standard French and the 1999 ban on the usage of Picard in all of France. 17 | - **Revitalization Efforts**: Recent efforts outside of France include community classes, cultural organizations, and media in Picard to promote the language. It is rumored that there is an underground movement in France to keep Picard alive in spite of the language being banned and illegal to use since 1999. 18 | 19 | ## Cultural Significance 20 | - **Identity**: Picard is an important part of regional identity and cultural heritage for many people in northern France. 21 | - **Festivals and Events**: Regional festivals celebrate Picard culture, featuring traditional songs, dances, and cuisine. 22 | 23 | ## Legal Status 24 | - **Recognition**: Picard has no official status in France, but it is recognized as a regional language. Efforts have been made to include it in educational curricula and local government documents in some areas. 25 | 26 | ## Conclusion 27 | Picard is a unique language that reflects the cultural and historical tapestry of northern France. Despite challenges, there are active efforts to preserve and promote its usage among future generations. -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/agents/ensemble_agent.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.linear_model import LinearRegression 3 | import joblib 4 | 5 | from agents.agent import Agent 6 | from agents.specialist_agent import SpecialistAgent 7 | from agents.frontier_agent import FrontierAgent 8 | from agents.random_forest_agent import RandomForestAgent 9 | from agents.gradient_boosting_agent import GradientBoostingAgent 10 | 11 | class EnsembleAgent(Agent): 12 | 13 | name = "Ensemble Agent" 14 | color = Agent.YELLOW 15 | 16 | def __init__(self, collection): 17 | """ 18 | Create an instance of Ensemble, by creating each of the models 19 | And loading the weights of the Ensemble 20 | """ 21 | self.log("Initializing Ensemble Agent") 22 | self.specialist = SpecialistAgent() 23 | self.frontier = FrontierAgent(collection) 24 | self.random_forest = RandomForestAgent() 25 | self.gradient_boosting = GradientBoostingAgent() 26 | self.model = joblib.load('ensemble_model.pkl') 27 | self.log("Ensemble Agent is ready") 28 | 29 | def price(self, description: str) -> float: 30 | """ 31 | Run this ensemble model 32 | Ask each of the models to price the product 33 | Then use the Linear Regression model to return the weighted price 34 | :param description: the description of a product 35 | :return: an estimate of its price 36 | """ 37 | self.log("Running Ensemble Agent - collaborating with specialist, frontier and random forest agents") 38 | specialist = self.specialist.price(description) 39 | frontier = self.frontier.price(description) 40 | random_forest = self.random_forest.price(description) 41 | gradient_boosting = self.gradient_boosting.price(description) 42 | X = pd.DataFrame({ 43 | 'Specialist': [specialist], 44 | 'Frontier': [frontier], 45 | 'RandomForest': [random_forest], 46 | 'GradientBoosting': [gradient_boosting], 47 | 'Min': [min(specialist, frontier, random_forest)], 48 | 'Max': [max(specialist, frontier, random_forest)], 49 | }) 50 | y = max(0, self.model.predict(X)[0]) 51 | self.log(f"Ensemble Agent complete - returning ${y:.2f}") 52 | return y -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/languedocien.md: -------------------------------------------------------------------------------- 1 | # Overview of Languedocien Language 2 | 3 | ## General Information 4 | - **Language Family**: Occitan 5 | - **Region**: Primarily spoken in the Languedoc region of southern France. 6 | - **ISO Code**: Not officially assigned, but sometimes referred to as "oc" for Occitan. 7 | 8 | ## Linguistic Features 9 | - **Dialects**: Languedocien is one of the major dialects of the Occitan language, which also includes Provençal, Gascon, and Auvergnat. 10 | - **Phonetics**: Characterized by the presence of certain vowel sounds and the use of diphthongs that may differ from other dialects. 11 | - **Grammar**: Similar to other Occitan dialects, it features a subject-verb-object structure, but with unique local variations. 12 | 13 | ## Vocabulary 14 | - **Lexical Influence**: Languedocien vocabulary is heavily influenced by Latin, with a significant number of words also derived from Provençal and other regional languages. 15 | - **Regionalisms**: Contains unique words and expressions that are specific to local culture and traditions. 16 | 17 | ## Cultural Context 18 | - **Recognition**: While part of the Occitan language family, Languedocien does not have official status in France and is considered a regional language. 19 | - **Literature**: Historically used in medieval literature; notable authors include Frédéric Mistral and others who contributed to the revival of Occitan literature. 20 | 21 | ## Current Status 22 | - **Speakers**: There are an estimated few hundred thousand speakers, with numbers decreasing due to the dominance of French. 23 | - **Revitalization Efforts**: Various cultural organizations and schools aim to preserve and promote the use of Languedocien through courses, workshops, and public events. 24 | 25 | ## Geographic Distribution 26 | - **Primary Areas**: Predominantly spoken in the departments of Hérault, Aude, Gard, and parts of Lozère and Pyrénées-Orientales. 27 | - **Urban vs. Rural**: More commonly spoken in rural areas, with younger generations tending to use it less in urban settings. 28 | 29 | ## Conclusion 30 | Languedocien remains an essential part of the cultural heritage of southern France, reflecting the region's history, traditions, and linguistic diversity. Efforts to sustain and promote the language continue amidst challenges posed by modernization and globalization. -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/provencal.md: -------------------------------------------------------------------------------- 1 | # Overview of Provençal Language 2 | 3 | ## Definition 4 | Provençal is a Romance language that belongs to the Occitan language family, which is spoken primarily in the Provence region of southern France. 5 | 6 | ## Historical Background 7 | - **Origins**: Provençal has its roots in Vulgar Latin and has been influenced by various languages and cultures throughout history, including Celtic, Germanic, and Arabic. 8 | - **Literary Tradition**: It has a rich literary tradition dating back to the 11th century, with notable poets such as Frédéric Mistral contributing to its revival in the 19th century. 9 | 10 | ## Geographic Distribution 11 | - **Regions**: Primarily spoken in Provence, it also has speakers in parts of Italy and Spain, particularly in the Val d'Aran valley in Catalonia, known as Aranese. 12 | - **Dialectal Variations**: Provençal encompasses several dialects, such as Alémanique, Boulégue, and Languedocien, reflecting the linguistic diversity within the Occitan language. 13 | 14 | ## Current Status 15 | - **Recognition**: Provençal is recognized as a cultural language in France but has a minority status and faces challenges due to the dominance of French. 16 | - **Revitalization Efforts**: There are ongoing efforts to promote and teach Provençal, including in schools and cultural institutions. 17 | 18 | ## Linguistic Features 19 | - **Grammar and Syntax**: Provençal has distinct grammatical structures that differentiate it from standard French, including the use of gendered nouns and specific verb conjugations. 20 | - **Vocabulary**: It retains many words and expressions derived from Latin, along with unique local terms and influences from neighboring languages. 21 | 22 | ## Cultural Significance 23 | - **Folklore and Traditions**: Provençal is an important part of the cultural identity in Provence, associated with local traditions, music, festivals, and cuisine. 24 | - **Media and Literature**: There are books, newspapers, and online resources available in Provençal, contributing to its presence in modern media. 25 | 26 | ## Conclusion 27 | Provençal is a vibrant language with a deep historical and cultural significance in southern France. While it faces challenges, ongoing efforts for its preservation continue to foster interest and engagement in this unique linguistic heritage. -------------------------------------------------------------------------------- /week5/community-contributions/tourist-guide/style.css: -------------------------------------------------------------------------------- 1 | /* Styling for Tourist Assistant */ 2 | 3 | .container { 4 | max-width: 850px; 5 | margin: auto; 6 | background-color: rgba(255, 255, 255, 0.95); 7 | padding: 20px; 8 | border-radius: 15px; 9 | box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); 10 | } 11 | 12 | .title { 13 | text-align: center; 14 | font-size: 2.5rem !important; 15 | margin-bottom: 0.5rem; 16 | color: #2563EB; 17 | font-weight: 600; 18 | } 19 | 20 | .subtitle { 21 | text-align: center; 22 | font-size: 1.1rem !important; 23 | margin-bottom: 1.5rem; 24 | color: #4B5563; 25 | } 26 | 27 | .footer { 28 | text-align: center; 29 | margin-top: 1rem; 30 | color: #6B7280; 31 | font-size: 0.9rem !important; 32 | } 33 | 34 | .mic-container { 35 | text-align: center; 36 | margin: 1rem auto; 37 | } 38 | 39 | .clear-button { 40 | max-width: 120px; 41 | margin-left: auto; 42 | } 43 | 44 | .chatbot-container { 45 | border-radius: 10px; 46 | box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); 47 | background-color: white; 48 | } 49 | 50 | /* Styling for the microphone button */ 51 | #mic-btn { 52 | width: 150px !important; 53 | margin: 0 auto !important; 54 | } 55 | 56 | #mic-btn .wrap { 57 | display: flex; 58 | justify-content: center; 59 | } 60 | 61 | /* Make the mic button more prominent and attractive */ 62 | #mic-btn button.record-button { 63 | width: 60px !important; 64 | height: 60px !important; 65 | border-radius: 50% !important; 66 | background-color: #3B82F6 !important; 67 | color: white !important; 68 | font-size: 24px !important; 69 | display: flex !important; 70 | align-items: center !important; 71 | justify-content: center !important; 72 | margin: 0 auto !important; 73 | border: none !important; 74 | box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important; 75 | transition: all 0.2s ease !important; 76 | margin-bottom: 10px !important; 77 | } 78 | 79 | #mic-btn button.record-button:hover { 80 | transform: scale(1.05) !important; 81 | box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15) !important; 82 | } 83 | 84 | /* Hide the audio controls */ 85 | #mic-btn .audio-controls { 86 | display: none !important; 87 | } 88 | 89 | /* Hide the audio playback */ 90 | #mic-btn audio { 91 | display: none !important; 92 | } -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/normand.md: -------------------------------------------------------------------------------- 1 | # Overview of the Normand Language 2 | 3 | ## What is Normand? 4 | Normand is a regional language of France, part of the Oïl language group. It originates from the Normandy region and is historically linked to Old Norman, which developed from the Old Norman dialect of Old French. 5 | 6 | ## Geographic Distribution 7 | - Predominantly spoken in Normandy, particularly in the departments of Seine-Maritime and Calvados. 8 | - Some dialects extend into the Channel Islands (like Jersey and Guernsey), where it is closely related to Jèrriais and Guernésiais. 9 | 10 | ## Dialects 11 | Normand has several dialects, which can vary significantly in terms of vocabulary, pronunciation, and grammar. Key dialects include: 12 | - **Bocage**: Spoken in the rural areas of western Normandy. 13 | - **Mélée**: Found in the northeastern part. 14 | - **Sèvres**: A dialect with influences from the urban centers. 15 | 16 | ## Linguistic Features 17 | - Normand retains many archaic French features that have evolved in Standard French. 18 | - The pronunciation of vowels and some consonant sounds can be quite distinct from Standard French. 19 | - There are notable differences in use of articles and noun endings compared to Standard French. 20 | 21 | ## Historical Context 22 | - Norman was historically influential due to the Viking settlement of Normandy in the 9th century and subsequent Norman Conquest of England in 1066. 23 | - It was widely used by the nobility and in administrative contexts until French became more dominant post-16th century. 24 | 25 | ## Current Status 26 | - Normand is considered a minority language and has seen a decline in speakers over the years. 27 | - Efforts for revitalization are ongoing, with various cultural associations promoting the language through education and media. 28 | 29 | ## Cultural Aspects 30 | - Normand has a rich oral tradition, with folk tales, songs, and proverbs integral to the culture of Normandy. 31 | - Festivals and events celebrating Normand language and culture are held in various communities. 32 | 33 | ## Conclusion 34 | While facing challenges due to globalization and the dominance of Standard French, Normand remains an important part of the cultural heritage of Normandy. Efforts to preserve and promote the language continue, aiming to maintain its presence for future generations. -------------------------------------------------------------------------------- /week8/pricer_ephemeral.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from modal import App, Image 3 | 4 | # Setup 5 | 6 | app = modal.App("pricer") 7 | image = Image.debian_slim().pip_install("torch", "transformers", "bitsandbytes", "accelerate", "peft") 8 | secrets = [modal.Secret.from_name("hf-secret")] 9 | 10 | # Constants 11 | 12 | GPU = "T4" 13 | BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B" 14 | PROJECT_NAME = "pricer" 15 | HF_USER = "ed-donner" # your HF name here! Or use mine if you just want to reproduce my results. 16 | RUN_NAME = "2024-09-13_13.04.39" 17 | PROJECT_RUN_NAME = f"{PROJECT_NAME}-{RUN_NAME}" 18 | REVISION = "e8d637df551603dc86cd7a1598a8f44af4d7ae36" 19 | FINETUNED_MODEL = f"{HF_USER}/{PROJECT_RUN_NAME}" 20 | 21 | 22 | @app.function(image=image, secrets=secrets, gpu=GPU, timeout=1800) 23 | def price(description: str) -> float: 24 | import os 25 | import re 26 | import torch 27 | from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, set_seed 28 | from peft import PeftModel 29 | 30 | QUESTION = "How much does this cost to the nearest dollar?" 31 | PREFIX = "Price is $" 32 | 33 | prompt = f"{QUESTION}\n{description}\n{PREFIX}" 34 | 35 | # Quant Config 36 | quant_config = BitsAndBytesConfig( 37 | load_in_4bit=True, 38 | bnb_4bit_use_double_quant=True, 39 | bnb_4bit_compute_dtype=torch.bfloat16, 40 | bnb_4bit_quant_type="nf4" 41 | ) 42 | 43 | # Load model and tokenizer 44 | 45 | tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL) 46 | tokenizer.pad_token = tokenizer.eos_token 47 | tokenizer.padding_side = "right" 48 | 49 | base_model = AutoModelForCausalLM.from_pretrained( 50 | BASE_MODEL, 51 | quantization_config=quant_config, 52 | device_map="auto" 53 | ) 54 | 55 | fine_tuned_model = PeftModel.from_pretrained(base_model, FINETUNED_MODEL, revision=REVISION) 56 | 57 | set_seed(42) 58 | inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda") 59 | attention_mask = torch.ones(inputs.shape, device="cuda") 60 | outputs = fine_tuned_model.generate(inputs, attention_mask=attention_mask, max_new_tokens=5, num_return_sequences=1) 61 | result = tokenizer.decode(outputs[0]) 62 | 63 | contents = result.split("Price is $")[1] 64 | contents = contents.replace(',','') 65 | match = re.search(r"[-+]?\d*\.\d+|\d+", contents) 66 | return float(match.group()) if match else 0 67 | -------------------------------------------------------------------------------- /community-contributions/bojan-playwright-scraper/notebooks/deepmind_google_Summary.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "144bdfa2", 6 | "metadata": {}, 7 | "source": [ 8 | "\n", 9 | "# Summary for https://deepmind.google\n", 10 | "\n", 11 | "This notebook contains an AI-generated summary of the website content.\n", 12 | "\n", 13 | "**URL**: `https://deepmind.google`\n", 14 | "\n", 15 | "---\n", 16 | "**Analysis**:\n", 17 | "### Summary\n", 18 | "The website introduces \"Gemini 2.5,\" which appears to be the latest version of an AI model designed for the \"agentic era.\" The site likely focuses on promoting and explaining the capabilities and applications of this AI technology.\n", 19 | "\n", 20 | "### Entities\n", 21 | "- **Gemini 2.5**: This is the primary entity mentioned, referring to the AI model.\n", 22 | "- No specific individuals or organizations are named in the provided content.\n", 23 | "\n", 24 | "### Updates\n", 25 | "- The introduction of \"Gemini 2.5\" is a recent update, indicating a new or significantly updated version of the AI model.\n", 26 | "\n", 27 | "### Topics\n", 28 | "- **AI Models**: The site focuses on artificial intelligence technologies.\n", 29 | "- **Agentic Era**: This suggests a theme of AI models being used in ways that are proactive or autonomous.\n", 30 | "\n", 31 | "### Features\n", 32 | "- **Chat with Gemini**: This feature allows users to interact directly with the Gemini 2.5 AI, presumably to demonstrate its capabilities or to provide user support.\n", 33 | "- Detailed descriptions of other projects or initiatives are not provided in the content.\n", 34 | "\n", 35 | "**Note**: The content provided is limited, and additional information might be available on the actual website to provide a more comprehensive analysis.\n" 36 | ] 37 | } 38 | ], 39 | "metadata": { 40 | "kernelspec": { 41 | "display_name": "Python (WSL-Lakov)", 42 | "language": "python", 43 | "name": "lakov-wsl" 44 | }, 45 | "language_info": { 46 | "codemirror_mode": { 47 | "name": "ipython", 48 | "version": 3 49 | }, 50 | "file_extension": ".py", 51 | "mimetype": "text/x-python", 52 | "name": "python", 53 | "nbconvert_exporter": "python", 54 | "pygments_lexer": "ipython3", 55 | "version": "3.12.7" 56 | } 57 | }, 58 | "nbformat": 4, 59 | "nbformat_minor": 5 60 | } 61 | -------------------------------------------------------------------------------- /week2/community-contributions/medical_prescription_to_google_calender/src/ocr.py: -------------------------------------------------------------------------------- 1 | import os 2 | from openai import OpenAI 3 | from dotenv import load_dotenv 4 | import base64 5 | from PIL import Image 6 | import re 7 | 8 | load_dotenv() 9 | 10 | openai_api_key = os.getenv("OPENAI_API_KEY") 11 | 12 | MODEL = "gpt-4o" 13 | 14 | openai = OpenAI() 15 | 16 | def encode_image(image_path): 17 | with open(image_path, "rb") as image_file: 18 | return base64.b64encode(image_file.read()).decode("utf-8") 19 | 20 | def extract_text_from_image(image_path): 21 | response = openai.chat.completions.create( 22 | model = MODEL, 23 | max_tokens = 1000, 24 | messages=[ 25 | { 26 | "role": "system", "content": """You are an OCR assistant that extracts text from medical 27 | prescription images. Extract all the text exactly as it 28 | appears in the prescription image. Dont include images. Only 29 | extract text.""" 30 | }, 31 | { 32 | "role": "user", 33 | "content": [ 34 | { 35 | "type": "text", 36 | "text": "Extract text from this image: " 37 | }, 38 | { 39 | "type": "image_url", 40 | "image_url": { 41 | "url": f"data:image/jpeg;base64,{encode_image(image_path)}" 42 | } 43 | } 44 | ] 45 | } 46 | ] 47 | ) 48 | return response.choices[0].message.content 49 | 50 | import re 51 | 52 | def clean_text(text): 53 | # Remove all hyphens 54 | text = re.sub(r'-', ' ', text) 55 | 56 | # Remove excessive non-word characters but keep necessary punctuation 57 | text = re.sub(r'[^\w\s.,()%/]', '', text) 58 | 59 | # Remove multiple spaces and ensure single spaces 60 | text = re.sub(r'\s+', ' ', text) 61 | 62 | # Replace multiple newlines with a single newline 63 | text = re.sub(r'\n+', '\n', text) 64 | 65 | # Ensure spacing around punctuation marks 66 | text = re.sub(r'([.,])([^\s])', r'\1 \2', text) 67 | 68 | return text.strip() 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /week2/community-contributions/muawiya/tools.py: -------------------------------------------------------------------------------- 1 | # Let's start by making a useful function 2 | 3 | ticket_prices = {"london": "$799", "paris": "$899", "tokyo": "$1400", "berlin": "$499"} 4 | 5 | def get_ticket_price(destination_city): 6 | print(f"Tool get_ticket_price called for {destination_city}") 7 | city = destination_city.lower() 8 | return ticket_prices.get(city, "Unknown") 9 | 10 | def make_a_booking(destination_city, customer_name, customer_id): 11 | print(f"Tool make_a_booking called for {destination_city}") 12 | city = destination_city.lower() 13 | print(f"Customer name: {customer_name}, Customer ID: {customer_id}") 14 | return True 15 | 16 | # There's a particular dictionary structure that's required to describe our function: 17 | 18 | price_function = { 19 | "name": "get_ticket_price", 20 | "description": "Get the price of a return ticket to the destination city. Call this whenever you need to know the ticket price, for example when a customer asks 'How much is a ticket to this city'", 21 | "parameters": { 22 | "type": "object", 23 | "properties": { 24 | "destination_city": { 25 | "type": "string", 26 | "description": "The city that the customer wants to travel to", 27 | }, 28 | }, 29 | "required": ["destination_city"], 30 | "additionalProperties": False 31 | } 32 | } 33 | 34 | booking_function = { 35 | "name": "make_a_booking", 36 | "description": "Make a booking for a customer to a destination city. Call this when a customer wants to book a flight. You can get the customer's name and ID by directly asking the customer. For example, you can say 'What is your name?' or 'What is your ID?'", 37 | "parameters": { 38 | "type": "object", 39 | "properties": { 40 | "destination_city": { 41 | "type": "string", 42 | "description": "The city that the customer wants to travel to", 43 | }, 44 | "customer_name": { 45 | "type": "string", 46 | "description": "The name of the customer making the booking", 47 | }, 48 | "customer_id": { 49 | "type": "string", 50 | "description": "The unique identifier for the customer", 51 | } 52 | }, 53 | "required": ["destination_city", "customer_name", "customer_id"], 54 | "additionalProperties": False 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/pricer_ephemeral.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from modal import App, Image 3 | 4 | # Setup 5 | 6 | app = modal.App("pricer") 7 | image = Image.debian_slim().pip_install("torch", "transformers", "bitsandbytes", "accelerate", "peft") 8 | secrets = [modal.Secret.from_name("hf-secret")] 9 | 10 | # Constants 11 | 12 | GPU = "T4" 13 | BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B" 14 | PROJECT_NAME = "pricer" 15 | HF_USER = "ed-donner" # your HF name here! Or use mine if you just want to reproduce my results. 16 | RUN_NAME = "2024-09-13_13.04.39" 17 | PROJECT_RUN_NAME = f"{PROJECT_NAME}-{RUN_NAME}" 18 | REVISION = "e8d637df551603dc86cd7a1598a8f44af4d7ae36" 19 | FINETUNED_MODEL = f"{HF_USER}/{PROJECT_RUN_NAME}" 20 | 21 | 22 | @app.function(image=image, secrets=secrets, gpu=GPU, timeout=1800) 23 | def price(description: str) -> float: 24 | import os 25 | import re 26 | import torch 27 | from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, set_seed 28 | from peft import PeftModel 29 | 30 | QUESTION = "How much does this cost to the nearest dollar?" 31 | PREFIX = "Price is $" 32 | 33 | prompt = f"{QUESTION}\n{description}\n{PREFIX}" 34 | 35 | # Quant Config 36 | quant_config = BitsAndBytesConfig( 37 | load_in_4bit=True, 38 | bnb_4bit_use_double_quant=True, 39 | bnb_4bit_compute_dtype=torch.bfloat16, 40 | bnb_4bit_quant_type="nf4" 41 | ) 42 | 43 | # Load model and tokenizer 44 | 45 | tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL) 46 | tokenizer.pad_token = tokenizer.eos_token 47 | tokenizer.padding_side = "right" 48 | 49 | base_model = AutoModelForCausalLM.from_pretrained( 50 | BASE_MODEL, 51 | quantization_config=quant_config, 52 | device_map="auto" 53 | ) 54 | 55 | fine_tuned_model = PeftModel.from_pretrained(base_model, FINETUNED_MODEL, revision=REVISION) 56 | 57 | set_seed(42) 58 | inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda") 59 | attention_mask = torch.ones(inputs.shape, device="cuda") 60 | outputs = fine_tuned_model.generate(inputs, attention_mask=attention_mask, max_new_tokens=5, num_return_sequences=1) 61 | result = tokenizer.decode(outputs[0]) 62 | 63 | contents = result.split("Price is $")[1] 64 | contents = contents.replace(',','') 65 | match = re.search(r"[-+]?\d*\.\d+|\d+", contents) 66 | return float(match.group()) if match else 0 67 | -------------------------------------------------------------------------------- /week5/community-contributions/auto_shop.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "service_001", 4 | "content": "We offer tire services including rotation, balancing, flat repair, and new tire sales and installation.", 5 | "metadata": { 6 | "source": "service_page", 7 | "category": "tire_services", 8 | "tags": "tire, rotation, repair, installation" 9 | } 10 | }, 11 | { 12 | "id": "service_002", 13 | "content": "Brake services include pad replacement, rotor resurfacing, and ABS diagnostics.", 14 | "metadata": { 15 | "source": "service_page", 16 | "category": "brake_services", 17 | "tags": "brake, pads, rotors, abs" 18 | } 19 | }, 20 | { 21 | "id": "faq_001", 22 | "content": "Walk-ins are welcome, but appointments are recommended for faster service.", 23 | "metadata": { 24 | "source": "faq", 25 | "category": "appointments", 26 | "tags": "appointment, walk-in" 27 | } 28 | }, 29 | { 30 | "id": "faq_002", 31 | "content": "Most oil changes are completed within 30–45 minutes.", 32 | "metadata": { 33 | "source": "faq", 34 | "category": "oil_change", 35 | "tags": "oil change, duration" 36 | } 37 | }, 38 | { 39 | "id": "general_001", 40 | "content": "Pinkys Auto Care is located at Rte 112, Yorkjuh, JH 98746. We're open Monday through Friday from 8am to 6pm, and Saturday from 9am to 2pm.", 41 | "metadata": { 42 | "source": "general_info", 43 | "category": "location_hours", 44 | "tags": "location, hours, contact" 45 | } 46 | }, 47 | { 48 | "id": "promo_001", 49 | "content": "At Pinkys Auto Care, we combine modern diagnostics with friendly, small-town service. Our ASE-certified mechanics serve Springfield with over 15 years of experience.", 50 | "metadata": { 51 | "source": "about_us", 52 | "category": "branding", 53 | "tags": "promo, about us, experience" 54 | } 55 | }, 56 | { 57 | "id": "customer_query_001", 58 | "content": "My car shakes when braking—do I need new rotors?", 59 | "metadata": { 60 | "source": "user_query", 61 | "category": "brake_services", 62 | "tags": "brake, rotor, vibration" 63 | } 64 | }, 65 | { 66 | "id": "customer_query_002", 67 | "content": "Can you align wheels on a 2021 Subaru Outback?", 68 | "metadata": { 69 | "source": "user_query", 70 | "category": "wheel_alignment", 71 | "tags": "wheel alignment, vehicle-specific" 72 | } 73 | } 74 | ] 75 | -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/languages/gascon.md: -------------------------------------------------------------------------------- 1 | # Overview of the Gascon Language 2 | 3 | ## General Information 4 | - **Language Family**: Occitan branch of the Romance languages. 5 | - **Region**: Primarily spoken in the Gascony region of southwestern France, which includes parts of the departments of Gers, Landes, and Pyrénées-Atlantiques. 6 | 7 | ## Historical Context 8 | - **Origins**: Gascon evolved from Vulgar Latin and has influences from the Visigoths and various other historical invaders. 9 | - **Status**: Once a widely spoken language, Gascon has seen a decline in the number of speakers, particularly in urban areas, due to the rise of French as the dominant language. 10 | 11 | ## Dialects 12 | - **Varieties**: Gascon includes several dialects, most notably: 13 | - **Bigourdan**: Spoken in the region of Bigorre. 14 | - **Armanac**: Found in Armagnac. 15 | - **Languedocien**: This influences some Gascon speakers, particularly those in mixed-language areas. 16 | 17 | ## Linguistic Features 18 | - **Phonetics**: Gascon has unique phonetic characteristics, such as the preservation of the Latin 'u' sound and certain nasal vowels. 19 | - **Vocabulary**: Contains a wealth of regional vocabulary, along with borrowings from French, Occitan, and Basque. 20 | 21 | ## Cultural Significance 22 | - **Literature**: Historically, Gascon has been used in regional literature and songs, contributing richly to the cultural heritage of the area. 23 | - **Folklore and Traditions**: Gascon is an important vehicle for local folklore, traditions, and customs in Gascony. 24 | 25 | ## Current Status 26 | - **Revitalization Efforts**: There are ongoing efforts to promote and teach Gascon in schools, cultural organizations, and through local media. 27 | - **Number of Speakers**: As of recent estimates, the number of fluent speakers is declining, with efforts being made to preserve the language among younger generations. 28 | 29 | ## Related Languages 30 | - **Occitan**: Gascon is one of the major dialects of the Occitan language, which also includes Provençal and Languedocien. 31 | - **Comparison to French**: While Gascon shares some similarities with French, it retains distinct grammatical structures and vocabulary. 32 | 33 | ## Conclusion 34 | Gascon is not only a language but a crucial component of the cultural identity of the Gascon people, reflecting their history, traditions, and regional pride. Efforts for revitalization continue to be important in preserving this unique linguistic heritage. -------------------------------------------------------------------------------- /week2/community-contributions/AI Gold Investment Assistant/demo_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Demo test script for AI Investment Estimations assistant 4 | Test individual components before running the full Gradio interface 5 | """ 6 | 7 | import os 8 | import json 9 | from dotenv import load_dotenv 10 | 11 | # Load environment variables 12 | load_dotenv() 13 | 14 | # Test if OpenAI API key is set 15 | openai_api_key = os.getenv('OPENAI_API_KEY') 16 | if openai_api_key: 17 | print(f"✅ OpenAI API Key exists and begins with: {openai_api_key[:8]}") 18 | else: 19 | print("❌ OpenAI API Key not set - add OPENAI_API_KEY to your .env file") 20 | 21 | # Test if Metal Price API key is set (optional) 22 | metal_api_key = os.getenv('METAL_PRICE_API_KEY') 23 | if metal_api_key and metal_api_key != 'demo': 24 | print(f"✅ Metal Price API Key exists and begins with: {metal_api_key[:8]}") 25 | else: 26 | print("⚠️ Metal Price API Key not set - using demo mode (sign up at https://metalpriceapi.com/)") 27 | 28 | print("\n" + "="*50) 29 | print("Testing Gold Price Functions...") 30 | print("="*50) 31 | 32 | # Import the functions from the notebook (you'd need to copy them to a .py file) 33 | # For now, let's test with a simple demo 34 | 35 | demo_countries = ['USA', 'UK', 'Saudi Arabia', 'UAE', 'Japan'] 36 | 37 | for country in demo_countries: 38 | print(f"\nTesting gold price for: {country}") 39 | # This would call your get_gold_price function 40 | print(f" Currency mapping would convert '{country}' to appropriate currency code") 41 | print(f" Would fetch real-time price and provide investment advice") 42 | 43 | print("\n" + "="*50) 44 | print("Demo Purchase Simulation...") 45 | print("="*50) 46 | 47 | print("Simulating purchase of 2.5 ounces of gold in USD...") 48 | print("This would:") 49 | print(" 1. Get current gold price") 50 | print(" 2. Calculate total cost") 51 | print(" 3. Generate transaction ID") 52 | print(" 4. Save to gold_purchases.json file") 53 | print(" 5. Return confirmation with details") 54 | 55 | print("\n" + "="*50) 56 | print("Next Steps:") 57 | print("="*50) 58 | print("1. Make sure you have all required packages installed:") 59 | print(" pip install -r requirements_ai_investment.txt") 60 | print("2. Set up your .env file with API keys") 61 | print("3. Run the ai_investment_estimations.ipynb notebook") 62 | print("4. Test with example queries like:") 63 | print(" - 'What's the gold price in USA?'") 64 | print(" - 'Should I invest in gold now?'") 65 | print(" - 'Buy 3 ounces of gold'") -------------------------------------------------------------------------------- /week5/community-contributions/day 4 no_langchain/knowledge_collection/mountains/pyrenees.md: -------------------------------------------------------------------------------- 1 | # Overview of the Pyrenees Mountain Range 2 | 3 | ## Geographic Location 4 | - The Pyrenees mountain range forms a natural border between **France** and **Spain**. 5 | - It extends approximately **430 kilometers (267 miles)** from the Atlantic Ocean (Bay of Biscay) in the west to the Mediterranean Sea in the east. 6 | 7 | ## Major Peaks 8 | - **Aneto** is the highest peak, with an elevation of **3,404 meters (11,168 feet)**. 9 | - Other notable peaks include **Monte Perdido**, **Vignemale**, and **Pic du Midi d'Ossau**. 10 | 11 | ## Geography and Geology 12 | - The Pyrenees are divided into three sections: 13 | - **Western Pyrenees**: Characterized by rugged terrain and steep valleys. 14 | - **Central Pyrenees**: Known for its glacial landscapes and high peaks. 15 | - **Eastern Pyrenees**: Features more rounded hills and a transition to the Mediterranean landscape. 16 | - The range is primarily composed of granite, limestone, and schist rock formations. 17 | 18 | ## Climate 19 | - The climate varies from oceanic in the west to Mediterranean in the east. 20 | - Snowfall is common during the winter months, making it a popular destination for skiing and winter sports. 21 | 22 | ## Flora and Fauna 23 | - The region is home to diverse ecosystems, featuring forests, meadows, and alpine tundra. 24 | - Wildlife includes species such as the **Pyrenean ibex**, **brown bear**, **vultures**, and various endemic plants. 25 | 26 | ## Cultural Significance 27 | - The Pyrenees have a rich history, with numerous prehistoric caves, Roman ruins, and medieval castles. 28 | - The region is culturally significant for both France and Spain, with unique traditions, languages (such as **Occitan** and **Catalan**), and gastronomy. 29 | 30 | ## Outdoor Activities 31 | - The Pyrenees are a popular destination for various activities including: 32 | - **Hiking**: Numerous trails cater to different skill levels. 33 | - **Skiing and Snowboarding**: Several ski resorts like **Saint-Lary-Soulan** and **Baqueira Beret**. 34 | - **Climbing and Mountaineering**: Challenging routes attract climbers from around the world. 35 | 36 | ## National Parks 37 | - Several national parks, including **Pyrenees National Park** in France and **Ordesa y Monte Perdido National Park** in Spain, protect this stunning natural environment and its biodiversity. 38 | 39 | ## Accessibility 40 | - The Pyrenees can be accessed from various cities, including **Toulouse** and **Barcelona**, with numerous roads and hiking paths connecting different areas of the mountains. -------------------------------------------------------------------------------- /week5/knowledge-base/employees/Oliver Spencer.md: -------------------------------------------------------------------------------- 1 | # HR Record 2 | 3 | # Oliver Spencer 4 | 5 | ## Summary 6 | - **Date of Birth**: May 14, 1990 7 | - **Job Title**: Backend Software Engineer 8 | - **Location**: Austin, Texas 9 | 10 | ## Insurellm Career Progression 11 | - **March 2018**: Joined Insurellm as a Backend Developer I, focusing on API development for customer management systems. 12 | - **July 2019**: Promoted to Backend Developer II after successfully leading a team project to revamp the claims processing system, reducing response time by 30%. 13 | - **June 2021**: Transitioned to Backend Software Engineer with a broader role in architecture and system design, collaborating closely with the DevOps team. 14 | - **September 2022**: Assigned as the lead engineer for the new "Innovate" initiative, aimed at integrating AI-driven solutions into existing products. 15 | - **January 2023**: Awarded a mentorship role to guide new hires in backend technology and best practices within Insurellm. 16 | 17 | ## Annual Performance History 18 | - **2018**: **3/5** - Adaptable team player but still learning to take initiative. 19 | - **2019**: **4/5** - Demonstrated strong problem-solving skills, outstanding contribution on the claims project. 20 | - **2020**: **2/5** - Struggled with time management; fell behind on deadlines during a high-traffic release period. 21 | - **2021**: **4/5** - Made a significant turnaround with organized work habits and successful project management. 22 | - **2022**: **5/5** - Exceptional performance during the "Innovate" initiative, showcasing leadership and creativity. 23 | - **2023**: **3/5** - Maintaining steady work; expectations for innovation not fully met, leading to discussions about goals. 24 | 25 | ## Compensation History 26 | - **March 2018**: Initial salary of $80,000. 27 | - **July 2019**: Salary increased to $90,000 post-promotion. 28 | - **June 2021**: Salary raised to $105,000 after role transition. 29 | - **September 2022**: Salary adjustment to $120,000 due to increased responsibilities and performance. 30 | - **January 2023**: Revised salary of $125,000 in recognition of mentorship role. 31 | 32 | ## Other HR Notes 33 | - Oliver enjoys a strong rapport with team members and is known for organizing regular team-building activities. 34 | - Participated in Insurellm’s Hackathon in 2022, where he led a project that won “Best Overall Solution.” 35 | - Pursuing AWS Certified Solutions Architect certification to enhance cloud skillset. 36 | - Has expressed interest in further leadership opportunities within Insurellm and may consider project management roles in the future. -------------------------------------------------------------------------------- /week5/knowledge-base/employees/Alex Thomson.md: -------------------------------------------------------------------------------- 1 | # HR Record 2 | 3 | # Alex Thomson 4 | 5 | ## Summary 6 | - **Date of Birth:** March 15, 1995 7 | - **Job Title:** Sales Development Representative (SDR) 8 | - **Location:** Austin, Texas 9 | 10 | ## Insurellm Career Progression 11 | - **November 2022** - Joined Insurellm as a Sales Development Representative. Alex Thomson quickly adapted to the team, demonstrating exceptional communication and rapport-building skills. 12 | - **January 2023** - Promoted to Team Lead for special projects due to Alex's initiative in driving B2B customer outreach programs. 13 | - **August 2023** - Developed a training module for new SDRs at Insurellm, enhancing onboarding processes based on feedback and strategies that Alex Thomson pioneered. 14 | - **Current** - Continues to excel in the role, leading a small team of 5 SDRs while collaborating closely with the marketing department to identify new lead-generation strategies. 15 | 16 | ## Annual Performance History 17 | - **2022** - Rated as "Exceeds Expectations." Alex Thomson achieved 150% of the sales target within the first three months. 18 | - **2023** - Rated "Outstanding." Recognized for innovative lead-generation tactics which contributed to a 30% increase in qualified leads for the sales team. 19 | 20 | ### Highlights: 21 | - Consistently maintained a 30-minute response time to inbound leads. 22 | - Successfully coordinated webinars for product launches, which attracted over 2,000 potential customers. 23 | 24 | ## Compensation History 25 | - **2022**: Base Salary - $55,000 | Bonus - $5,000 26 | - **2023**: Base Salary - $65,000 | Bonus - $10,000 (for exceeding sales targets and exceptional teamwork) 27 | - **Projected for 2024**: Anticipated salary increase due to Alex Thomson's significant contributions and successful completion of leadership training. 28 | 29 | ## Other HR Notes 30 | - Alex Thomson is an active member of the Diversity and Inclusion committee at Insurellm and has participated in various community outreach programs. 31 | - Alex has received external training on advanced CRM usage, which has subsequently improved team efficiency and productivity. 32 | - Continuous professional development through attending sales conventions and workshops, with plans to pursue certification in Sales Enablement in 2024. 33 | - Recognized by peers for promoting a supportive and high-energy team environment, often organizing team-building activities to enhance camaraderie within the SDR department. 34 | 35 | --- 36 | **Comment:** Alex Thomson is considered a cornerstone of Insurellm’s sales team and has a bright future within the organization. -------------------------------------------------------------------------------- /week8/pricer_service.py: -------------------------------------------------------------------------------- 1 | import modal 2 | from modal import App, Image 3 | 4 | # Setup - define our infrastructure with code! 5 | 6 | app = modal.App("pricer-service") 7 | image = Image.debian_slim().pip_install("torch", "transformers", "bitsandbytes", "accelerate", "peft") 8 | 9 | # This collects the secret from Modal. 10 | # Depending on your Modal configuration, you may need to replace "hf-secret" with "huggingface-secret" 11 | secrets = [modal.Secret.from_name("hf-secret")] 12 | 13 | # Constants 14 | 15 | GPU = "T4" 16 | BASE_MODEL = "meta-llama/Meta-Llama-3.1-8B" 17 | PROJECT_NAME = "pricer" 18 | HF_USER = "ed-donner" # your HF name here! Or use mine if you just want to reproduce my results. 19 | RUN_NAME = "2024-09-13_13.04.39" 20 | PROJECT_RUN_NAME = f"{PROJECT_NAME}-{RUN_NAME}" 21 | REVISION = "e8d637df551603dc86cd7a1598a8f44af4d7ae36" 22 | FINETUNED_MODEL = f"{HF_USER}/{PROJECT_RUN_NAME}" 23 | 24 | 25 | @app.function(image=image, secrets=secrets, gpu=GPU, timeout=1800) 26 | def price(description: str) -> float: 27 | import os 28 | import re 29 | import torch 30 | from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, set_seed 31 | from peft import PeftModel 32 | 33 | QUESTION = "How much does this cost to the nearest dollar?" 34 | PREFIX = "Price is $" 35 | 36 | prompt = f"{QUESTION}\n{description}\n{PREFIX}" 37 | 38 | # Quant Config 39 | quant_config = BitsAndBytesConfig( 40 | load_in_4bit=True, 41 | bnb_4bit_use_double_quant=True, 42 | bnb_4bit_compute_dtype=torch.bfloat16, 43 | bnb_4bit_quant_type="nf4" 44 | ) 45 | 46 | # Load model and tokenizer 47 | 48 | tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL) 49 | tokenizer.pad_token = tokenizer.eos_token 50 | tokenizer.padding_side = "right" 51 | 52 | base_model = AutoModelForCausalLM.from_pretrained( 53 | BASE_MODEL, 54 | quantization_config=quant_config, 55 | device_map="auto" 56 | ) 57 | 58 | fine_tuned_model = PeftModel.from_pretrained(base_model, FINETUNED_MODEL, revision=REVISION) 59 | 60 | set_seed(42) 61 | inputs = tokenizer.encode(prompt, return_tensors="pt").to("cuda") 62 | attention_mask = torch.ones(inputs.shape, device="cuda") 63 | outputs = fine_tuned_model.generate(inputs, attention_mask=attention_mask, max_new_tokens=5, num_return_sequences=1) 64 | result = tokenizer.decode(outputs[0]) 65 | 66 | contents = result.split("Price is $")[1] 67 | contents = contents.replace(',','') 68 | match = re.search(r"[-+]?\d*\.\d+|\d+", contents) 69 | return float(match.group()) if match else 0 70 | -------------------------------------------------------------------------------- /week2/community-contributions/medical_prescription_to_google_calender/src/create_calender_events.py: -------------------------------------------------------------------------------- 1 | from googleapiclient.discovery import build 2 | from calendar_auth import authenticate_google_calender 3 | from parsing_json import format_calendar_events 4 | from datetime import datetime, timedelta 5 | 6 | def create_event(service, event_details): 7 | """Creates an event in Google Calendar.""" 8 | try: 9 | event = service.events().insert(calendarId='primary', body=event_details).execute() 10 | print(f"Event created: {event.get('htmlLink')}") 11 | except Exception as e: 12 | print(f"Error creating event: {str(e)}") 13 | 14 | def convert_time_to_24hr(time_str): 15 | """Converts time from '10:30 am' format to '10:30:00'""" 16 | if time_str and time_str.lower() != 'none': 17 | try: 18 | parsed_time = datetime.strptime(time_str, '%I:%M %p') 19 | return parsed_time.strftime('%H:%M:%S') 20 | except ValueError: 21 | return '09:00:00' 22 | return '09:00:00' 23 | 24 | def convert_to_gcal_events(formatted_events): 25 | """Converts formatted events into Google Calendar's format.""" 26 | gcal_events = [] 27 | 28 | for event in formatted_events: 29 | gcal_event = { 30 | 'summary': event['summary'], 31 | 'reminders': { 32 | 'useDefault': False, 33 | 'overrides': [{'method': 'popup', 'minutes': 10}] 34 | } 35 | } 36 | 37 | # Check if it's an all-day event (has 'date') or timed event (has 'dateTime') 38 | if 'date' in event['start']: 39 | # All-day event (like tests and follow-ups) 40 | gcal_event['start'] = { 41 | 'date': event['start']['date'], 42 | 'timeZone': 'Asia/Kolkata' 43 | } 44 | gcal_event['end'] = { 45 | 'date': event['end']['date'], 46 | 'timeZone': 'Asia/Kolkata' 47 | } 48 | else: 49 | # Timed event (like medicine schedules) 50 | start_dt = datetime.strptime(event['start']['dateTime'], '%Y-%m-%dT%H:%M:%S') 51 | end_dt = start_dt + timedelta(minutes=30) 52 | 53 | gcal_event['start'] = { 54 | 'dateTime': start_dt.isoformat(), 55 | 'timeZone': 'Asia/Kolkata' 56 | } 57 | gcal_event['end'] = { 58 | 'dateTime': end_dt.isoformat(), 59 | 'timeZone': 'Asia/Kolkata' 60 | } 61 | 62 | gcal_events.append(gcal_event) 63 | 64 | return gcal_events 65 | -------------------------------------------------------------------------------- /week1/community-contributions/week1-day1_2-bedtime-storyteller.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import argparse 5 | from dotenv import load_dotenv 6 | from openai import OpenAI 7 | 8 | def load_openai_key(): 9 | # Load environment variables in a file called .env 10 | load_dotenv(override=True) 11 | api_key = os.getenv('OPENAI_API_KEY') 12 | 13 | # Check the key 14 | if not api_key: 15 | return "Error: No API key was found!" 16 | elif not api_key.startswith("sk-proj-"): 17 | return "Error: An API key was found, but it doesn't start sk-proj-; please check you're using the right key" 18 | elif api_key.strip() != api_key: 19 | return "Error: An API key was found, but it looks like it might have space or tab characters at the start or end - please remove them!" 20 | else: 21 | return "API key found and looks good so far!" 22 | 23 | def ask_llm(client, model, user_prompt): 24 | system_prompt = """ 25 | you are a writing assistant with an expertise in children's stories. 26 | Write a bedtime story inspired by the subject below. 27 | The story should have a begining, middle, and end. 28 | The story shoukd be appropriate for children ages 5-8 and have a positive message. 29 | I should be able to read the entire story in about 3 minutes 30 | """ 31 | response = client.chat.completions.create( 32 | model = model, 33 | messages = [ {"role": "system", "content": system_prompt}, 34 | {"role": "user", "content": user_prompt}] 35 | ) 36 | return response.choices[0].message.content 37 | 38 | def main(): 39 | parser = argparse.ArgumentParser(description="AI Bedtime Storyteller") 40 | parser.add_argument("provider", choices=["openai", "ollama"], help="AI provider to use") 41 | parser.add_argument("--model", help="Model to use for Ollama (required if provider is 'ollama')", required="ollama" in parser.parse_known_args()[0].provider) 42 | parser.add_argument("subject", help="What do you want the story to be about?") 43 | 44 | args = parser.parse_args() 45 | 46 | if args.provider == "openai": 47 | load_openai_key() 48 | client = OpenAI() 49 | model = "gpt-4o-mini" 50 | elif args.provider == "ollama": 51 | client = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama') 52 | model = args.model 53 | else: 54 | return "Error: invalid provider!" 55 | 56 | user_prompt = args.subject 57 | 58 | result = ask_llm(client, model, user_prompt) 59 | print("AI Response:", result) 60 | 61 | if __name__ == "__main__": 62 | main() 63 | 64 | -------------------------------------------------------------------------------- /week8/agents/planning_agent.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, List 2 | from agents.agent import Agent 3 | from agents.deals import ScrapedDeal, DealSelection, Deal, Opportunity 4 | from agents.scanner_agent import ScannerAgent 5 | from agents.ensemble_agent import EnsembleAgent 6 | from agents.messaging_agent import MessagingAgent 7 | 8 | 9 | class PlanningAgent(Agent): 10 | 11 | name = "Planning Agent" 12 | color = Agent.GREEN 13 | DEAL_THRESHOLD = 50 14 | 15 | def __init__(self, collection): 16 | """ 17 | Create instances of the 3 Agents that this planner coordinates across 18 | """ 19 | self.log("Planning Agent is initializing") 20 | self.scanner = ScannerAgent() 21 | self.ensemble = EnsembleAgent(collection) 22 | self.messenger = MessagingAgent() 23 | self.log("Planning Agent is ready") 24 | 25 | def run(self, deal: Deal) -> Opportunity: 26 | """ 27 | Run the workflow for a particular deal 28 | :param deal: the deal, summarized from an RSS scrape 29 | :returns: an opportunity including the discount 30 | """ 31 | self.log("Planning Agent is pricing up a potential deal") 32 | estimate = self.ensemble.price(deal.product_description) 33 | discount = estimate - deal.price 34 | self.log(f"Planning Agent has processed a deal with discount ${discount:.2f}") 35 | return Opportunity(deal=deal, estimate=estimate, discount=discount) 36 | 37 | def plan(self, memory: List[str] = []) -> Optional[Opportunity]: 38 | """ 39 | Run the full workflow: 40 | 1. Use the ScannerAgent to find deals from RSS feeds 41 | 2. Use the EnsembleAgent to estimate them 42 | 3. Use the MessagingAgent to send a notification of deals 43 | :param memory: a list of URLs that have been surfaced in the past 44 | :return: an Opportunity if one was surfaced, otherwise None 45 | """ 46 | self.log("Planning Agent is kicking off a run") 47 | selection = self.scanner.scan(memory=memory) 48 | if selection: 49 | opportunities = [self.run(deal) for deal in selection.deals[:5]] 50 | opportunities.sort(key=lambda opp: opp.discount, reverse=True) 51 | best = opportunities[0] 52 | self.log(f"Planning Agent has identified the best deal has discount ${best.discount:.2f}") 53 | if best.discount > self.DEAL_THRESHOLD: 54 | self.messenger.alert(best) 55 | self.log("Planning Agent has completed a run") 56 | return best if best.discount > self.DEAL_THRESHOLD else None 57 | return None -------------------------------------------------------------------------------- /week1/community-contributions/OllamaDay1_MailSubjectLine.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "ce3db287-8661-4649-a599-cba0edd115b1", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "\n", 11 | "import os\n", 12 | "import requests\n", 13 | "from dotenv import load_dotenv\n", 14 | "from bs4 import BeautifulSoup\n", 15 | "from IPython.display import Markdown, display\n", 16 | "from openai import OpenAI\n", 17 | "\n", 18 | "openai = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')\n", 19 | "system_prompt = \"You are an assistant that analyzes the contents of an email\"\n", 20 | "user_prompt = \"Provide a short subject line which aligns with the body of the email\"\n", 21 | "email_content = \"\"\"\n", 22 | "From: TestSender@example.com\n", 23 | "To: TestReceiver@example.com\n", 24 | "Subject: \n", 25 | "\n", 26 | "Hi Team,\n", 27 | "\n", 28 | "This email provides an update on Project Alpha. We've successfully completed Phase 1, which involved, and would like to thank all the \n", 29 | "team for the great work, and looking forward to the same energy and rigor for Phase 2 too. \n", 30 | "\n", 31 | "Keep up the good work!! \n", 32 | "\n", 33 | "Thanks,\n", 34 | "James\n", 35 | "\"\"\"\n", 36 | "\n", 37 | "# Step 2: Make the messages list\n", 38 | "\n", 39 | "messages = [\n", 40 | " {\"role\": \"system\", \"content\": system_prompt},\n", 41 | " {\"role\": \"user\", \"content\": user_prompt+email_content}\n", 42 | "]\n", 43 | "\n", 44 | "# Step 3: Call OpenAI\n", 45 | "\n", 46 | "#response =\n", 47 | "response = openai.chat.completions.create(model=\"llama3.2\", messages=messages)\n", 48 | "\n", 49 | "# Step 4: print the result\n", 50 | "print(response.choices[0].message.content)\n" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": null, 56 | "id": "526b87f1-aa38-44d4-9609-292a4f4d72a9", 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [] 60 | } 61 | ], 62 | "metadata": { 63 | "kernelspec": { 64 | "display_name": "Python 3 (ipykernel)", 65 | "language": "python", 66 | "name": "python3" 67 | }, 68 | "language_info": { 69 | "codemirror_mode": { 70 | "name": "ipython", 71 | "version": 3 72 | }, 73 | "file_extension": ".py", 74 | "mimetype": "text/x-python", 75 | "name": "python", 76 | "nbconvert_exporter": "python", 77 | "pygments_lexer": "ipython3", 78 | "version": "3.11.12" 79 | } 80 | }, 81 | "nbformat": 4, 82 | "nbformat_minor": 5 83 | } 84 | -------------------------------------------------------------------------------- /week5/community-contributions/rag_chat_example/knowledge_base/mtsample_dictations/test_patient_2_f/progress_note.txt: -------------------------------------------------------------------------------- 1 | HISTORY OF PRESENT ILLNESS:, 2 | 3 | Ms. Mouse is a 67-year-old white female with a history of uterine papillary serous carcinoma who is 4 | status post 6 cycles of carboplatin and Taxol, is here today for followup. Her last cycle of chemotherapy 5 | was finished on 01/18/08, and she complains about some numbness in her right upper extremity. 6 | This has not gotten worse recently and there is no numbness in her toes. She denies any tingling or burning., 7 | 8 | REVIEW OF SYSTEMS: 9 | 10 | Negative for any fever, chills, nausea, vomiting, headache, chest pain, shortness of breath, abdominal pain, 11 | constipation, diarrhea, melena, hematochezia or dysuria. 12 | 13 | The patient is concerned about her blood pressure being up a little bit and also a mole that she had noticed for the 14 | past few months in her head. 15 | 16 | PHYSICAL EXAMINATION: 17 | 18 | VITAL SIGNS: Temperature 35.6, blood pressure 143/83, pulse 65, respirations 18, and weight 66.5 kg. 19 | GENERAL: She is a middle-aged white female, not in any distress. 20 | HEENT: No lymphadenopathy or mucositis. 21 | CARDIOVASCULAR: Regular rate and rhythm. 22 | LUNGS: Clear to auscultation bilaterally. 23 | EXTREMITIES: No cyanosis, clubbing or edema. 24 | NEUROLOGICAL: No focal deficits noted. 25 | PELVIC: Normal-appearing external genitalia. Vaginal vault with no masses or bleeding., 26 | 27 | LABORATORY DATA: 28 | 29 | None today. 30 | 31 | RADIOLOGIC DATA: 32 | 33 | CT of the chest, abdomen, and pelvis from 01/28/08 revealed status post total abdominal hysterectomy/bilateral 34 | salpingo-oophorectomy with an unremarkable vaginal cuff. No local or distant metastasis. 35 | Right probably chronic gonadal vein thrombosis. 36 | 37 | ASSESSMENT: 38 | 39 | This is a 67-year-old white female with history of uterine papillary serous carcinoma, status post total 40 | abdominal hysterectomy and bilateral salpingo-oophorectomy and 6 cycles of carboplatin and Taxol chemotherapy. 41 | She is doing well with no evidence of disease clinically or radiologically. 42 | 43 | PLAN: 44 | 45 | 1. Plan to follow her every 3 months and CT scans every 6 months for the first 2 years. 46 | 2. The patient was advised to contact the primary physician for repeat blood pressure check and get started on 47 | antihypertensives if it is persistently elevated. 48 | 3. The patient was told that the mole that she is mentioning in her head is no longer palpable and just to observe it for now. 49 | 4. The patient was advised about doing Kegel exercises for urinary incontinence, and we will address this issue again 50 | during next clinic visit if it is persistent. -------------------------------------------------------------------------------- /week5/knowledge-base/employees/Alex Chen.md: -------------------------------------------------------------------------------- 1 | # HR Record 2 | 3 | # Alex Chen 4 | 5 | ## Summary 6 | - **Date of Birth:** March 15, 1990 7 | - **Job Title:** Backend Software Engineer 8 | - **Location:** San Francisco, California 9 | 10 | ## Insurellm Career Progression 11 | - **April 2020:** Joined Insurellm as a Junior Backend Developer. Focused on building APIs to enhance customer data security. 12 | - **October 2021:** Promoted to Backend Software Engineer. Took on leadership for a key project developing a microservices architecture to support the company's growing platform. 13 | - **March 2023:** Awarded the title of Senior Backend Software Engineer due to exemplary performance in scaling backend services, reducing downtime by 30% over six months. 14 | 15 | ## Annual Performance History 16 | - **2020:** 17 | - Completed onboarding successfully. 18 | - Met expectations in delivering project milestones. 19 | - Received positive feedback from the team leads. 20 | 21 | - **2021:** 22 | - Achieved a 95% success rate in project delivery timelines. 23 | - Awarded "Rising Star" at the annual company gala for outstanding contributions. 24 | 25 | - **2022:** 26 | - Exceeded goals by optimizing existing backend code, improving system performance by 25%. 27 | - Conducted training sessions for junior developers, fostering knowledge sharing. 28 | 29 | - **2023:** 30 | - Led a major overhaul of the API internal architecture, enhancing security protocols. 31 | - Contributed to the company’s transition to a cloud-based infrastructure. 32 | - Received an overall performance rating of 4.8/5. 33 | 34 | ## Compensation History 35 | - **2020:** Base Salary: $80,000 36 | - **2021:** Base Salary Increase to $90,000; Received a performance bonus of $5,000. 37 | - **2022:** Base Salary Increase to $100,000; Performance bonus of $7,500 due to exceptional project outcomes. 38 | - **2023:** Base Salary Increase to $115,000; Performance bonus of $10,000 for leading pivotal projects. 39 | 40 | ## Other HR Notes 41 | - Participates regularly in Insurellm's Diversity & Inclusion initiatives, championing tech accessibility for underrepresented communities. 42 | - Completed several certifications in cloud architecture and DevOps, contributing to professional growth. 43 | - Plans for a professional development course in AI and machine learning to further enhance backend capabilities in Insurellm's offerings. 44 | - Acknowledged for volunteer efforts in local tech meetups, bringing seasoned engineers to mentor aspiring coders. 45 | 46 | Alex Chen continues to be a vital asset at Insurellm, contributing significantly to innovative backend solutions that help shape the future of insurance technology. -------------------------------------------------------------------------------- /week8/community_contributions/Ensemble_with_xgboost/agents/planning_agent.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, List 2 | from agents.agent import Agent 3 | from agents.deals import ScrapedDeal, DealSelection, Deal, Opportunity 4 | from agents.scanner_agent import ScannerAgent 5 | from agents.ensemble_agent import EnsembleAgent 6 | from agents.messaging_agent import MessagingAgent 7 | 8 | 9 | class PlanningAgent(Agent): 10 | 11 | name = "Planning Agent" 12 | color = Agent.GREEN 13 | DEAL_THRESHOLD = 50 14 | 15 | def __init__(self, collection): 16 | """ 17 | Create instances of the 3 Agents that this planner coordinates across 18 | """ 19 | self.log("Planning Agent is initializing") 20 | self.scanner = ScannerAgent() 21 | self.ensemble = EnsembleAgent(collection) 22 | self.messenger = MessagingAgent() 23 | self.log("Planning Agent is ready") 24 | 25 | def run(self, deal: Deal) -> Opportunity: 26 | """ 27 | Run the workflow for a particular deal 28 | :param deal: the deal, summarized from an RSS scrape 29 | :returns: an opportunity including the discount 30 | """ 31 | self.log("Planning Agent is pricing up a potential deal") 32 | estimate = self.ensemble.price(deal.product_description) 33 | discount = estimate - deal.price 34 | self.log(f"Planning Agent has processed a deal with discount ${discount:.2f}") 35 | return Opportunity(deal=deal, estimate=estimate, discount=discount) 36 | 37 | def plan(self, memory: List[str] = []) -> Optional[Opportunity]: 38 | """ 39 | Run the full workflow: 40 | 1. Use the ScannerAgent to find deals from RSS feeds 41 | 2. Use the EnsembleAgent to estimate them 42 | 3. Use the MessagingAgent to send a notification of deals 43 | :param memory: a list of URLs that have been surfaced in the past 44 | :return: an Opportunity if one was surfaced, otherwise None 45 | """ 46 | self.log("Planning Agent is kicking off a run") 47 | selection = self.scanner.scan(memory=memory) 48 | if selection: 49 | opportunities = [self.run(deal) for deal in selection.deals[:5]] 50 | opportunities.sort(key=lambda opp: opp.discount, reverse=True) 51 | best = opportunities[0] 52 | self.log(f"Planning Agent has identified the best deal has discount ${best.discount:.2f}") 53 | if best.discount > self.DEAL_THRESHOLD: 54 | self.messenger.alert(best) 55 | self.log("Planning Agent has completed a run") 56 | return best if best.discount > self.DEAL_THRESHOLD else None 57 | return None -------------------------------------------------------------------------------- /week5/knowledge-base/contracts/Contract with Roadway Insurance Inc. for Carllm.md: -------------------------------------------------------------------------------- 1 | # Contract with Roadway Insurance Inc. for Carllm 2 | 3 | --- 4 | 5 | ## Terms 6 | 7 | 1. **Agreement Effective Date**: This contract is effective as of January 1, 2025. 8 | 2. **Duration**: This agreement will remain in effect for a term of 12 months, concluding on December 31, 2025. 9 | 3. **Subscription Type**: Roadway Insurance Inc. agrees to subscribe to the **Professional Tier** of Carllm, at a cost of $2,500/month, totaling $30,000 for the duration of this contract. 10 | 4. **Payment Terms**: Payments are due on the first of each month. Late payments will incur a penalty of 1.5% per month. 11 | 5. **Termination Clause**: Either party may terminate this agreement with 30 days' written notice prior to the end of the term. If terminated early, fees will be calculated on a pro-rata basis. 12 | 13 | --- 14 | 15 | ## Renewal 16 | 17 | 1. **Automatic Renewal**: This agreement will automatically renew for an additional 12-month term unless either party provides written notice of non-renewal at least 30 days before the expiration date. 18 | 2. **Price Adjustments**: Subscription fees may be adjusted for the renewal term in accordance with market conditions and the company's pricing policies, with 60 days' prior notice provided to Roadway Insurance Inc. 19 | 20 | --- 21 | 22 | ## Features 23 | 24 | 1. **Access to Core Features**: Roadway Insurance Inc. will have access to all Professional Tier features, including: 25 | - AI-Powered Risk Assessment 26 | - Advanced Analytics & Fraud Detection 27 | - Instant Quoting System 28 | - Customizable Coverage Plans 29 | - Customer Insights Dashboard 30 | 31 | 2. **Mobile Integration**: All features will be accessible through a mobile application that Insurellm will provide. 32 | 3. **Customer Support**: Includes 24/7 automated customer support via AI chatbots and access to dedicated account management support during business hours. 33 | 34 | --- 35 | 36 | ## Support 37 | 38 | 1. **Technical Support**: Roadway Insurance Inc. will receive priority technical support from Insurellm for any issues arising from the Carllm product. 39 | 2. **Training**: Insurellm will provide up to 5 training sessions for Roadway Insurance Inc. staff on the effective use of the Carllm platform, scheduled at mutual convenience. 40 | 3. **Updates and Maintenance**: Regular updates to the Carllm platform will be conducted quarterly, and any maintenance outages will be communicated at least 48 hours in advance. 41 | 42 | --- 43 | 44 | *This contract outlines the terms of the relationship between Insurellm and Roadway Insurance Inc. for the Carllm product, emphasizing the collaborative spirit aimed at transforming the auto insurance landscape.* --------------------------------------------------------------------------------