Team Ai
Apppublic

MD2204/multi_modality

sourceHugging Faceupdated 8mo agoView on Hugging Face
1likes
rag.cpython-310.pyc20 linesDownload Raw Back to __pycache__
1o

2��wi��@s`ddlmZddlmZddlmZddlmZddlm	Z	defdd�Z3d	ed4efdd�Zd
S)�)�RetrievalQA)�PromptTemplate)�
BaseRetriever)�
BaseChatModel)�RETRIEVER_K�returncCs|jdddid�S)zEGet retriever from vector store with higher K for multimodal context.�5similarity�k�)�search_type�
search_kwargsN)�as_retriever)�vectorstore�r�GC:\Users\MoEdBouk\Desktop\AI ENGENEER PATH\multimodality_RAG\src\rag.py�
get_retrievers�r�llm�	retrievercCs0d}t|ddgd�}tj|d|dd|id�}|S)6z$Create a multimodal-aware RAG chain.aBYou are a highly capable AI Assistant. Use ONLY the provided context to answer the user's question. Do not use any external knowledge about the DeepSeek paper or Reinforcement Learning results.7 8CRITICAL INSTRUCTIONS:9- Some context blocks are marked as [Visual Data Transcription]. These contain data extracted from images, charts, and tables. Treat these as the absolute source of truth.10- If the user asks for specific values, read the row and column of the Markdown tables exactly.11- Numeric Format Check: Ensure the numbers you report match the scale in the context (e.g., if the context shows thousands like 6500, do not report decimals like 0.65).12- If the answer is not in the context, say "I don't know based on the provided data." Do not guess or use memory.13 14    Context:15    {context}16 17    Question: {question}18    Answer:�context�question)�templateZinput_variables�stuffT�prompt)rZ19chain_typerZreturn_source_documentsZchain_type_kwargsN)rrZfrom_chain_type)rr�prompt_template�PROMPT�qa_chainrrr�create_rag_chains��rN)Zlangchain_classic.chainsr�langchain_core.promptsr�langchain_core.retrieversrZlangchain_core.language_modelsr�20src.configrrrrrrr�<module>s