Spaces:
Sleeping
Sleeping
Commit ·
e070b43
1
Parent(s): 8f0d578
updated file save paths
Browse files
app.py
CHANGED
|
@@ -88,7 +88,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 88 |
# 3. Run your Agent
|
| 89 |
results_log = []
|
| 90 |
answers_payload = []
|
| 91 |
-
save_path = Path(__file__)
|
| 92 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 93 |
for index, item in enumerate(questions_data, start=1):
|
| 94 |
task_id = item.get("task_id")
|
|
|
|
| 88 |
# 3. Run your Agent
|
| 89 |
results_log = []
|
| 90 |
answers_payload = []
|
| 91 |
+
save_path = Path(__file__).cwd()
|
| 92 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 93 |
for index, item in enumerate(questions_data, start=1):
|
| 94 |
task_id = item.get("task_id")
|
tools.py
CHANGED
|
@@ -165,14 +165,15 @@ def get_yt_video_info_metadata(url:str) -> dict:
|
|
| 165 |
|
| 166 |
# Document Loaders
|
| 167 |
@tool
|
| 168 |
-
def analyze_excel_file(
|
| 169 |
"""
|
| 170 |
Analyze an excel file using python pandas
|
| 171 |
|
| 172 |
Arguments:
|
| 173 |
-
|
| 174 |
"""
|
| 175 |
try:
|
|
|
|
| 176 |
df = pd.read_excel(file_path)
|
| 177 |
result = (f"Excel file loaded with {len(df)} rows and {len(df.columns)} columns \n")
|
| 178 |
result += f"Columns : {', '.join(map(str,df.columns))}\n\n"
|
|
@@ -184,14 +185,15 @@ def analyze_excel_file(file_path:str) -> str:
|
|
| 184 |
|
| 185 |
|
| 186 |
@tool
|
| 187 |
-
def read_file(
|
| 188 |
"""
|
| 189 |
read the contents of any type of text file including code files
|
| 190 |
|
| 191 |
Arguments:
|
| 192 |
-
|
| 193 |
"""
|
| 194 |
try:
|
|
|
|
| 195 |
docs = TextLoader(file_path, autodetect_encoding=True)
|
| 196 |
result = docs.load()
|
| 197 |
return result[0].page_content
|
|
@@ -199,17 +201,18 @@ def read_file(file_path:str) -> str:
|
|
| 199 |
return f"An Exception occured : {e}"
|
| 200 |
|
| 201 |
@tool
|
| 202 |
-
def analyze_image(
|
| 203 |
"""
|
| 204 |
give the query and image path to this tool for you to get answers related to provided image
|
| 205 |
Arguments
|
| 206 |
-
|
| 207 |
query (str): query related to the image
|
| 208 |
"""
|
| 209 |
try:
|
| 210 |
import google.generativeai as genai
|
| 211 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 212 |
model = genai.GenerativeModel(model_name="gemini-2.5-pro", generation_config=genai.GenerationConfig(temperature=0))
|
|
|
|
| 213 |
response = model.generate_content([query, image_path])
|
| 214 |
return response.text
|
| 215 |
except Exception as e:
|
|
@@ -225,7 +228,7 @@ def transcribe_audio_file(audio_file_name:str)->str:
|
|
| 225 |
audio_file_name (str): nameof the audio file to be transcribed
|
| 226 |
"""
|
| 227 |
client = Groq(api_key=os.getenv("LLM_API_KEY", None))
|
| 228 |
-
filename = Path(__file__).joinpath(audio_file_name)
|
| 229 |
|
| 230 |
with open(filename, "rb") as file:
|
| 231 |
translation = client.audio.translations.create(
|
|
|
|
| 165 |
|
| 166 |
# Document Loaders
|
| 167 |
@tool
|
| 168 |
+
def analyze_excel_file(file_name:str) -> str:
|
| 169 |
"""
|
| 170 |
Analyze an excel file using python pandas
|
| 171 |
|
| 172 |
Arguments:
|
| 173 |
+
file_name (str): name of the excel file
|
| 174 |
"""
|
| 175 |
try:
|
| 176 |
+
file_path = Path(__file__).cwd().joinpath(file_name)
|
| 177 |
df = pd.read_excel(file_path)
|
| 178 |
result = (f"Excel file loaded with {len(df)} rows and {len(df.columns)} columns \n")
|
| 179 |
result += f"Columns : {', '.join(map(str,df.columns))}\n\n"
|
|
|
|
| 185 |
|
| 186 |
|
| 187 |
@tool
|
| 188 |
+
def read_file(file_name:str) -> str:
|
| 189 |
"""
|
| 190 |
read the contents of any type of text file including code files
|
| 191 |
|
| 192 |
Arguments:
|
| 193 |
+
file_name (str): name of the text file
|
| 194 |
"""
|
| 195 |
try:
|
| 196 |
+
file_path = Path(__file__).cwd().joinpath(file_name)
|
| 197 |
docs = TextLoader(file_path, autodetect_encoding=True)
|
| 198 |
result = docs.load()
|
| 199 |
return result[0].page_content
|
|
|
|
| 201 |
return f"An Exception occured : {e}"
|
| 202 |
|
| 203 |
@tool
|
| 204 |
+
def analyze_image(image_name:str, query:str)->str:
|
| 205 |
"""
|
| 206 |
give the query and image path to this tool for you to get answers related to provided image
|
| 207 |
Arguments
|
| 208 |
+
image_name (str): path of image file
|
| 209 |
query (str): query related to the image
|
| 210 |
"""
|
| 211 |
try:
|
| 212 |
import google.generativeai as genai
|
| 213 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 214 |
model = genai.GenerativeModel(model_name="gemini-2.5-pro", generation_config=genai.GenerationConfig(temperature=0))
|
| 215 |
+
image_path = Path(__file__).cwd().joinpath(image_name)
|
| 216 |
response = model.generate_content([query, image_path])
|
| 217 |
return response.text
|
| 218 |
except Exception as e:
|
|
|
|
| 228 |
audio_file_name (str): nameof the audio file to be transcribed
|
| 229 |
"""
|
| 230 |
client = Groq(api_key=os.getenv("LLM_API_KEY", None))
|
| 231 |
+
filename = Path(__file__).cwd().joinpath(audio_file_name)
|
| 232 |
|
| 233 |
with open(filename, "rb") as file:
|
| 234 |
translation = client.audio.translations.create(
|