muhammadanwar-31 commited on
Commit
b957d93
·
verified ·
1 Parent(s): 1ebac14

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # GROQ API details
5
+ GROQ_API_KEY = "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"
6
+ GROQ_URL = "https://api.groq.com/openai/v1/chat/completions"
7
+
8
+ # Function to generate contract
9
+ def generate_contract(client_name, contractor_name, project_scope, payment_terms):
10
+ prompt = f"""
11
+ Create a simple civil engineering contract between:
12
+ - Client: {client_name}
13
+ - Contractor: {contractor_name}
14
+ Scope of work: {project_scope}
15
+ Payment terms: {payment_terms}
16
+ Include start date, completion date, and general terms.
17
+ """
18
+
19
+ headers = {
20
+ "Authorization": f"Bearer {GROQ_API_KEY}",
21
+ "Content-Type": "application/json"
22
+ }
23
+ payload = {
24
+ "model": "llama3-70b-8192",
25
+ "messages": [{"role": "user", "content": prompt}],
26
+ "temperature": 0.7
27
+ }
28
+
29
+ response = requests.post(GROQ_URL, headers=headers, json=payload)
30
+ data = response.json()
31
+
32
+ return data['choices'][0]['message']['content']
33
+
34
+ # Gradio UI
35
+ with gr.Blocks() as demo:
36
+ gr.Markdown("## 🏗️ Civil Engineering Contract Generator")
37
+
38
+ client = gr.Textbox(label="Client Name")
39
+ contractor = gr.Textbox(label="Contractor Name")
40
+ scope = gr.Textbox(label="Project Scope")
41
+ payment = gr.Textbox(label="Payment Terms")
42
+
43
+ output = gr.Textbox(label="Generated Contract", lines=20)
44
+
45
+ btn = gr.Button("Generate Contract")
46
+ btn.click(generate_contract, inputs=[client, contractor, scope, payment], outputs=output)
47
+
48
+ demo.launch()