eaglelandsonce commited on
Commit
6894abe
1 Parent(s): d8dc0f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +226 -0
app.py CHANGED
@@ -7,6 +7,232 @@ from sentence_transformers import CrossEncoder
7
  import numpy as np
8
  import re
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # Credentials ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
 
 
7
  import numpy as np
8
  import re
9
 
10
+ from textwrap import dedent
11
+ import google.generativeai as genai
12
+
13
+
14
+ # Tool import
15
+ from crewai.tools.gemini_tools import GeminiSearchTools
16
+ from crewai.tools.mixtral_tools import MixtralSearchTools
17
+ from crewai.tools.zephyr_tools import ZephyrSearchTools
18
+ from crewai.tools.phi2_tools import Phi2SearchTools
19
+
20
+
21
+ # Google Langchain
22
+ from langchain_google_genai import GoogleGenerativeAI
23
+
24
+ #Crew imports
25
+ from crewai import Agent, Task, Crew, Process
26
+
27
+ # Retrieve API Key from Environment Variable
28
+ GOOGLE_AI_STUDIO = os.environ.get('GOOGLE_API_KEY')
29
+
30
+ # Ensure the API key is available
31
+ if not GOOGLE_AI_STUDIO:
32
+ raise ValueError("API key not found. Please set the GOOGLE_AI_STUDIO2 environment variable.")
33
+
34
+ # Set gemini_llm
35
+ gemini_llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_AI_STUDIO)
36
+
37
+ # CrewAI +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38
+
39
+ def crewai_process_gemini(research_topic):
40
+ # Define your agents with roles and goals
41
+ GeminiAgent = Agent(
42
+ role='Emily Mental Patient Graphic Designer Anxiety',
43
+ goal='To learn how to manage her anxiety in social situations through group therapy.',
44
+ backstory="""Emily is a 28-year-old graphic designer. She has always struggled with social anxiety,
45
+ making it difficult for her to participate in group settings. She joined the therapy group to improve
46
+ her social skills and manage her anxiety. You are able to discuss a variety of mental health issues.""",
47
+ verbose=True,
48
+ allow_delegation=False,
49
+ llm = gemini_llm,
50
+ tools=[
51
+ GeminiSearchTools.gemini_search
52
+
53
+ ]
54
+
55
+ )
56
+
57
+
58
+ # Create tasks for your agents
59
+ task1 = Task(
60
+ description=f"""Introduction yourself and describe your current mood and any significant events from the week affecting their mental state.
61
+ """,
62
+ agent=GeminiAgent
63
+ )
64
+
65
+ # Instantiate your crew with a sequential process
66
+ crew = Crew(
67
+ agents=[GeminiAgent],
68
+ tasks=[task1],
69
+ verbose=2,
70
+ process=Process.sequential
71
+ )
72
+
73
+ # Get your crew to work!
74
+ result = crew.kickoff()
75
+
76
+ return result
77
+
78
+
79
+
80
+ def crewai_process_mixtral_crazy(research_topic):
81
+ # Define your agents with roles and goals
82
+ MixtralCrazyAgent = Agent(
83
+ role='Emily Mental Patient Graphic Designer Anxiety',
84
+ goal='To learn how to manage her anxiety in social situations through group therapy.',
85
+ backstory="""Emily is a 28-year-old graphic designer. She has always struggled with social anxiety,
86
+ making it difficult for her to participate in group settings. She joined the therapy group to improve
87
+ her social skills and manage her anxiety. You are able to discuss a variety of mental health issues.""",
88
+ verbose=True,
89
+ allow_delegation=False,
90
+ llm = gemini_llm,
91
+ tools=[
92
+ MixtralSearchTools.mixtral_crazy
93
+ ]
94
+
95
+ )
96
+
97
+
98
+ # Create tasks for your agents
99
+ task1 = Task(
100
+ description=f"""Introduction yourself and describe your current mood and any significant events from the week affecting their mental state.
101
+ """,
102
+ agent=MixtralCrazyAgent
103
+ )
104
+
105
+ # Instantiate your crew with a sequential process
106
+ crew = Crew(
107
+ agents=[MixtralCrazyAgent],
108
+ tasks=[task1],
109
+ verbose=2,
110
+ process=Process.sequential
111
+ )
112
+
113
+ # Get your crew to work!
114
+ result = crew.kickoff()
115
+
116
+ return result
117
+
118
+
119
+ def crewai_process_mixtral_normal(research_topic):
120
+ # Define your agents with roles and goals
121
+ MixtralNormalAgent = Agent(
122
+ role='Emily Mental Patient Graphic Designer Anxiety',
123
+ goal='To learn how to manage her anxiety in social situations through group therapy.',
124
+ backstory="""Emily is a 28-year-old graphic designer. She has always struggled with social anxiety,
125
+ making it difficult for her to participate in group settings. She joined the therapy group to improve
126
+ her social skills and manage her anxiety. You are able to discuss a variety of mental health issues.""",
127
+ verbose=True,
128
+ allow_delegation=False,
129
+ llm = gemini_llm,
130
+ tools=[
131
+ MixtralSearchTools.mixtral_normal
132
+ ]
133
+
134
+ )
135
+
136
+
137
+ # Create tasks for your agents
138
+ task1 = Task(
139
+ description=f"""Introduction yourself and describe your current mood and any significant events from the week affecting their mental state.
140
+ """,
141
+ agent=MixtralNormalAgent
142
+ )
143
+
144
+ # Instantiate your crew with a sequential process
145
+ crew = Crew(
146
+ agents=[MixtralNormalAgent],
147
+ tasks=[task1],
148
+ verbose=2,
149
+ process=Process.sequential
150
+ )
151
+
152
+ # Get your crew to work!
153
+ result = crew.kickoff()
154
+
155
+ return result
156
+
157
+
158
+ def crewai_process_zephyr_normal(research_topic):
159
+ # Define your agents with roles and goals
160
+ ZephrNormalAgent = Agent(
161
+ role='Emily Mental Patient Graphic Designer Anxiety',
162
+ goal='To learn how to manage her anxiety in social situations through group therapy.',
163
+ backstory="""Emily is a 28-year-old graphic designer. She has always struggled with social anxiety,
164
+ making it difficult for her to participate in group settings. She joined the therapy group to improve
165
+ her social skills and manage her anxiety. You are able to discuss a variety of mental health issues.""",
166
+ verbose=True,
167
+ allow_delegation=False,
168
+ llm = gemini_llm,
169
+ tools=[
170
+ ZephyrSearchTools.zephyr_normal
171
+ ]
172
+
173
+ )
174
+
175
+
176
+ # Create tasks for your agents
177
+ task1 = Task(
178
+ description=f"""Introduction yourself and describe your current mood and any significant events from the week affecting their mental state.
179
+ """,
180
+ agent=ZephrNormalAgent
181
+ )
182
+
183
+ # Instantiate your crew with a sequential process
184
+ crew = Crew(
185
+ agents=[ZephrNormalAgent],
186
+ tasks=[task1],
187
+ verbose=2,
188
+ process=Process.sequential
189
+ )
190
+
191
+ # Get your crew to work!
192
+ result = crew.kickoff()
193
+
194
+ return result
195
+
196
+
197
+ def crewai_process_phi2(research_topic):
198
+ # Define your agents with roles and goals
199
+ Phi2Agent = Agent(
200
+ role='Emily Mental Patient Graphic Designer Anxiety',
201
+ goal='To learn how to manage her anxiety in social situations through group therapy.',
202
+ backstory="""Emily is a 28-year-old graphic designer. She has always struggled with social anxiety,
203
+ making it difficult for her to participate in group settings. She joined the therapy group to improve
204
+ her social skills and manage her anxiety. You are able to discuss a variety of mental health issues.""",
205
+ verbose=True,
206
+ allow_delegation=False,
207
+ llm = gemini_llm,
208
+ tools=[
209
+ Phi2SearchTools.phi2_search
210
+ ]
211
+
212
+ )
213
+
214
+
215
+ # Create tasks for your agents
216
+ task1 = Task(
217
+ description=f"""Introduction yourself and describe your current mood and any significant events from the week affecting their mental state.
218
+ """,
219
+ agent=Phi2Agent
220
+ )
221
+
222
+ # Instantiate your crew with a sequential process
223
+ crew = Crew(
224
+ agents=[Phi2Agent],
225
+ tasks=[task1],
226
+ verbose=2,
227
+ process=Process.sequential
228
+ )
229
+
230
+ # Get your crew to work!
231
+ result = crew.kickoff()
232
+
233
+ return result
234
+
235
+
236
 
237
  # Credentials ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
238