Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammedNasserAhmed authored Jan 14, 2025
1 parent 0cbdab4 commit b83b56e
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions codexpert/app.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
from codeexp.pipeline.rag_pipeline import CodeAnalysisPipeline
import logging
from codeexp.pipeline.rag_pipeline import CodeAnalysisPipeline

# Configure logging
logging.basicConfig(level=logging.INFO)

def main():
pipeline = CodeAnalysisPipeline()

pipeline = CodeAnalysisPipeline()
try:
phase_name = "Load and preprocess documents"
logging.info(f">>>>>> phase {phase_name} started <<<<<<")
pipeline.load_and_preprocess_documents()
except Exception as e:
logging.error(f"Error in phase {phase_name}: {e}")
return

PHASE_NAME= "Load and preprocess documents"
logging.info(f">>>>>> phase {PHASE_NAME} started <<<<<<")
pipeline.load_and_preprocess_documents()
try:
phase_name = "Create embeddings and vector store"
logging.info(f">>>>>> phase {phase_name} started <<<<<<")
pipeline.create_embeddings_and_vector_store()
except Exception as e:
logging.error(f"Error in phase {phase_name}: {e}")
return

PHASE_NAME= "Create embeddings and vector store"
logging.info(f">>>>>> phase {PHASE_NAME} started <<<<<<")
pipeline.create_embeddings_and_vector_store()
try:
phase_name = "Initialize QA chain and explanation chain"
logging.info(f">>>>>> phase {phase_name} started <<<<<<")
pipeline.initialize_qa_chain()
pipeline.initialize_agent_and_explanation_chain()
except Exception as e:
logging.error(f"Error in phase {phase_name}: {e}")
return

PHASE_NAME = "Initialize QA chain and explanation chain"
logging.info(f">>>>>> phase {PHASE_NAME} started <<<<<<")
pipeline.initialize_qa_chain()
pipeline.initialize_agent_and_explanation_chain()
try:
phase_name = "Process user query"
logging.info(f">>>>>> phase {phase_name} started <<<<<<")
user_query = "Explain the purpose of the provided code" # Consider getting this from a config file or environment variable
if user_query:
pipeline.process_query(user_query)
except Exception as e:
logging.error(f"Error in phase {phase_name}: {e}")
return

PHASE_NAME = "Process user query"
logging.info(f">>>>>> phase {PHASE_NAME} started <<<<<<")
user_query = "Explain the purpose of the provided code"
if user_query:
pipeline.process_query(user_query)
if __name__ == "__main__":
main()

0 comments on commit b83b56e

Please sign in to comment.