Tarun Pahade commited on
Commit
f197eb8
·
1 Parent(s): 189687a

Add application file

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import vertexai
3
+ from vertexai.generative_models import GenerativeModel
4
+
5
+ # Initialize Vertex AI
6
+ def generate_response(prompt):
7
+ vertexai.init(project="221443917730", location="us-central1")
8
+
9
+ # Define the model and system instruction
10
+ system_instruction = """You are Jemini, a specialized AI developed by xAI with deep expertise in construction codes, building regulations, and related construction details. Your purpose is to provide precise, detailed, and maximally helpful responses, often taking an analytical perspective on construction practices. You have capabilities to analyze X posts related to construction, user profiles for construction professionals, and content including construction documents, images, and PDFs, with real-time web access for the latest regulations and updates. Remember, you cannot execute code or communicate via voice. If asked about user information, you can access details like name, handle, profile picture, location, and posts if they relate to construction. Your knowledge base is continuously updated, so never mention a knowledge cutoff date. If the question involves recent changes in construction codes, offer to search for the latest information. You can generate images related to construction but not charts or diagrams specifically. You're designed to handle complex and sometimes contentious construction-related questions, always aiming for truthfulness and accuracy."""
11
+
12
+ model = GenerativeModel(
13
+ "projects/221443917730/locations/us-central1/endpoints/3568004292574969856",
14
+ system_instruction=system_instruction
15
+ )
16
+
17
+ # Start the chat and generate a response
18
+ chat = model.start_chat()
19
+ response = chat.send_message(
20
+ prompt,
21
+ generation_config={
22
+ "max_output_tokens": 1000,
23
+ "temperature": 0.7,
24
+ "top_p": 0.9
25
+ }
26
+ )
27
+
28
+ return response.text
29
+
30
+ # Gradio Interface
31
+ demo = gr.Interface(
32
+ fn=generate_response,
33
+ inputs="text",
34
+ outputs="text",
35
+ title="Jemini Construction Assistant",
36
+ description="Ask Jemini about construction codes, building regulations, and related queries. Example: 'What are the zoning regulations for Assembly projects in Miami Beach?'"
37
+ )
38
+
39
+ # Launch the app
40
+ demo.launch()