Sequential Prompts from Original RAG with aider and Claude 3.5 Sonnet Tutorial
Prompt: Use the LangChain RAG tutorial documentation, which I provided to you previously, to generate a simple RAG app in Python that uses the LangChain v0.2 framework. The app will allow the user to provide the URL for a web page and ask questions related to the contents of the page. The user interface will be the command line for now. The app should use OpenAI models and APIs. Generate all the required files, functions, methods, imports, etc. but don't implement any functions yet. Instead, just insert comments. Also, generate the Python requirements.txt file. Only implement the features I've requested.
Prompt: Implement the loading of a web page. Let the user provide the URL to be loaded. Print the contents of the page to the console. Leave the rest of the code as is.
Prompt: Generate the implementation for loading the web page contents into the vector store. Leave the rest of the code as is.
Prompt: Implement the code required to complete the retrieval chain and allow the user to ask questions based on the web page content that's been stored in the vector database. Use GPT 4o (gpt-4o) as the chat LLM.
Prompt: Add a simple Streamlit UI for this app that allows the user to do the same things they can currently do from the command line, but in a web browser. Also, give me instructions for running the Streamlit UI.
Prompt: Add more color to the UI. I want to see some blues and purples, with a splash of red.
===================
NEW "uber" Single-shot prompt for New aider, Cursor, Windsurf Tutorial
You will build a Retrieval-Augmented Generation (RAG) app using the LangChain framework in Python. The app will use the provided LangChain RAG tutorial documentation, which contains the most current API references, code samples, and library details. Your solution must adhere to the relevant approaches and patterns described in that documentation, overriding any conflicting prior knowledge.
The app should allow users to input a web page URL, load all page content, store it in a vector database, and ask questions based on the content via a user-friendly Streamlit web interface. All AI features must be implemented using OpenAI models, specifically GPT-4 Turbo (gpt-4-turbo), and must comply with the listed dependencies and library versions.
- Use Python version 3.11
- Use the below library dependencies, without version specifiers to get the latest stable versions:
- beautifulsoup4
- langchain
- langchain-community
- langchain-openai
- langchain-chroma
- python-dotenv
- streamlit
- Assume the developer will create a Python virtual environment using the python -m venv method to isolate dependencies
- Generate a requirements.txt file specifying all necessary dependencies
- Load complete contents of a web page from a user-provided URL
- Display the contents of the web page in the UI for confirmation
- Store the web page content in a ChromaDB vector database for efficient retrieval
- The database and previously stored data must persist across user sessions
- Allow users to ask questions based on the stored content using GPT-4 Turbo
- Use LangChain's retrieval chain mechanism for querying the vector database
- Create a web-based interface for the app:
- Input fields for the web page URL and user questions
- Buttons for loading content, storing it in the vector database, and running queries
- Display areas for web page content and query results
- Incorporate a visually appealing design with the following style guidelines:
- Blues and purples as the primary colors
- A splash of red for accents (e.g., buttons or headings)
- Clean, user-friendly layout
- The solution should be modular, with components logically separated to improve maintainability and reusability
- Avoid placing all code into a single file; instead, organize it into multiple modules or files as appropriate
- Generate all required files, functions, methods, imports, and code
- Fully implement the app, including backend logic and UI components
- Ensure clear inline comments explaining key parts of the code
- Do not implement features beyond those described here
- Ensure the LLM answers questions based only on the knowledge provided by the loaded web page content stored in the vector database
- Follow best practices for maintainable and modular code
- Use the documentation to ensure compatibility with the latest LangChain APIs and provided library versions
Output the complete project structure, including:
- Python scripts with implemented code
- A requirements.txt file
- Inline comments explaining the functionality of the app
- Follow the provided LangChain documentation meticulously. If you encounter ambiguities or unsupported patterns in your training data, default to the methods specified in the documentation
- Use the specified dependencies and library versions in all implementations
- Ensure the app is logically structured, modular, and easy to maintain
@adamraine