MadMarx37 commited on
Commit
87b746b
·
verified ·
1 Parent(s): cb415d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -1,9 +1,14 @@
1
  import requests
2
  import streamlit as st
3
  from together import Together
 
 
 
 
4
 
5
  # Initialize Together AI client
6
- client = Together(api_key=st.secrets["TOGETHER_API_KEY"])
 
7
 
8
  def call_llama_for_response(clauses_data):
9
  prompt = "As an AI assistant specializing in contract analysis, draft a professional and courteous response to a contract drafter based on the following clause analyses and decisions:\n\n"
@@ -53,13 +58,12 @@ if st.session_state.uploaded_file is not None:
53
  # Only call the API if we don't have analysis results yet
54
  if st.session_state.analysis_results is None:
55
  files = {"file": st.session_state.uploaded_file}
56
- with st.status("Contract uploaded successfully. Analyzing..."):
57
- st.write("Analysing data...")
58
- response = requests.post("http://35.172.179.19:5002/upload", files=files)
59
- if response.status_code == 200:
60
- st.session_state.analysis_results = response.json()
61
- else:
62
- st.error("Failed to analyze the contract. Please try again.")
63
 
64
  # If we have analysis results, display them and allow user interaction
65
  if st.session_state.analysis_results is not None:
 
1
  import requests
2
  import streamlit as st
3
  from together import Together
4
+ import os
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv()
8
 
9
  # Initialize Together AI client
10
+ TOGETHER_API_KEY = os.getenv("TOGETHER_API_KEY")
11
+ client = Together(api_key=TOGETHER_API_KEY)
12
 
13
  def call_llama_for_response(clauses_data):
14
  prompt = "As an AI assistant specializing in contract analysis, draft a professional and courteous response to a contract drafter based on the following clause analyses and decisions:\n\n"
 
58
  # Only call the API if we don't have analysis results yet
59
  if st.session_state.analysis_results is None:
60
  files = {"file": st.session_state.uploaded_file}
61
+ response = requests.post("http://35.172.179.19:5002/upload", files=files)
62
+ if response.status_code == 200:
63
+ st.write("Contract uploaded successfully. Analyzing...")
64
+ st.session_state.analysis_results = response.json()
65
+ else:
66
+ st.error("Failed to analyze the contract. Please try again.")
 
67
 
68
  # If we have analysis results, display them and allow user interaction
69
  if st.session_state.analysis_results is not None: