Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
import smtplib
|
| 4 |
from email.mime.text import MIMEText
|
| 5 |
from email.mime.multipart import MIMEMultipart
|
|
@@ -23,7 +23,7 @@ class POGenerator:
|
|
| 23 |
def __init__(self):
|
| 24 |
if not OPENAI_API_KEY:
|
| 25 |
raise ValueError("OPENAI_API_KEY not found in environment variables")
|
| 26 |
-
|
| 27 |
self.template_doc = None
|
| 28 |
self.load_template()
|
| 29 |
|
|
@@ -58,7 +58,7 @@ class POGenerator:
|
|
| 58 |
Please provide values for the following placeholders: {', '.join(placeholders)}
|
| 59 |
Format the response as a JSON object with placeholder names as keys."""
|
| 60 |
|
| 61 |
-
response =
|
| 62 |
model="gpt-3.5-turbo",
|
| 63 |
messages=[
|
| 64 |
{"role": "system", "content": "You are a professional purchase order generator."},
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from openai import OpenAI
|
| 3 |
import smtplib
|
| 4 |
from email.mime.text import MIMEText
|
| 5 |
from email.mime.multipart import MIMEMultipart
|
|
|
|
| 23 |
def __init__(self):
|
| 24 |
if not OPENAI_API_KEY:
|
| 25 |
raise ValueError("OPENAI_API_KEY not found in environment variables")
|
| 26 |
+
self.client = OpenAI(api_key=OPENAI_API_KEY)
|
| 27 |
self.template_doc = None
|
| 28 |
self.load_template()
|
| 29 |
|
|
|
|
| 58 |
Please provide values for the following placeholders: {', '.join(placeholders)}
|
| 59 |
Format the response as a JSON object with placeholder names as keys."""
|
| 60 |
|
| 61 |
+
response = self.client.chat.completions.create(
|
| 62 |
model="gpt-3.5-turbo",
|
| 63 |
messages=[
|
| 64 |
{"role": "system", "content": "You are a professional purchase order generator."},
|