Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import os
|
|
2 |
import gradio as gr
|
3 |
import openai
|
4 |
from langdetect import detect
|
5 |
-
from fpdf import FPDF # To generate PDF
|
6 |
import json
|
7 |
|
8 |
# Set up OpenAI API with your custom endpoint
|
@@ -85,27 +84,6 @@ def format_response(data):
|
|
85 |
|
86 |
return formatted_response.strip()
|
87 |
|
88 |
-
# Function to generate PDF based on investment data
|
89 |
-
def generate_pdf(company_name, investment_data):
|
90 |
-
pdf = FPDF()
|
91 |
-
pdf.set_auto_page_break(auto=True, margin=15)
|
92 |
-
pdf.add_page()
|
93 |
-
|
94 |
-
# Title
|
95 |
-
pdf.set_font("Arial", 'B', 16)
|
96 |
-
pdf.cell(200, 10, f"Investment Report for {company_name}", ln=True, align="C")
|
97 |
-
|
98 |
-
# Adding investment data
|
99 |
-
pdf.set_font("Arial", size=12)
|
100 |
-
pdf.ln(10)
|
101 |
-
pdf.multi_cell(0, 10, f"Investment Data:\n\n{investment_data}")
|
102 |
-
|
103 |
-
# Save PDF to file
|
104 |
-
pdf_output = f"{company_name}_investment_report.pdf"
|
105 |
-
pdf.output(pdf_output)
|
106 |
-
|
107 |
-
return pdf_output
|
108 |
-
|
109 |
# Function to handle the interaction and queries
|
110 |
def market_analysis_agent(user_input, history=[]):
|
111 |
try:
|
@@ -120,13 +98,7 @@ def market_analysis_agent(user_input, history=[]):
|
|
120 |
return history, history
|
121 |
|
122 |
# Handle private market queries with datasets
|
123 |
-
if "
|
124 |
-
company_name = "Razorpay" # Example; in real scenario, extract from user input
|
125 |
-
investment_data = "Investment data for Razorpay will go here." # Replace with actual data retrieval logic
|
126 |
-
pdf_output = generate_pdf(company_name, investment_data)
|
127 |
-
return history, gr.File(pdf_output) # Returning the generated PDF file
|
128 |
-
|
129 |
-
elif "company" in user_input.lower():
|
130 |
response = company_profile
|
131 |
elif "financials" in user_input.lower():
|
132 |
response = financials
|
|
|
2 |
import gradio as gr
|
3 |
import openai
|
4 |
from langdetect import detect
|
|
|
5 |
import json
|
6 |
|
7 |
# Set up OpenAI API with your custom endpoint
|
|
|
84 |
|
85 |
return formatted_response.strip()
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
# Function to handle the interaction and queries
|
88 |
def market_analysis_agent(user_input, history=[]):
|
89 |
try:
|
|
|
98 |
return history, history
|
99 |
|
100 |
# Handle private market queries with datasets
|
101 |
+
if "company" in user_input.lower():
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
response = company_profile
|
103 |
elif "financials" in user_input.lower():
|
104 |
response = financials
|