Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,35 +137,35 @@ Use the correct currency and amounts for each invoice field.
|
|
| 137 |
For each line item, provide the Description, Tax Percentage, Tax Amount, and Amount.
|
| 138 |
If certain values are missing or not applicable, leave them empty or set them as null where necessary.
|
| 139 |
This JSON format will be used to store and manage invoices in a structured and uniform way. Please ensure only return JSON format. No extra content should not provide."""
|
| 140 |
-
try:
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
except Exception as e:
|
| 168 |
-
|
| 169 |
# Dependency to check API Key
|
| 170 |
def verify_api_key(api_key: str = Header(...)):
|
| 171 |
if api_key != API_KEY:
|
|
|
|
| 137 |
For each line item, provide the Description, Tax Percentage, Tax Amount, and Amount.
|
| 138 |
If certain values are missing or not applicable, leave them empty or set them as null where necessary.
|
| 139 |
This JSON format will be used to store and manage invoices in a structured and uniform way. Please ensure only return JSON format. No extra content should not provide."""
|
| 140 |
+
# try:
|
| 141 |
+
# response = openai.ChatCompletion.create(
|
| 142 |
+
# model="gpt-4o-mini",
|
| 143 |
+
# messages=[
|
| 144 |
+
# {"role": "system", "content": system_prompt},
|
| 145 |
+
# {"role": "user", "content": f"{text}"}
|
| 146 |
+
# ],
|
| 147 |
+
# temperature=0.5,
|
| 148 |
+
# max_tokens=16384
|
| 149 |
+
# )
|
| 150 |
+
# content = response.choices[0].message.content.strip()
|
| 151 |
+
# print("Before content:", content)
|
| 152 |
+
# cleaned_content = re.sub(r'^.*```json\n', '', content) # Remove '```json\n' at the beginning
|
| 153 |
+
# cleaned_content = re.sub(r'\n```$', '', cleaned_content) # Remove '\n```' at the end
|
| 154 |
+
|
| 155 |
+
# # Step 2: Parse the cleaned content as JSON
|
| 156 |
+
# #parsed_content = json.loads(cleaned_content)
|
| 157 |
+
|
| 158 |
+
# # Step 3: Print the parsed JSON object
|
| 159 |
+
# try:
|
| 160 |
+
# parsed_content = json.loads(cleaned_content)
|
| 161 |
+
# return parsed_content
|
| 162 |
+
# except json.JSONDecodeError as e:
|
| 163 |
+
# print("Error parsing JSON:", e)
|
| 164 |
+
# # Optionally, print the cleaned content to debug
|
| 165 |
+
# print("Cleaned content:", cleaned_content)
|
| 166 |
+
# return None
|
| 167 |
+
# except Exception as e:
|
| 168 |
+
# return f"Error in summarization: {str(e)}"
|
| 169 |
# Dependency to check API Key
|
| 170 |
def verify_api_key(api_key: str = Header(...)):
|
| 171 |
if api_key != API_KEY:
|