Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
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 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
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:
|