-
Notifications
You must be signed in to change notification settings - Fork 0
/
Podcast_Summarizer_AI_Agent.py
64 lines (59 loc) · 2.12 KB
/
Podcast_Summarizer_AI_Agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from Tools.audio_trancriber import audio_transcriber_tool
from Tools.composio_slack import composio_slack_tool
import os
from langchain_openai import AzureChatOpenAI, ChatOpenAI
from dotenv import load_dotenv
load_dotenv()
@CrewBase
class PodSumCrew:
"Podcast summarizer and slack messenger Crew"
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
audio_tool = [audio_transcriber_tool]
slack_tool = composio_slack_tool()
openai_api_key = os.environ.get("OPENAI_API_KEY")
llm_model = AzureChatOpenAI(openai_api_version=os.getenv("AZURE_OPENAI_VERSION", "2023-07-01-preview"),
azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT", "gpt4chat"),
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT", "https://gpt-4-trails.openai.azure.com/"),
api_key=os.getenv("AZURE_OPENAI_KEY"))
@agent
def summary_agent(self) -> Agent:
return Agent(
config = self.agents_config['Transcriber_summarizer'],
tools = self.audio_tool,
verbose = True,
llm = self.llm_model,
allow_delegation = False,
)
@agent
def slack_agent(self) -> Agent:
return Agent(
config = self.agents_config['slack_messenger'],
tools = self.slack_tool,
verbose = True,
llm = self.llm_model,
)
@task
def generate_summary(self) -> Task:
return Task(
config=self.tasks_config['summarize_podcast_task'],
tools=self.audio_tool,
agent=self.summary_agent(),
)
@task
def send_message(self) -> Task:
return Task(
config=self.tasks_config['send_message_to_slack_task'],
tools=self.slack_tool,
agent=self.slack_agent(),
)
@crew
def crew(self) -> Crew:
"""Creates a crew for the Podcast summarizer"""
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
)