Spaces:
Sleeping
Sleeping
changed the response
Browse files- phase1_agents.py +24 -9
phase1_agents.py
CHANGED
|
@@ -33,7 +33,8 @@ company_search_agent = Agent(
|
|
| 33 |
|
| 34 |
def search_company(company_name: str):
|
| 35 |
query = f"Find detailed company information for {company_name}. Extract its official website, mission, services, and any AI-related initiatives. Prioritize official sources and provide links where available."
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
##############################
|
|
@@ -48,8 +49,8 @@ firecrawl_agent = Agent(
|
|
| 48 |
)
|
| 49 |
|
| 50 |
def scrape_website(url: str):
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
| 54 |
##############################
|
| 55 |
# 3️⃣ Text Processing Agent #
|
|
@@ -64,8 +65,8 @@ text_processing_agent = Agent(
|
|
| 64 |
)
|
| 65 |
|
| 66 |
def process_company_description(text: str):
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
#################################
|
| 71 |
# 4️⃣ Document Processing Agent #
|
|
@@ -75,6 +76,8 @@ embedding_model = OpenAIEmbedder(model="text-embedding-3-small")
|
|
| 75 |
dimension = 1536 # OpenAI's embedding dimension
|
| 76 |
faiss_index = faiss.IndexFlatL2(dimension)
|
| 77 |
|
|
|
|
|
|
|
| 78 |
def process_uploaded_document(file: UploadFile):
|
| 79 |
file_path = f"tmp/{file.filename}"
|
| 80 |
with open(file_path, "wb") as buffer:
|
|
@@ -83,8 +86,20 @@ def process_uploaded_document(file: UploadFile):
|
|
| 83 |
with open(file_path, "r", encoding="utf-8") as f:
|
| 84 |
document_text = f.read()
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
|
|
|
| 33 |
|
| 34 |
def search_company(company_name: str):
|
| 35 |
query = f"Find detailed company information for {company_name}. Extract its official website, mission, services, and any AI-related initiatives. Prioritize official sources and provide links where available."
|
| 36 |
+
response = company_search_agent.run(query)
|
| 37 |
+
return response.content
|
| 38 |
|
| 39 |
|
| 40 |
##############################
|
|
|
|
| 49 |
)
|
| 50 |
|
| 51 |
def scrape_website(url: str):
|
| 52 |
+
response = firecrawl_agent.run(f"Extract all relevant business information from {url}, including mission statement, services, case studies, and AI-related content. Provide structured output.")
|
| 53 |
+
return response.content
|
| 54 |
|
| 55 |
##############################
|
| 56 |
# 3️⃣ Text Processing Agent #
|
|
|
|
| 65 |
)
|
| 66 |
|
| 67 |
def process_company_description(text: str):
|
| 68 |
+
response = text_processing_agent.run(f"Summarize the following company description: {text}. Focus on key services, mission, industry, and potential AI use cases where applicable.")
|
| 69 |
+
return response.content
|
| 70 |
|
| 71 |
#################################
|
| 72 |
# 4️⃣ Document Processing Agent #
|
|
|
|
| 76 |
dimension = 1536 # OpenAI's embedding dimension
|
| 77 |
faiss_index = faiss.IndexFlatL2(dimension)
|
| 78 |
|
| 79 |
+
|
| 80 |
+
|
| 81 |
def process_uploaded_document(file: UploadFile):
|
| 82 |
file_path = f"tmp/{file.filename}"
|
| 83 |
with open(file_path, "wb") as buffer:
|
|
|
|
| 86 |
with open(file_path, "r", encoding="utf-8") as f:
|
| 87 |
document_text = f.read()
|
| 88 |
|
| 89 |
+
# Optionally, you can generate an embedding if needed, but return the raw content for further phases.
|
| 90 |
+
return document_text # Return the processed document text
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# def process_uploaded_document(file: UploadFile):
|
| 94 |
+
# file_path = f"tmp/{file.filename}"
|
| 95 |
+
# with open(file_path, "wb") as buffer:
|
| 96 |
+
# buffer.write(file.file.read())
|
| 97 |
+
|
| 98 |
+
# with open(file_path, "r", encoding="utf-8") as f:
|
| 99 |
+
# document_text = f.read()
|
| 100 |
+
|
| 101 |
+
# # Generate embedding
|
| 102 |
+
# embedding = np.array(embedding_model.embed([document_text])).astype("float32")
|
| 103 |
+
# faiss_index.add(embedding)
|
| 104 |
|
| 105 |
+
# return f"Document processed and stored in FAISS index: {file.filename}"
|