bstraehle commited on
Commit
f72152d
·
verified ·
1 Parent(s): 9af114b

Update agents/crew.py

Browse files
Files changed (1) hide show
  1. agents/crew.py +33 -16
agents/crew.py CHANGED
@@ -4,24 +4,41 @@
4
  # https://arize.com/docs/phoenix/integrations/python/crewai/crewai-tracing
5
 
6
  import logging, os
 
 
7
 
8
- os.environ["CREWAI_TRACING_ENABLED"] = "0" # Arize Phoenix
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- from agents.models.llms import (
11
- LLM_CREW_MANAGER,
12
- LLM_CREW_PLANNING,
13
- LLM_MANAGER,
14
- LLM_AGENT
15
- )
16
- from agents.tools.ai_tools import AITools
17
- from agents.tools.deterministic_tools import DeterministicTools
18
- from agents.tools.mcp_tools import MCPTools
19
- from crewai import Agent, Crew, Task, Process
20
- from crewai.agents.agent_builder.base_agent import BaseAgent
21
- from crewai.project import CrewBase, agent, crew, task
22
- from google import genai
23
- from google.genai import types
24
- from phoenix.otel import register
25
  from typing import List
26
  from utils.utils import read_file_json, is_ext
27
 
 
4
  # https://arize.com/docs/phoenix/integrations/python/crewai/crewai-tracing
5
 
6
  import logging, os
7
+ import sys
8
+ from contextlib import contextmanager
9
 
10
+ @contextmanager
11
+ def suppress_stdout_stderr():
12
+ with open(os.devnull, 'w') as fnull:
13
+ old_stdout = sys.stdout
14
+ old_stderr = sys.stderr
15
+ sys.stdout = fnull
16
+ sys.stderr = fnull
17
+ try:
18
+ yield
19
+ finally:
20
+ sys.stdout = old_stdout
21
+ sys.stderr = old_stderr
22
+
23
+ os.environ["CREWAI_TRACING_ENABLED"] = "0"
24
+
25
+ with suppress_stdout_stderr():
26
+ from agents.models.llms import (
27
+ LLM_CREW_MANAGER,
28
+ LLM_CREW_PLANNING,
29
+ LLM_MANAGER,
30
+ LLM_AGENT
31
+ )
32
+ from agents.tools.ai_tools import AITools
33
+ from agents.tools.deterministic_tools import DeterministicTools
34
+ from agents.tools.mcp_tools import MCPTools
35
+ from crewai import Agent, Crew, Task, Process
36
+ from crewai.agents.agent_builder.base_agent import BaseAgent
37
+ from crewai.project import CrewBase, agent, crew, task
38
+ from google import genai
39
+ from google.genai import types
40
+ from phoenix.otel import register
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  from typing import List
43
  from utils.utils import read_file_json, is_ext
44