eaglelandsonce commited on
Commit
ea3b15d
1 Parent(s): f9746d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -6
app.py CHANGED
@@ -47,9 +47,6 @@ GOOGLE_AI_STUDIO = os.environ.get('GOOGLE_API_KEY')
47
  if not GOOGLE_AI_STUDIO:
48
  raise ValueError("API key not found. Please set the GOOGLE_AI_STUDIO2 environment variable.")
49
 
50
- # Set gemini_llm
51
- gemini_llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_AI_STUDIO)
52
-
53
 
54
 
55
 
@@ -104,6 +101,7 @@ print("google-generativeai:", genai.__version__)
104
 
105
  GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
106
 
 
107
 
108
  TITLE1 = """<h1 align="center">Company Analysis</h1>"""
109
  TITLE2 = """<h1 align="center">Investment Strategy</h1>"""
@@ -335,6 +333,81 @@ bot_inputs = [
335
  chatbot_component
336
  ]
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  # Portfolio Analysis +++++++++++++++++++++++++++++++++++
339
 
340
  def plot_cum_returns(data, title):
@@ -413,11 +486,18 @@ def output_results(start_date, end_date, tickers_string):
413
  expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns
414
 
415
 
 
416
 
 
 
417
 
418
-
419
-
420
- # Interface =============================================
 
 
 
 
421
 
422
  with gr.Blocks() as demo:
423
  with gr.Tab("Portfolio Analysis"):
 
47
  if not GOOGLE_AI_STUDIO:
48
  raise ValueError("API key not found. Please set the GOOGLE_AI_STUDIO2 environment variable.")
49
 
 
 
 
50
 
51
 
52
 
 
101
 
102
  GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
103
 
104
+ TITLE_INTRO = """<h1 align="center">Introduction to Financial Manager</h1>"""
105
 
106
  TITLE1 = """<h1 align="center">Company Analysis</h1>"""
107
  TITLE2 = """<h1 align="center">Investment Strategy</h1>"""
 
333
  chatbot_component
334
  ]
335
 
336
+
337
+
338
+
339
+
340
+ # Gmix ++++++++++++++++++++++++++++++++++++++++++++++++
341
+
342
+ #Crew imports
343
+ from crewai import Agent, Task, Crew, Process
344
+
345
+ # Set gemini_llm
346
+ gemini_llm = GoogleGenerativeAI(model="gemini-pro", google_api_key=GOOGLE_AI_STUDIO)
347
+
348
+ def crewai_process(research_topic):
349
+ # Define your agents with roles and goals
350
+ researcher = Agent(
351
+ role='Senior Research Analyst',
352
+ goal=f'Uncover cutting-edge developments in {research_topic}',
353
+ backstory="""You are a Senior Research Analyst at a leading think tank.
354
+ Your expertise lies in identifying emerging trends. You have a knack for dissecting complex data and presenting
355
+ actionable insights.""",
356
+ verbose=True,
357
+ allow_delegation=False,
358
+ llm = gemini_llm,
359
+ tools=[
360
+ GeminiSearchTools.gemini_search
361
+ ]
362
+
363
+ )
364
+ writer = Agent(
365
+ role='Tech Content Strategist',
366
+ goal='Craft compelling content on tech advancements',
367
+ backstory="""You are a renowned Tech Social Media Content Writer and Strategist, known for your insightful
368
+ and engaging articles on technology and innovation. With a deep understanding of
369
+ the tech industry and how people are impacted by it, you transform complex concepts into compelling narratives.""",
370
+ verbose=True,
371
+ allow_delegation=True,
372
+ llm = gemini_llm
373
+
374
+ # Add tools and other optional parameters as needed
375
+ )
376
+
377
+ # Create tasks for your agents
378
+ task1 = Task(
379
+ description=f"""Conduct a comprehensive analysis of the latest advancements in {research_topic}.
380
+ Compile your findings in a detailed report. Your final answer MUST be a full analysis report""",
381
+ agent=researcher
382
+ )
383
+
384
+ task2 = Task(
385
+ description="""Using the insights from the researcher's report, develop an engaging blog
386
+ post that highlights the most significant advancements.
387
+ Your post should be informative yet accessible, catering to a tech-savvy audience.
388
+ Aim for a narrative that captures the essence of these breakthroughs and their
389
+ implications for the future. Your final answer MUST be the full blog post of at least 3 paragraphs.""",
390
+ agent=writer
391
+ )
392
+
393
+ # Instantiate your crew with a sequential process
394
+ crew = Crew(
395
+ agents=[researcher, writer],
396
+ tasks=[task1, task2],
397
+ verbose=2,
398
+ process=Process.sequential
399
+ )
400
+
401
+ # Get your crew to work!
402
+ result = crew.kickoff()
403
+
404
+ return result
405
+
406
+
407
+
408
+
409
+
410
+
411
  # Portfolio Analysis +++++++++++++++++++++++++++++++++++
412
 
413
  def plot_cum_returns(data, title):
 
486
  expected_annual_return, annual_volatility, sharpe_ratio, fig_indiv_prices, fig_cum_returns
487
 
488
 
489
+ # Interface =============================================
490
 
491
+ with gr.Tab("Introduction"):
492
+ gr.HTML(TITLE_INTRO)
493
 
494
+ with gr.Tab("Your Portfolio"):
495
+ gr.HTML(TITLE_INTRO)
496
+ fn=crewai_process,
497
+ inputs=gr.Textbox(lines=2, placeholder="Enter Research Topic Here..."),
498
+ outputs="text",
499
+ title="CrewAI on Gemini (Blog Post Writer)",
500
+ description="Input a research topic to get a comprehensive analysis (in logs) and a blog post draft (in output). To lea
501
 
502
  with gr.Blocks() as demo:
503
  with gr.Tab("Portfolio Analysis"):