(self, documents, temperature=0.7, top_k=3, model_name=None, embedding_model=None)
| 172 | # Define main class |
| 173 | class SelfRAG: |
| 174 | def __init__(self, documents, temperature=0.7, top_k=3, model_name=None, embedding_model=None): |
| 175 | self.vectorstore = encode_documents(documents=documents, embedding_model=embedding_model) |
| 176 | self.top_k = top_k |
| 177 | self.llm = _get_chat_openai(model_name or "gpt-4o-mini", temperature=temperature, max_tokens=1000) |
| 178 | |
| 179 | # Create LLMChains for each step |
| 180 | self.retrieval_chain = retrieval_prompt | self.llm.with_structured_output(RetrievalResponse) |
| 181 | self.relevance_chain = relevance_prompt | self.llm.with_structured_output(RelevanceResponse) |
| 182 | self.generation_chain = generation_prompt | self.llm.with_structured_output(GenerationResponse) |
| 183 | self.support_chain = support_prompt | self.llm.with_structured_output(SupportResponse) |
| 184 | self.utility_chain = utility_prompt | self.llm.with_structured_output(UtilityResponse) |
| 185 | self.start_time = time.time() |
| 186 | |
| 187 | |
| 188 | def run(self, query): |
nothing calls this directly
no test coverage detected