Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -124,16 +124,16 @@ For each line item, provide the Description, Tax Percentage, Tax Amount, and Amo
|
|
| 124 |
If certain values are missing or not applicable, leave them empty or set them as null where necessary.
|
| 125 |
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."""
|
| 126 |
try:
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
)
|
| 136 |
-
|
| 137 |
print("Before content:", content)
|
| 138 |
cleaned_content = re.sub(r'^.*```json\n', '', content) # Remove '```json\n' at the beginning
|
| 139 |
cleaned_content = re.sub(r'\n```$', '', cleaned_content) # Remove '\n```' at the end
|
|
|
|
| 124 |
If certain values are missing or not applicable, leave them empty or set them as null where necessary.
|
| 125 |
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."""
|
| 126 |
try:
|
| 127 |
+
response = openai.ChatCompletion.create(
|
| 128 |
+
model="gpt-4o-mini",
|
| 129 |
+
messages=[
|
| 130 |
+
{"role": "system", "content": system_prompt},
|
| 131 |
+
{"role": "user", "content": f"{text}"}
|
| 132 |
+
],
|
| 133 |
+
temperature=0.5,
|
| 134 |
+
max_tokens=16384
|
| 135 |
)
|
| 136 |
+
content = response.choices[0].message.content.strip()
|
| 137 |
print("Before content:", content)
|
| 138 |
cleaned_content = re.sub(r'^.*```json\n', '', content) # Remove '```json\n' at the beginning
|
| 139 |
cleaned_content = re.sub(r'\n```$', '', cleaned_content) # Remove '\n```' at the end
|