Skip to content

100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.

refactor: Update corrective_rag to use Claude 4.5 Sonnet for LLM functionality

Shubhamsaboo4fc1412062b2
diff --git a/rag_tutorials/corrective_rag/README.md b/rag_tutorials/corrective_rag/README.md
index ae8c72a3..72921079 100644
--- a/rag_tutorials/corrective_rag/README.md
+++ b/rag_tutorials/corrective_rag/README.md
@@ -4,10 +4,10 @@ A sophisticated Retrieval-Augmented Generation (RAG) system that implements a co
## Features
- **Smart Document Retrieval**: Uses Qdrant vector store for efficient document retrieval
-- **Document Relevance Grading**: Employs Claude 3.5 sonnet to assess document relevance
+- **Document Relevance Grading**: Employs Claude 4.5 sonnet to assess document relevance
- **Query Transformation**: Improves search results by optimizing queries when needed
- **Web Search Fallback**: Uses Tavily API for web search when local documents aren't sufficient
-- **Multi-Model Approach**: Combines OpenAI embeddings and Claude 3.5 sonnet for different tasks
+- **Multi-Model Approach**: Combines OpenAI embeddings and Claude 4.5 sonnet for different tasks
- **Interactive UI**: Built with Streamlit for easy document upload and querying
## How to Run?
@@ -26,7 +26,7 @@ A sophisticated Retrieval-Augmented Generation (RAG) system that implements a co
3. **Set Up API Keys**:
You'll need to obtain the following API keys:
- [OpenAI API key](https://platform.openai.com/api-keys) (for embeddings)
- - [Anthropic API key](https://console.anthropic.com/settings/keys) (for Claude 3.5 sonnet as LLM)
+ - [Anthropic API key](https://console.anthropic.com/settings/keys) (for Claude 4.5 sonnet as LLM)
- [Tavily API key](https://app.tavily.com/home) (for web search)
- Qdrant Cloud Setup
1. Visit [Qdrant Cloud](https://cloud.qdrant.io/)
@@ -52,7 +52,7 @@ A sophisticated Retrieval-Augmented Generation (RAG) system that implements a co
- **LangChain**: For RAG orchestration and chains
- **LangGraph**: For workflow management
- **Qdrant**: Vector database for document storage
-- **Claude 3.5 sonnet**: Main language model for analysis and generation
+- **Claude 4.5 sonnet**: Main language model for analysis and generation
- **OpenAI**: For document embeddings
- **Tavily**: For web search capabilities
- **Streamlit**: For the user interface
diff --git a/rag_tutorials/corrective_rag/corrective_rag.py b/rag_tutorials/corrective_rag/corrective_rag.py
index 3746741f..2a637a91 100644
--- a/rag_tutorials/corrective_rag/corrective_rag.py
+++ b/rag_tutorials/corrective_rag/corrective_rag.py
@@ -248,7 +248,7 @@ def generate(state):
Context: {context}
Question: {question}
Answer:""", input_variables=["context", "question"])
- llm = ChatAnthropic(model="claude-3-5-sonnet-20241022", api_key=st.session_state.anthropic_api_key,
+ llm = ChatAnthropic(model="claude-sonnet-4-5", api_key=st.session_state.anthropic_api_key,
temperature=0, max_tokens=1000)
context = "\n\n".join(doc.page_content for doc in documents)
@@ -284,7 +284,7 @@ def grade_documents(state):
question = state_dict["question"]
documents = state_dict["documents"]
- llm = ChatAnthropic(model="claude-3-5-sonnet-20241022", api_key=st.session_state.anthropic_api_key,
+ llm = ChatAnthropic(model="claude-sonnet-4-5", api_key=st.session_state.anthropic_api_key,
temperature=0, max_tokens=1000)
prompt = PromptTemplate(template="""You are grading the relevance of a retrieved document to a user question.
@@ -356,7 +356,7 @@ def transform_query(state):
# Use Claude instead of Gemini
llm = ChatAnthropic(
- model="claude-3-5-sonnet-20240620",
+ model="claude-sonnet-4-5",
anthropic_api_key=st.session_state.anthropic_api_key,
temperature=0,
max_tokens=1000