bstraehle commited on
Commit
b2c1039
·
verified ·
1 Parent(s): ff22768

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +3 -24
crew.py CHANGED
@@ -1,10 +1,6 @@
1
  import os
2
  from crewai import Agent, Crew, Process, Task
3
  from crewai.tools import tool
4
- #from crewai_tools import (
5
- # SerperDevTool,
6
- # WebsiteSearchTool
7
- #)
8
  from google import genai
9
  from google.genai import types
10
  from openinference.instrumentation.crewai import CrewAIInstrumentor
@@ -44,9 +40,6 @@ CrewAIInstrumentor().instrument(tracer_provider=tracer_provider)
44
  def run_crew(question, file_path):
45
  # Tools
46
 
47
- #web_search_tool = SerperDevTool()
48
- #web_rag_tool = WebsiteSearchTool()
49
-
50
  @tool("Web Search Tool")
51
  def web_search_tool(question: str) -> str:
52
  """Search the web to answer a question.
@@ -60,15 +53,6 @@ def run_crew(question, file_path):
60
  Raises:
61
  RuntimeError: If processing fails"""
62
  try:
63
- #client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
64
-
65
- #response = client.models.generate_content(
66
- # model=IMAGE_MODEL,
67
- # contents=[file, question]
68
- #)
69
-
70
- #return response.text
71
- ###
72
  client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
73
 
74
  response = client.models.generate_content(
@@ -80,7 +64,6 @@ def run_crew(question, file_path):
80
  )
81
 
82
  return response.text
83
- ###
84
  except Exception as e:
85
  raise RuntimeError(f"Processing failed: {str(e)}")
86
 
@@ -194,7 +177,7 @@ def run_crew(question, file_path):
194
  @tool("Document Analysis Tool")
195
  def document_analysis_tool(question: str, file_path: str) -> str:
196
  """Answer a question about a document file. Supported document types include:
197
- .txt, .csv, .xml, .rtf, .pdf, .md, .html, .css, .js
198
 
199
  Args:
200
  question (str): Question about a document file
@@ -341,7 +324,7 @@ def run_crew(question, file_path):
341
 
342
  document_analysis_agent = Agent(
343
  role="Document Analysis Agent",
344
- goal="Analyze document of type .txt, .csv, .xml, .rtf, .pdf, .md, .html, .css, .js to help answer question \"{question}\"",
345
  backstory="As an expert document analysis assistant, you analyze the document to help answer the question.",
346
  allow_delegation=False,
347
  llm=AGENT_MODEL,
@@ -400,7 +383,7 @@ def run_crew(question, file_path):
400
  audio_analysis_agent,
401
  video_analysis_agent,
402
  youtube_analysis_agent,
403
- document_analysis_agent,
404
  code_generation_agent,
405
  code_execution_agent],
406
  manager_agent=manager_agent,
@@ -413,10 +396,6 @@ def run_crew(question, file_path):
413
  if file_path:
414
  question = f"{question} File path: {file_path}."
415
 
416
- #if file_path.endswith(".py"):
417
- # with open(f"{file_path}", "r") as file:
418
- # question = f"{question} File data:\n{file.read()}"
419
-
420
  initial_answer = crew.kickoff(inputs={"question": question})
421
  final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(initial_answer))
422
 
 
1
  import os
2
  from crewai import Agent, Crew, Process, Task
3
  from crewai.tools import tool
 
 
 
 
4
  from google import genai
5
  from google.genai import types
6
  from openinference.instrumentation.crewai import CrewAIInstrumentor
 
40
  def run_crew(question, file_path):
41
  # Tools
42
 
 
 
 
43
  @tool("Web Search Tool")
44
  def web_search_tool(question: str) -> str:
45
  """Search the web to answer a question.
 
53
  Raises:
54
  RuntimeError: If processing fails"""
55
  try:
 
 
 
 
 
 
 
 
 
56
  client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
57
 
58
  response = client.models.generate_content(
 
64
  )
65
 
66
  return response.text
 
67
  except Exception as e:
68
  raise RuntimeError(f"Processing failed: {str(e)}")
69
 
 
177
  @tool("Document Analysis Tool")
178
  def document_analysis_tool(question: str, file_path: str) -> str:
179
  """Answer a question about a document file. Supported document types include:
180
+ .txt, .csv, .xml, .rtf, .pdf, .md, .html, .css, .js, .py
181
 
182
  Args:
183
  question (str): Question about a document file
 
324
 
325
  document_analysis_agent = Agent(
326
  role="Document Analysis Agent",
327
+ goal="Analyze document of type .txt, .csv, .xml, .rtf, .pdf, .md, .html, .css, .js, .py to help answer question \"{question}\"",
328
  backstory="As an expert document analysis assistant, you analyze the document to help answer the question.",
329
  allow_delegation=False,
330
  llm=AGENT_MODEL,
 
383
  audio_analysis_agent,
384
  video_analysis_agent,
385
  youtube_analysis_agent,
386
+ #document_analysis_agent,
387
  code_generation_agent,
388
  code_execution_agent],
389
  manager_agent=manager_agent,
 
396
  if file_path:
397
  question = f"{question} File path: {file_path}."
398
 
 
 
 
 
399
  initial_answer = crew.kickoff(inputs={"question": question})
400
  final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(initial_answer))
401