streamlit # 🎨 Build interactive web apps: st.title("Hello"), st.button("Click"), st.image("pic.png") # 📊 Display data: st.dataframe(df), st.plotly_chart(fig), st.write("Text") # 🚀 Create UI: st.slider("Range", 0, 100), st.selectbox("Choose", options), st.file_uploader("Upload") asyncio # 🔄 Run async tasks: await asyncio.sleep(1), asyncio.run(main()), asyncio.gather(*tasks) # 🌐 Handle coroutines: async def fetch(), await coro(), asyncio.create_task(func()) # ⏳ Manage event loops: loop = asyncio.get_event_loop(), loop.run_until_complete(), asyncio.ensure_future() websockets # 🌐 WebSocket server: async with websockets.serve(handler, "localhost", 8765): await asyncio.Future() # 📡 Client connect: async with websockets.connect("ws://localhost:8765") as ws: await ws.send("Hi") # 🔊 Real-time comms: async for msg in ws: print(msg), await ws.recv(), ws.send("Response") pillow # 🖼️ Load images: img = Image.open("file.png"), img.resize((100, 100)), img.save("out.png") # 🎨 Process images: img.convert("RGB"), ImageDraw.Draw(img).text((10, 10), "Hello"), img.rotate(90) # 📸 Manipulate: img.crop((0, 0, 50, 50)), img.filter(ImageFilter.BLUR), img.thumbnail((50, 50)) edge_tts # 🎙️ Text-to-speech: comm = edge_tts.Communicate("Hello", "en-US-AriaNeural"), await comm.save("out.mp3") # 🔊 Customize voice: edge_tts.Communicate(text, voice="en-GB-SoniaNeural", rate="+10%"), await comm.save() # 📢 Generate audio: async def speak(text): await edge_tts.Communicate(text, "en-US-GuyNeural").save("file.mp3") audio-recorder-streamlit # 🎤 Record audio: audio_bytes = audio_recorder(), st.audio(audio_bytes, format="audio/wav") # 🔉 Capture voice: if audio_bytes: process_audio(audio_bytes), st.write("Recording...") # 📥 Save recording: with open("recording.wav", "wb") as f: f.write(audio_recorder()) nest_asyncio # 🔧 Fix nested loops: nest_asyncio.apply(), asyncio.run(main()), loop.run_until_complete(coro()) # 🌐 Enable async in sync: nest_asyncio.apply() before asyncio.run() in Jupyter/Streamlit # ⏳ Patch event loop: import nest_asyncio; nest_asyncio.apply() for multiple event loops streamlit-paste-button # 📋 Paste images: result = paste_image_button("Paste"), if result.image_data: st.image(result.image_data) # ✂️ Capture clipboard: paste_data = paste_image_button("Click"), st.write(paste_data.text_data) # 🖼️ Process paste: if paste_image_button("Paste").image_data: save_image(result.image_data) pypdf2 # 📜 Read PDFs: reader = PdfReader("file.pdf"), text = reader.pages[0].extract_text(), num_pages = len(reader.pages) # 📝 Extract text: for page in PdfReader("doc.pdf").pages: st.write(page.extract_text()) # 📚 Parse PDF: pdf = PdfReader(open("file.pdf", "rb")), st.write(pdf.metadata), page_count = len(pdf.pages) anthropic # 🤖 AI responses: client = anthropic.Anthropic(api_key="key"), resp = client.messages.create(model="claude-3", messages=[...]) # 📢 Claude chat: msg = client.messages.create(model="claude-3-sonnet", max_tokens=1000, messages=[{"role": "user", "content": "Hi"}]) # 🔍 Query AI: response = client.completions.create(model="claude-2", prompt="Hello", max_tokens_to_sample=512) openai # 🧠 GPT queries: client = openai.OpenAI(api_key="key"), resp = client.chat.completions.create(model="gpt-4", messages=[...]) # 📝 Generate text: completion = openai.Completion.create(model="text-davinci-003", prompt="Write a story", max_tokens=100) # 🔊 AI chat: chat = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello"}]) gradio-client # 🌐 Call Gradio APIs: client = Client("user/repo"), result = client.predict("input", api_name="/predict") # 📡 Remote inference: prediction = Client("awacke1/Arxiv-Paper-Search").predict("query", 10, "search", "model") # 🔍 Fetch results: resp = client.predict(param1, param2, api_name="/endpoint"), st.write(resp) python-dotenv # 🔑 Load env vars: load_dotenv(), api_key = os.getenv("API_KEY"), st.write(os.getenv("SECRET")) # 🌍 Config from .env: from dotenv import load_dotenv; load_dotenv(); db_url = os.getenv("DB_URL") # 📋 Secure secrets: load_dotenv(".env"), token = os.getenv("TOKEN"), client = SomeClient(token) streamlit-marquee # 🎥 Scrolling text: streamlit_marquee(content="Hello", background="#000", color="#FFF", font-size="20px") # 📣 Dynamic marquee: streamlit_marquee(content="News", animationDuration="10s", width="100%") # 🌈 Styled ticker: streamlit_marquee(content="Update", background="#1E1E1E", lineHeight="30px")