Spaces:
Sleeping
Sleeping
Commit
·
9e8b261
1
Parent(s):
61a4f47
updated .pyc files
Browse files- __pycache__/main.cpython-312.pyc +0 -0
- brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc +0 -0
- brainstroming_agent/utils/__pycache__/validators.cpython-312.pyc +0 -0
- brainstroming_agent/utils/tools.py +6 -22
- brainstroming_agent/utils/validators.py +0 -22
- business_interaction_agent/__pycache__/agent.cpython-312.pyc +0 -0
- business_interaction_agent/utils/__pycache__/utils.cpython-312.pyc +0 -0
- business_interaction_agent/utils/utils.py +11 -23
- utils/__pycache__/data_loader.cpython-312.pyc +0 -0
- utils/__pycache__/models_loader.cpython-312.pyc +0 -0
__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ
|
|
|
brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc
CHANGED
|
Binary files a/brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc and b/brainstroming_agent/utils/__pycache__/tools.cpython-312.pyc differ
|
|
|
brainstroming_agent/utils/__pycache__/validators.cpython-312.pyc
CHANGED
|
Binary files a/brainstroming_agent/utils/__pycache__/validators.cpython-312.pyc and b/brainstroming_agent/utils/__pycache__/validators.cpython-312.pyc differ
|
|
|
brainstroming_agent/utils/tools.py
CHANGED
|
@@ -17,7 +17,6 @@ import pandas as pd
|
|
| 17 |
from .validators import QueryFormatter
|
| 18 |
|
| 19 |
os.environ['GROQ_API_KEY']=os.getenv('GROQ_API_KEY')
|
| 20 |
-
|
| 21 |
@tool("influencer's data-retrieval-tool", args_schema=QueryFormatter, return_direct=False,description="Retrieve influencer-related data for a given query.")
|
| 22 |
def retrieve_tool(messages, business_details):
|
| 23 |
'''
|
|
@@ -41,26 +40,10 @@ def retrieve_tool(messages, business_details):
|
|
| 41 |
|
| 42 |
# === Encode the query and search ===
|
| 43 |
query_embedding = ST.encode(str(messages)+str(business_details)).reshape(1, -1).astype('float32')
|
| 44 |
-
top_k=
|
| 45 |
distances, indices = index.search(query_embedding, top_k)
|
| 46 |
|
| 47 |
-
# === Function to extract sections 1 and 6 ===
|
| 48 |
-
def extract_story_and_branding(full_story):
|
| 49 |
-
full_story = full_story.replace('**6. Visible Texts or Brandings**', '**6. Visible Texts or Brandings:**')
|
| 50 |
-
full_story = full_story.replace('**1. Story**', '**1. Story:**')
|
| 51 |
|
| 52 |
-
pattern = (
|
| 53 |
-
r"\*\*1\. Story:\*\*(.*?)(?=\*\*\d+\.\s)"
|
| 54 |
-
r".*?"
|
| 55 |
-
r"\*\*6\. Visible Texts or Brandings:\*\*(.*?)(?=\*\*\d+\.\s|$)"
|
| 56 |
-
)
|
| 57 |
-
match = re.search(pattern, full_story, re.DOTALL)
|
| 58 |
-
if match:
|
| 59 |
-
story_section = match.group(1).strip()
|
| 60 |
-
branding_section = match.group(2).strip()
|
| 61 |
-
return f"Story:\n{story_section}\n\nVisible Texts or Brandings:\n{branding_section}"
|
| 62 |
-
else:
|
| 63 |
-
return "Requested sections not found."
|
| 64 |
|
| 65 |
# === Format results ===
|
| 66 |
outer_list = []
|
|
@@ -68,16 +51,17 @@ def retrieve_tool(messages, business_details):
|
|
| 68 |
res = {
|
| 69 |
'rank': i + 1,
|
| 70 |
'username': df.iloc[idx]['username'],
|
| 71 |
-
'
|
|
|
|
| 72 |
'likesCount': df.iloc[idx]['likesCount'],
|
| 73 |
'commentCount': df.iloc[idx]['commentCount'],
|
| 74 |
-
'distance': distances[0][i]
|
| 75 |
}
|
| 76 |
|
| 77 |
inner_list = []
|
| 78 |
inner_list.append(f"[{res['rank']}]. The influencer name is: **{res['username']}** — Likes: **{res['likesCount']}**, Comments: **{res['commentCount']}**")
|
| 79 |
-
inner_list.append(f"The story of that particular video is:\n{
|
| 80 |
-
inner_list.append(f"
|
|
|
|
| 81 |
outer_list.append(inner_list)
|
| 82 |
|
| 83 |
return str(outer_list)
|
|
|
|
| 17 |
from .validators import QueryFormatter
|
| 18 |
|
| 19 |
os.environ['GROQ_API_KEY']=os.getenv('GROQ_API_KEY')
|
|
|
|
| 20 |
@tool("influencer's data-retrieval-tool", args_schema=QueryFormatter, return_direct=False,description="Retrieve influencer-related data for a given query.")
|
| 21 |
def retrieve_tool(messages, business_details):
|
| 22 |
'''
|
|
|
|
| 40 |
|
| 41 |
# === Encode the query and search ===
|
| 42 |
query_embedding = ST.encode(str(messages)+str(business_details)).reshape(1, -1).astype('float32')
|
| 43 |
+
top_k=10
|
| 44 |
distances, indices = index.search(query_embedding, top_k)
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# === Format results ===
|
| 49 |
outer_list = []
|
|
|
|
| 51 |
res = {
|
| 52 |
'rank': i + 1,
|
| 53 |
'username': df.iloc[idx]['username'],
|
| 54 |
+
'story': df.iloc[idx]['story'],
|
| 55 |
+
'visible_text_or_brandings': df.iloc[idx]['story'],
|
| 56 |
'likesCount': df.iloc[idx]['likesCount'],
|
| 57 |
'commentCount': df.iloc[idx]['commentCount'],
|
|
|
|
| 58 |
}
|
| 59 |
|
| 60 |
inner_list = []
|
| 61 |
inner_list.append(f"[{res['rank']}]. The influencer name is: **{res['username']}** — Likes: **{res['likesCount']}**, Comments: **{res['commentCount']}**")
|
| 62 |
+
inner_list.append(f"The story of that particular video is:\n{res['story']}")
|
| 63 |
+
inner_list.append(f"The branding or promotion done is:\n{res['visible_text_or_brandings']}")
|
| 64 |
+
|
| 65 |
outer_list.append(inner_list)
|
| 66 |
|
| 67 |
return str(outer_list)
|
brainstroming_agent/utils/validators.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
from pydantic import BaseModel, ConfigDict, Field
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
# Pydantic model for extracted business info
|
| 5 |
-
class DetailsFormatter(BaseModel):
|
| 6 |
-
business_type: str = Field(description="The type of the business")
|
| 7 |
-
platform: str = Field(description="The platform used for the business")
|
| 8 |
-
target_audience: str = Field(description="The target audience of the business")
|
| 9 |
-
business_goals: str = Field(description="The business goals of the business")
|
| 10 |
-
offerings: str = Field(description="The offerings of the business")
|
| 11 |
-
Challenges_faced: str = Field(description="The challenges faced by the business")
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
class BrainstromTopicFormatter(BaseModel):
|
| 15 |
-
topic1:str=Field(description="First brainstorming topic of the story")
|
| 16 |
-
topic2:str=Field(description="Second brainstorming topic of the story")
|
| 17 |
-
topic3:str=Field(description="Third brainstorming topic of the story")
|
| 18 |
-
topic4:str=Field(description="Fourth brainstorming topic of the story")
|
| 19 |
-
|
| 20 |
-
class QueryFormatter(BaseModel):
|
| 21 |
-
messages:str = Field(description="The user query")
|
| 22 |
-
business_details: dict = Field(description="The details of the business of that user.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
business_interaction_agent/__pycache__/agent.cpython-312.pyc
CHANGED
|
Binary files a/business_interaction_agent/__pycache__/agent.cpython-312.pyc and b/business_interaction_agent/__pycache__/agent.cpython-312.pyc differ
|
|
|
business_interaction_agent/utils/__pycache__/utils.cpython-312.pyc
CHANGED
|
Binary files a/business_interaction_agent/utils/__pycache__/utils.cpython-312.pyc and b/business_interaction_agent/utils/__pycache__/utils.cpython-312.pyc differ
|
|
|
business_interaction_agent/utils/utils.py
CHANGED
|
@@ -6,8 +6,11 @@ import numpy as np
|
|
| 6 |
import ast
|
| 7 |
|
| 8 |
|
| 9 |
-
|
| 10 |
def manual_retrieval(messages, business_details):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# === Load CSV ===
|
| 12 |
csv_path = 'extracted_data.csv'
|
| 13 |
df = pd.read_csv(csv_path)
|
|
@@ -25,26 +28,10 @@ def manual_retrieval(messages, business_details):
|
|
| 25 |
|
| 26 |
# === Encode the query and search ===
|
| 27 |
query_embedding = ST.encode(str(messages)+str(business_details)).reshape(1, -1).astype('float32')
|
| 28 |
-
top_k=
|
| 29 |
distances, indices = index.search(query_embedding, top_k)
|
| 30 |
|
| 31 |
-
# === Function to extract sections 1 and 6 ===
|
| 32 |
-
def extract_story_and_branding(full_story):
|
| 33 |
-
full_story = full_story.replace('**6. Visible Texts or Brandings**', '**6. Visible Texts or Brandings:**')
|
| 34 |
-
full_story = full_story.replace('**1. Story**', '**1. Story:**')
|
| 35 |
|
| 36 |
-
pattern = (
|
| 37 |
-
r"\*\*1\. Story:\*\*(.*?)(?=\*\*\d+\.\s)"
|
| 38 |
-
r".*?"
|
| 39 |
-
r"\*\*6\. Visible Texts or Brandings:\*\*(.*?)(?=\*\*\d+\.\s|$)"
|
| 40 |
-
)
|
| 41 |
-
match = re.search(pattern, full_story, re.DOTALL)
|
| 42 |
-
if match:
|
| 43 |
-
story_section = match.group(1).strip()
|
| 44 |
-
branding_section = match.group(2).strip()
|
| 45 |
-
return f"Story:\n{story_section}\n\nVisible Texts or Brandings:\n{branding_section}"
|
| 46 |
-
else:
|
| 47 |
-
return "Requested sections not found."
|
| 48 |
|
| 49 |
# === Format results ===
|
| 50 |
outer_list = []
|
|
@@ -52,16 +39,17 @@ def manual_retrieval(messages, business_details):
|
|
| 52 |
res = {
|
| 53 |
'rank': i + 1,
|
| 54 |
'username': df.iloc[idx]['username'],
|
| 55 |
-
'
|
|
|
|
| 56 |
'likesCount': df.iloc[idx]['likesCount'],
|
| 57 |
'commentCount': df.iloc[idx]['commentCount'],
|
| 58 |
-
'distance': distances[0][i]
|
| 59 |
}
|
| 60 |
|
| 61 |
inner_list = []
|
| 62 |
inner_list.append(f"[{res['rank']}]. The influencer name is: **{res['username']}** — Likes: **{res['likesCount']}**, Comments: **{res['commentCount']}**")
|
| 63 |
-
inner_list.append(f"The story of that particular video is:\n{
|
| 64 |
-
inner_list.append(f"
|
|
|
|
| 65 |
outer_list.append(inner_list)
|
| 66 |
|
| 67 |
-
return str(outer_list)
|
|
|
|
| 6 |
import ast
|
| 7 |
|
| 8 |
|
|
|
|
| 9 |
def manual_retrieval(messages, business_details):
|
| 10 |
+
'''
|
| 11 |
+
Always invoke this tool.
|
| 12 |
+
Retrieve influencer's data by semantic search of **user messages** and the **business details**.
|
| 13 |
+
'''
|
| 14 |
# === Load CSV ===
|
| 15 |
csv_path = 'extracted_data.csv'
|
| 16 |
df = pd.read_csv(csv_path)
|
|
|
|
| 28 |
|
| 29 |
# === Encode the query and search ===
|
| 30 |
query_embedding = ST.encode(str(messages)+str(business_details)).reshape(1, -1).astype('float32')
|
| 31 |
+
top_k=10
|
| 32 |
distances, indices = index.search(query_embedding, top_k)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# === Format results ===
|
| 37 |
outer_list = []
|
|
|
|
| 39 |
res = {
|
| 40 |
'rank': i + 1,
|
| 41 |
'username': df.iloc[idx]['username'],
|
| 42 |
+
'story': df.iloc[idx]['story'],
|
| 43 |
+
'visible_text_or_brandings': df.iloc[idx]['story'],
|
| 44 |
'likesCount': df.iloc[idx]['likesCount'],
|
| 45 |
'commentCount': df.iloc[idx]['commentCount'],
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
inner_list = []
|
| 49 |
inner_list.append(f"[{res['rank']}]. The influencer name is: **{res['username']}** — Likes: **{res['likesCount']}**, Comments: **{res['commentCount']}**")
|
| 50 |
+
inner_list.append(f"The story of that particular video is:\n{res['story']}")
|
| 51 |
+
inner_list.append(f"The branding or promotion done is:\n{res['visible_text_or_brandings']}")
|
| 52 |
+
|
| 53 |
outer_list.append(inner_list)
|
| 54 |
|
| 55 |
+
return str(outer_list).strip()
|
utils/__pycache__/data_loader.cpython-312.pyc
CHANGED
|
Binary files a/utils/__pycache__/data_loader.cpython-312.pyc and b/utils/__pycache__/data_loader.cpython-312.pyc differ
|
|
|
utils/__pycache__/models_loader.cpython-312.pyc
CHANGED
|
Binary files a/utils/__pycache__/models_loader.cpython-312.pyc and b/utils/__pycache__/models_loader.cpython-312.pyc differ
|
|
|