Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -97,7 +97,7 @@ if st.session_state.df is not None:
|
|
97 |
return QuerySQLDataBaseTool(db=db).invoke(sql_query)
|
98 |
|
99 |
# --- CrewAI Agents for Patent Analysis ---
|
100 |
-
|
101 |
role="Patent Data Analyst",
|
102 |
goal="Extract patent data using optimized SQL queries.",
|
103 |
backstory="An expert in writing optimized SQL queries for complex patent databases.",
|
@@ -105,17 +105,17 @@ if st.session_state.df is not None:
|
|
105 |
tools=[list_tables, tables_schema, execute_sql],
|
106 |
)
|
107 |
|
108 |
-
|
109 |
-
role="Patent Analyst",
|
110 |
-
goal="Analyze
|
111 |
-
backstory="
|
112 |
llm=llm,
|
113 |
)
|
114 |
|
115 |
-
|
116 |
role="Patent Report Writer",
|
117 |
goal="Summarize patent insights into a clear report.",
|
118 |
-
backstory="Expert in summarizing patent data into comprehensive reports.",
|
119 |
llm=llm,
|
120 |
)
|
121 |
|
@@ -123,33 +123,33 @@ if st.session_state.df is not None:
|
|
123 |
extract_data = Task(
|
124 |
description="Extract patents related to the query: {query}.",
|
125 |
expected_output="Patent data matching the query.",
|
126 |
-
agent=
|
127 |
)
|
128 |
|
129 |
analyze_data = Task(
|
130 |
-
description="Analyze the extracted patent data.",
|
131 |
-
expected_output="
|
132 |
-
agent=
|
133 |
context=[extract_data],
|
134 |
)
|
135 |
|
136 |
write_report = Task(
|
137 |
description="Summarize analysis into an executive report.",
|
138 |
-
expected_output="Markdown report of
|
139 |
agent=report_writer,
|
140 |
-
context=[
|
141 |
)
|
142 |
|
143 |
# Assemble Crew
|
144 |
crew = Crew(
|
145 |
-
agents=[
|
146 |
tasks=[extract_data, analyze_data, write_report],
|
147 |
process=Process.sequential,
|
148 |
verbose=True,
|
149 |
)
|
150 |
|
151 |
#Query Input for Patent Analysis
|
152 |
-
query = st.text_area("Enter Patent Analysis Query:", placeholder="e.g., '
|
153 |
if st.button("Submit Query"):
|
154 |
with st.spinner("Processing your query..."):
|
155 |
inputs = {"query": query}
|
|
|
97 |
return QuerySQLDataBaseTool(db=db).invoke(sql_query)
|
98 |
|
99 |
# --- CrewAI Agents for Patent Analysis ---
|
100 |
+
patent_sql_dev = Agent(
|
101 |
role="Patent Data Analyst",
|
102 |
goal="Extract patent data using optimized SQL queries.",
|
103 |
backstory="An expert in writing optimized SQL queries for complex patent databases.",
|
|
|
105 |
tools=[list_tables, tables_schema, execute_sql],
|
106 |
)
|
107 |
|
108 |
+
patent_data_analyst = Agent(
|
109 |
+
role="Patent Data Analyst",
|
110 |
+
goal="Analyze the data and produce insights.",
|
111 |
+
backstory="A seasoned analyst who identifies trends and patterns in datasets.",
|
112 |
llm=llm,
|
113 |
)
|
114 |
|
115 |
+
patent_report_writer = Agent(
|
116 |
role="Patent Report Writer",
|
117 |
goal="Summarize patent insights into a clear report.",
|
118 |
+
backstory="Expert in summarizing patent data insights into comprehensive reports.",
|
119 |
llm=llm,
|
120 |
)
|
121 |
|
|
|
123 |
extract_data = Task(
|
124 |
description="Extract patents related to the query: {query}.",
|
125 |
expected_output="Patent data matching the query.",
|
126 |
+
agent=patent_sql_dev,
|
127 |
)
|
128 |
|
129 |
analyze_data = Task(
|
130 |
+
description="Analyze the extracted patent data for query: {query}.",
|
131 |
+
expected_output="Analysis text summarizing findings.",
|
132 |
+
agent=patent_data_analyst,
|
133 |
context=[extract_data],
|
134 |
)
|
135 |
|
136 |
write_report = Task(
|
137 |
description="Summarize analysis into an executive report.",
|
138 |
+
expected_output="Markdown report of insights.",
|
139 |
agent=report_writer,
|
140 |
+
context=[patent_analyze_data],
|
141 |
)
|
142 |
|
143 |
# Assemble Crew
|
144 |
crew = Crew(
|
145 |
+
agents=[patent_sql_dev, patent_data_analyst, patent_report_writer],
|
146 |
tasks=[extract_data, analyze_data, write_report],
|
147 |
process=Process.sequential,
|
148 |
verbose=True,
|
149 |
)
|
150 |
|
151 |
#Query Input for Patent Analysis
|
152 |
+
query = st.text_area("Enter Patent Analysis Query:", placeholder="e.g., 'How many patents related to Machine Learning were filed after 2016?'")
|
153 |
if st.button("Submit Query"):
|
154 |
with st.spinner("Processing your query..."):
|
155 |
inputs = {"query": query}
|