-
Notifications
You must be signed in to change notification settings - Fork 0
/
crewai_with_groq_llama70b.py
65 lines (48 loc) · 2.46 KB
/
crewai_with_groq_llama70b.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
65
# -*- coding: utf-8 -*-
"""CrewAI_with_Groq.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1gEfeGJd5_81o8zy5wa9I92u5Xq-M9891
"""
#!pip install crewai
# first, in a conda terminal, write te following command to install the packages: pip install crewai
from crewai import Agent, Task, Crew, Process
import os
os.environ["OPENAI_API_BASE"] = 'https://api.groq.com/openai/v1' #OpenAI Compatibilty of Groq with OpenAI
os.environ["OPENAI_MODEL_NAME"] ='llama3-70b-8192' # Adjust based on available model
os.environ["OPENAI_API_KEY"] ='<YOUR API KEY from GROQ>'
#model = Ollama(model = "llama3")
# email classification with llama3
email = "Hey, Are you up for running?"
classifier = Agent(
role = "email classifier",
goal = "Accurately classify emails based on their level of importance. Give them one of the three ratings: Important, Casual, Spam",
backstory = """You are an AI assistant whose job is to classify the emails accurately and honestly. Your job is to help the user manage his/her inbox.""",
verbose = True,
allow_delegation = False, #We do not want this agent delegate its task to somebody else :)
)
responder = Agent(
role = "email responder",
goal = "Based on the importance of the email, write a concise and simple response. If the email is rated Important, write a formal response. If rated casual, write a casual response, and ignore the email if it is rated as Spam. In any case, be concise.",
backstory = """You are an AI assistant whose job is to write short responses to emails based on their importance. The importance will be provided to you by the classifier agent.""",
verbose = True,
allow_delegation = False, #We do not want this agent delegate its task to somebody else :)
)
classify_email = Task(
description = f"Classify the following email: {email}",
agent = classifier,
expected_output = "One of these three options: 'Important', 'Casual', 'Spam'"
)
respond_to_email = Task(
description = f"Respond to the following email: {email} based on the importance provided by 'classifier' agent.",
agent = responder,
expected_output = "short responses to emails based on their importance. The importance will be provided to you by the classifier agent."
)
crew = Crew(
agents = [classifier, responder],
tasks = [classify_email, respond_to_email],
verbose = 2,
process = Process.sequential
)
output = crew.kickoff()
print(output)