-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
102 lines (81 loc) · 2.75 KB
/
app.py
File metadata and controls
102 lines (81 loc) · 2.75 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from crewai import Agent, Task, Crew, Process
# from langchain_google_vertexai import VertexAI
from langchain_community.tools import DuckDuckGoSearchRun
search_tool = DuckDuckGoSearchRun()
import os
from langchain_google_genai import ChatGoogleGenerativeAI
import google.generativeai as genai
from dotenv import load_dotenv
import streamlit as st
load_dotenv()
os.getenv("GOOGLE_API_KEY")
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
# llm_vertex = VertexAI(model_name="gemini-pro")
llm_google = ChatGoogleGenerativeAI(model="gemini-pro", temprecture=0.3)
# Create Agents
researcher = Agent(
role='Senior Researcher',
goal='Discover groundbreaking technologies',
backstory='A curious mind fascinated by cutting-edge innovation and the potential to change the world, you possess comprehensive knowledge of technology.',
verbose=True,
tools=[search_tool],
allow_delegation=False,
llm=llm_google
)
insight_researcher = Agent(
role='Insight Researcher',
goal='Discover Key Insights',
backstory='You excel at extracting key insights from the data provided.',
verbose=True,
allow_delegation=False,
llm=llm_google
)
writer = Agent(
role='Tech Content Strategist',
goal='Craft compelling content on tech advancements',
backstory='Renowned as a content strategist, you specialize in making complex tech topics interesting and easy to understand.',
verbose=True,
allow_delegation=False,
llm=llm_google
)
formater = Agent(
role='Markdown Formatter',
goal='Format the text in markdown',
backstory='Your expertise lies in converting text into markdown format.',
verbose=True,
allow_delegation=False,
llm=llm_google
)
# Tasks
research_task = Task(
description='Identify the next big trend in AI by searching the internet',
agent=researcher
)
insights_task = Task(
description='Identify a few key insights from the data in bullet point format. Do not use any tools.',
agent=insight_researcher
)
writer_task = Task(
description='Write a short blog post with subheadings. Do not use any tools.',
agent=writer
)
format_task = Task(
description='Convert the text into markdown format. Do not use any tools.',
agent=formater
)
# Creating the tech_crew
tech_crew = Crew(
agents=[researcher, insight_researcher, writer, formater],
tasks=[research_task, insights_task, writer_task, format_task],
process=Process.sequential # Tasks will be executed one after the other
)
def main():
st.set_page_config("Agent")
st.header("Chat with Personal Agent Team 💁")
user_question = st.text_input("Tell task to do")
if user_question:
result = tech_crew.kickoff()
print(result)
st.write(result)
if __name__ == "__main__":
main()