Spaces:
Sleeping
Sleeping
File size: 4,085 Bytes
1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 5551822 1e6d8a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | # import os
# import sys
# import asyncio
# sys.path.append(os.getcwd())
# from dotenv import load_dotenv
# load_dotenv()
# from logger import *
# import logging
# from src.MultiRag.pipeline.run_pipeline import RunPipeline
# from src.MultiRag.models.rag_model import Content
# from src.MultiRag.components.content_embedder import ContentEmbedder
# from src.MultiRag.entity.config_entity import ContentEmbedderConfig
# import os
# # ============= generating retreivers ===========================
# async def generate_retreivers(thread_id):
# for file in os.listdir("docs"):
# logging.info(f"Processing file: {file}")
# content_embedder_config = ContentEmbedderConfig(
# file_path=f"docs/{file}",
# vector_store_path=f"db/{thread_id}/{file}", # Updated path structure
# )
# component = ContentEmbedder(content_embedder_config=content_embedder_config)
# retreiver = await component.embed_content()
# logging.info(f"Generated retreiver for {file}: {retreiver}")
# # ============= testing pdf query loading =======================
# async def pdf_test():
# run_pipeline = RunPipeline()
# # Mocking user uploaded files
# temp_user_content = [
# Content(
# name="AI_Intro.pdf",
# about="An introductory document about Artificial Intelligence and Machine Learning.",
# path="docs/AI_Intro.pdf"
# )
# ]
# res = await run_pipeline.initiate(
# thread_id="1",
# query="What does the AI_Intro.pdf say about Neural Networks? Use the pdf",
# userContent=temp_user_content
# )
# logging.info(f"Final Pipeline Response: {res}")
# # ============= testing txt query loading =======================
# async def txt_test():
# run_pipeline = RunPipeline()
# # Mocking user uploaded files
# temp_user_content = [
# Content(
# name="growing_ai_tools.txt",
# about="General notes about growing AI tools.",
# path="docs/growing_ai_tools.txt"
# )
# ]
# res = await run_pipeline.initiate(
# thread_id="1",
# query="What does the growing_ai_tools.txt say about AI tools? use the txt file",
# userContent=temp_user_content
# )
# logging.info(f"Final Pipeline Response: {res}")
# # ============= testing docs query loading =======================
# async def docx_test():
# run_pipeline = RunPipeline()
# # Mocking user uploaded files
# temp_user_content = [
# Content(
# name="google.docx",
# about="General notes about company Google.",
# path="docs/google.docx"
# )
# ]
# res = await run_pipeline.initiate(
# thread_id="1",
# query="What does the google.docx say about Google? use the docx file",
# userContent=temp_user_content
# )
# logging.info(f"Final Pipeline Response: {res}")
# # ============= testing image query loading =======================
# async def image_test():
# run_pipeline = RunPipeline()
# # Mocking user uploaded files
# temp_user_content = [
# Content(
# name="lena.png",
# about="An image of a girl.",
# path="docs/lena.png"
# )
# ]
# res = await run_pipeline.initiate(
# thread_id="1",
# query="What does the lena.png say about the girl? use the image file",
# userContent=temp_user_content
# )
# logging.info(f"Final Pipeline Response: {res}")
# # ============== Running all the tests =============================
# async def main():
# logging.info("Starting generating retreivers...")
# await generate_retreivers(thread_id="1")
# logging.info("Retreivers generated successfully. Starting pipeline tests...")
# logging.info("Starting pipeline tests...")
# await pdf_test()
# await txt_test()
# await docx_test()
# await image_test()
# logging.info("Pipeline tests completed.")
# asyncio.run(main()) |