eaglelandsonce commited on
Commit
e4660a4
·
verified ·
1 Parent(s): d945d64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +107 -3
app.py CHANGED
@@ -7,6 +7,87 @@ import time
7
  from PIL import Image
8
  from streamlit_image_comparison import image_comparison
9
  import numpy as np
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
 
12
 
@@ -165,9 +246,32 @@ with tab2:
165
 
166
  st.header("Agent Advisors")
167
  st.write("Would you like to optimize your HIN number?")
168
-
169
- st.header("My Incentive")
170
- st.write("Total incentive for HIN optimization")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  with col2:
173
  st.header("Green Smart Village Layout")
 
7
  from PIL import Image
8
  from streamlit_image_comparison import image_comparison
9
  import numpy as np
10
+ #import chromadb
11
+
12
+ from textwrap import dedent
13
+ import google.generativeai as genai
14
+
15
+ api_key = os.environ["OPENAI_API_KEY"]
16
+
17
+ from openai import OpenAI
18
+ import numpy as np
19
+ # Assuming chromadb and TruLens are correctly installed and configured
20
+
21
+ #from chromadb.utils.embedding_functions import
22
+
23
+ # Google Langchain
24
+ from langchain_google_genai import GoogleGenerativeAI
25
+
26
+ #Crew imports
27
+ from crewai import Agent, Task, Crew, Process
28
+
29
+ # Retrieve API Key from Environment Variable
30
+ GOOGLE_AI_STUDIO = os.environ.get('GOOGLE_API_KEY')
31
+
32
+ # Ensure the API key is available
33
+ if not GOOGLE_AI_STUDIO:
34
+ raise ValueError("API key not found. Please set the GOOGLE_AI_STUDIO2 environment variable.")
35
+
36
+ # Set gemini_llm
37
+ gemini_llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_AI_STUDIO)
38
+
39
+
40
+
41
+ # CrewAI ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42
+
43
+
44
+ def crewai_process_gemini(research_topic):
45
+ # Define your agents with roles and goals
46
+ GeminiAgent = Agent(
47
+ role='Story Writer',
48
+ goal='To create a story from bullet points.',
49
+ backstory="""You are an expert writer that understands how to make the average extraordinary on paper """,
50
+ verbose=True,
51
+ allow_delegation=False,
52
+ llm = gemini_llm,
53
+ tools=[
54
+ GeminiSearchTools.gemini_search
55
+
56
+ ]
57
+
58
+ )
59
+
60
+
61
+ # Create tasks for your agents
62
+ task1 = Task(
63
+ description=f"""From {research_topic} create your story by writing at least one sentence about each bullet point
64
+ and make sure you have a transitional statement between scenes . BE VERBOSE.""",
65
+ agent=GeminiAgent
66
+ )
67
+
68
+ # Instantiate your crew with a sequential process
69
+ crew = Crew(
70
+ agents=[GeminiAgent],
71
+ tasks=[task1],
72
+ verbose=2,
73
+ process=Process.sequential
74
+ )
75
+
76
+ # Get your crew to work!
77
+ result = crew.kickoff()
78
+
79
+ return result
80
+
81
+
82
+
83
+
84
+ # Tool import
85
+ from crewai.tools.gemini_tools import GeminiSearchTools
86
+ from crewai.tools.mixtral_tools import MixtralSearchTools
87
+ from crewai.tools.zephyr_tools import ZephyrSearchTools
88
+ from crewai.tools.phi2_tools import
89
+
90
+
91
 
92
 
93
 
 
246
 
247
  st.header("Agent Advisors")
248
  st.write("Would you like to optimize your HIN number?")
249
+
250
+ # Selection box for the function to execute
251
+ process_selection = st.selectbox(
252
+ 'Choose the process to run:',
253
+ ('crewai_process_gemini', 'crewai_process_mixtral_crazy', 'crewai_process_mixtral_normal', 'crewai_process_zephyr_normal', 'crewai_process_phi2')
254
+ )
255
+
256
+ # Button to execute the chosen function
257
+ if st.button('Run Process'):
258
+ if research_topic: # Ensure there's a topic provided
259
+ if process_selection == 'crewai_process_gemini':
260
+ result = crewai_process_gemini(research_topic)
261
+ elif process_selection == 'crewai_process_mixtral_crazy':
262
+ result = crewai_process_mixtral_crazy(research_topic)
263
+ elif process_selection == 'crewai_process_mixtral_normal':
264
+ result = crewai_process_mixtral_normal(research_topic)
265
+ elif process_selection == 'crewai_process_zephyr_normal':
266
+ result = crewai_process_zephyr_normal(research_topic)
267
+ elif process_selection == 'crewai_process_phi2':
268
+ result = crewai_process_phi2(research_topic)
269
+ st.write(result)
270
+ else:
271
+ st.warning('Please enter a research topic.')
272
+
273
+ st.header("My Incentive")
274
+ st.write("Total incentive for HIN optimization")
275
 
276
  with col2:
277
  st.header("Green Smart Village Layout")