DrishtiSharma commited on
Commit
d3b0a19
·
verified ·
1 Parent(s): 65c3595

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
3
  from crewai import Agent, Task, Crew
4
  import os
5
  from langchain_groq import ChatGroq
 
6
  from fpdf import FPDF
7
  import pandas as pd
8
  import plotly.express as px
@@ -24,6 +25,34 @@ st.sidebar.header("User Inputs")
24
  patent_area = st.text_input("Enter Patent Technology Area", value="Transparent Antennas for Windshields")
25
  stakeholder = st.text_input("Enter Stakeholder", value="Patent Attorneys")
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  # Advanced Options
28
  st.sidebar.header("Advanced Options")
29
  enable_advanced_analysis = st.sidebar.checkbox("Enable Advanced Analysis", value=True)
@@ -51,9 +80,6 @@ with st.sidebar.expander("Customize Agent Goals", expanded=False):
51
  writer_goal = "Craft a professional insights document summarizing trends, strategies, and actionable outcomes for stakeholders."
52
  analyst_goal = "Perform detailed statistical analysis of patent filings, growth trends, and innovation distribution."
53
 
54
- # LLM Initialization
55
- llm = ChatGroq(groq_api_key=os.getenv("GROQ_API_KEY"), model="groq/llama-3.3-70b-versatile")
56
-
57
  # Agent Definitions
58
  planner = Agent(
59
  role="Patent Research Consultant",
 
3
  from crewai import Agent, Task, Crew
4
  import os
5
  from langchain_groq import ChatGroq
6
+ from langchain_openai import ChatOpenAI
7
  from fpdf import FPDF
8
  import pandas as pd
9
  import plotly.express as px
 
25
  patent_area = st.text_input("Enter Patent Technology Area", value="Transparent Antennas for Windshields")
26
  stakeholder = st.text_input("Enter Stakeholder", value="Patent Attorneys")
27
 
28
+ # Initialize LLM
29
+ llm = None
30
+
31
+ # Model Selection
32
+ #st.header("Model Selection")
33
+ model_choice = st.radio("Select LLM", ["OpenAI Model", "Groq-based LLM"], index=0, horizontal=True)
34
+
35
+
36
+ # API Key Validation and LLM Initialization
37
+ groq_api_key = os.getenv("GROQ_API_KEY")
38
+ openai_api_key = os.getenv("OPENAI_API_KEY")
39
+
40
+ #llm = ChatGroq(groq_api_key=os.getenv("GROQ_API_KEY"), model="groq/llama-3.3-70b-versatile")
41
+
42
+ if model_choice == "Groq-based LLM":
43
+ if not groq_api_key:
44
+ st.error("Groq API key is missing. Please set the GROQ_API_KEY environment variable.")
45
+ llm = None
46
+ else:
47
+ llm = ChatGroq(groq_api_key=groq_api_key, model="groq/llama-3.3-70b-versatile")
48
+ elif model_choice == "OpenAI Model":
49
+ if not openai_api_key:
50
+ st.error("OpenAI API key is missing. Please set the OPENAI_API_KEY environment variable.")
51
+ llm = None
52
+ else:
53
+ llm = ChatOpenAI(api_key=openai_api_key, model="gpt-4o")
54
+
55
+
56
  # Advanced Options
57
  st.sidebar.header("Advanced Options")
58
  enable_advanced_analysis = st.sidebar.checkbox("Enable Advanced Analysis", value=True)
 
80
  writer_goal = "Craft a professional insights document summarizing trends, strategies, and actionable outcomes for stakeholders."
81
  analyst_goal = "Perform detailed statistical analysis of patent filings, growth trends, and innovation distribution."
82
 
 
 
 
83
  # Agent Definitions
84
  planner = Agent(
85
  role="Patent Research Consultant",