mirror of
https://github.com/Shubhamsaboo/awesome-llm-apps.git
synced 2026-05-30 07:50:23 +00:00
refactor: Update corrective_rag to use Claude 4.5 Sonnet for LLM functionality
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user