# πŸš€ Infection AI Cookbook - Your Ultimate Guide to AI-Powered Applications! πŸš€ ## 🌟 Welcome to the **Infection AI Cookbook** πŸ€–βœ¨ Hey there, AI enthusiast! πŸ€–βœ¨ Ready to dive into the world of **Inflection AI** and supercharge your projects? [This repository](https://github.com/Inflection-Ops/inflection-ai-cookbook) is your all-in-one guide, packed with fun, practical, and powerful AI use cases! Whether you're automating workflows, classifying documents, generating intelligent responses, or building AI-powered applications, we've got you covered! --- ## πŸ“œπŸ“Œ **What’s Inside?** πŸ“œπŸ“Œ This cookbook contains a collection of hands-on notebooks showcasing how to use **Inflection AI** to solve real-world problems. Here’s what you’ll find inside: ### 🎬 **Getting Started: Chat Completions** 🎬 - Uses OpenAI Client with and without streaming - Uses HTTP Requests with and without streaming - Example: [chat_completions.ipynb](examples/chat_completions.ipynb) ### 🚦 **Intent Recognition for Service Routing** 🚦 - Uses **Chain-of-Thought (CoT) reasoning** for smarter intent classification. - Extracts **user intent** & provides structured XML outputs. - Optimized for **Inflection 3 Productivity Model** to ensure top-notch accuracy. - Example: [intent_recognition.ipynb](examples/intent_recognition.ipynb) ### πŸ“‚ **Document Classification** πŸ“‚ - Sorts documents into categories like **Statement of Work (SOW) or Other** - Uses **instruction-based prompting** to ensure consistency & reliability. - Generates **structured XML outputs** for seamless automation. - Example: [classification.ipynb](examples/classification.ipynb) ### πŸ’» **Code Generation for Automated Development** πŸ’» - Generates **Python & SQL** code automatically! - Uses **Inflection 3 Productivity model** for high-quality, structured output. - Ensures best practices in readability, maintainability & efficiency. - Example: [code_generation.ipynb](examples/code_generation.ipynb) ### ❀️ **Emotional Intelligence in Social Media Responses** ❀️ - Detects **emotional tone** in messages & adjusts response accordingly. - Improves user engagement & sentiment alignment. - Generates **empathetic, adaptive replies** to enhance brand communication. - Example: [emotional_intelligence.ipynb](examples/emotional_intelligence.ipynb) ### 🧠 **Few-Shot Learning for Smart Adaptation** 🧠 - Learns from just a few examples for **quick, efficient generalization**. - Adapts to different tasks with minimal labeled data. - Uses **prompt-based fine-tuning** for accurate predictions. - Example: [few_shot_learning.ipynb](examples/few_shot_learning.ipynb) ### βš™οΈ **Function Calling with Structured API Queries** βš™οΈ - Automates **API calls** with structured function execution. - Ensures consistent, interpretable, and adaptable API interactions. - Example: [function_calling.ipynb](examples/function_calling.ipynb) ### 🧐 **Retrieval-Augmented Generation (RAG) for Context-Aware AI Agents**🧐 - Enhances AI reasoning by retrieving **relevant knowledge** before responding. - Ensures AI-generated responses are **context-rich & accurate**. - Example: [rag_enabled_agents.ipynb](examples/rag_enabled_agents.ipynb) ### πŸ“œ **Automated Specification Validation** πŸ“œ - Ensures **compliance & correctness** in software development. - Extracts key compliance criteria & identifies inconsistencies. - Outputs **structured validation reports** for review. - Example: [specs_validation.ipynb](examples/specs_validation.ipynb) ### πŸ“… **Meeting Scheduling with JSON Output** πŸ“… - Extracts meeting details like **date, duration, participants, and topics**. - Handles relative dates (e.g., "next Friday") dynamically. - Outputs structured **JSON format** for seamless scheduling automation. - Example: [structured_output_json.ipynb](examples/structured_output_json.ipynb) ### πŸ— **Structured Output Generation with XML Formatting** πŸ— - Converts AI responses into **structured XML format**. - Ensures **validity, consistency, and seamless data integration**. - Perfect for **automation pipelines & interoperability**. - Example: [structured_output_xml.ipynb](examples/structured_output_xml.ipynb) ### πŸ§ͺ **Automated Testing with Inflection AI** πŸ§ͺ - **Automates testing** of Inflection LLM outputs. - Ensures **high coverage and reliability** in software testing. - Generates structured test reports for easy analysis and debugging. --- ## 🏁 **Getting Started with Inflection AI** 🏁 In early 2025, we release a version of our inference API that adheres to the OpenAI API specs. This will allow you to use OpenAI client, available in the python OpenAI client library, to call our models and makes it easy to leverage them in advanced frameworks like Langchain, LlamaIndex, CrewAI...etc. without additional customization. In most of the examples provided in this cookbook, you can switch between the legacy API and the new OpenAI compatible API by setting variable ***legacy_api*** ```bash legacy_api = False # True if using the old API, False if using the new OpenAI compatible API ``` ### Inflection-3 Models Inflection-3 comprises two models designed for distinct purposes: - **Pi (3.0)**: The model powering our Pi experience, including a backstory, emotional intelligence, productivity, and safety. It excels in scenarios such as customer support chatbots. Set the config field in the API request JSON to `inflection_3_pi` to use this model. - **Productivity (3.0)**: The model optimized for following instructions. It is better for tasks requiring JSON output or precise adherence to provided guidelines. Set the config field in the API request JSON to `inflection_3_productivity` to use this model. ### Context Window Both models currently support an 8k context window. To run these examples, you’ll need an **Inflection AI Developers Account** and an API key. Follow these steps to get started: 1️⃣ **Sign Up & Get Your API Key** πŸ”‘ πŸ‘‰ [Sign up here](https://developers.inflection.ai/login) using Google or GitHub. πŸ‘‰ Navigate to the **API Keys** section and create a new key. 2️⃣ **Read the API Docs** πŸ“– πŸ‘‰ Check out the official [Inflection AI API Docs](https://developers.inflection.ai/docs) to understand usage and best practices. 3️⃣ **Authenticate Your Requests** πŸ” 4️⃣ **Create a .env file and asign your key to INFLECTION_API_KEY**πŸ” BASE_URL=https://layercake.pubwestus3.inf7ks8.com INFLECTION_API_KEY=XXXXX GROQ_API_KEY=XXXXX The first parameter is the base url for the Inflection AI API you will be using. The second parameter is your API key and you need to replace XXXXX with the key you created in step 1️⃣ The third parameter is your Groq API key and only needed if you're running the tests in examples/tests (not needed for the examples in the Jupyter notebooks) Include your API key in all requests using the `Authorization` header: ```bash curl --location 'https://layercake.pubwestus3.inf7ks8.com/external/api/inference' \\ --header 'Authorization: Bearer ' \\ --header 'Content-Type: application/json' \\ --data '{ "context": [ { "text": "Hi", "type": "Human" } ], "config": "inflection_3_pi" }' ``` ## Dependencies Install the dependencies below in your virtual environment using ```bash pip install requirements.txt ``` - aiohttp - requests - python_dotenv - openai - numpy - scipy - transformers - torch - tiktoken --- ## 🀝 **Join the Community & Get Support** 🀝 πŸ’‘ **Questions? Issues? Need help?** Head over to: - πŸ“š [Inflection AI Docs](https://developers.inflection.ai/docs) for detailed guides. - πŸ— [Inflection AI Playground](https://developers.inflection.ai/playground) to test models interactively. - πŸ›Ÿ [Contact Us] developer_support@inflection.ai - πŸ† Join our AI community and share your projects! πŸš€ **Start Building with Inflection AI Today!** πŸš€ ✨ Happy Coding! ✨