Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Import all data modules
|
5 |
+
from company_profile import company_profile
|
6 |
+
from financials import financials
|
7 |
+
from workforce import workforce
|
8 |
+
# Import other modules as needed
|
9 |
+
|
10 |
+
# Set up the OpenAI (GROQ) API
|
11 |
+
openai.api_key = "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"
|
12 |
+
openai.api_base = "https://api.groq.com/openai/v1"
|
13 |
+
|
14 |
+
# Function to query the AI agent
|
15 |
+
def query_ai(user_input):
|
16 |
+
# Contextual data from the application
|
17 |
+
context_data = f"""
|
18 |
+
Company Name: {company_profile['brand_name']}
|
19 |
+
Headquarters: {company_profile['headquarters']}
|
20 |
+
Founders: {', '.join(company_profile['founders'])}
|
21 |
+
Latest Valuation: {financials['latest_valuation']}
|
22 |
+
Total Funding: {financials['total_funding']}
|
23 |
+
Employees: {workforce['total_employees']}
|
24 |
+
"""
|
25 |
+
|
26 |
+
# Call the OpenAI API
|
27 |
+
try:
|
28 |
+
response = openai.ChatCompletion.create(
|
29 |
+
model="llama-3.1-70b-versatile",
|
30 |
+
messages=[
|
31 |
+
{"role": "system", "content": "You are a Private Market Analysis AI Agent."},
|
32 |
+
{"role": "user", "content": f"{context_data}\n\n{user_input}"}
|
33 |
+
]
|
34 |
+
)
|
35 |
+
return response.choices[0].message["content"]
|
36 |
+
except Exception as e:
|
37 |
+
return f"Error: {str(e)}"
|
38 |
+
|
39 |
+
# Gradio interface
|
40 |
+
def chatbot_interface(user_input):
|
41 |
+
return query_ai(user_input)
|
42 |
+
|
43 |
+
# Launch the Gradio app
|
44 |
+
gr.Interface(
|
45 |
+
fn=chatbot_interface,
|
46 |
+
inputs="text",
|
47 |
+
outputs="text",
|
48 |
+
title="Satyam Market Analysis",
|
49 |
+
description="Ask me about private companies like Razorpay, including financials, products, and more!"
|
50 |
+
).launch()
|