Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(mess
|
|
20 |
|
21 |
OPENAI_KEY = os.environ.get("OPENAI_API_KEY", "")
|
22 |
openai.api_key = OPENAI_KEY
|
23 |
-
OPENAI_MODEL = "gpt-
|
24 |
OPENAI_MAX_TOKENS = 32768
|
25 |
|
26 |
DB_PATH = "maiko_dash_docs.sqlite"
|
@@ -651,7 +651,7 @@ def unified_handler(contents_lists, n_clicks_generate_list, n_clicks_download, s
|
|
651 |
|
652 |
def openai_thread():
|
653 |
try:
|
654 |
-
response = openai.
|
655 |
model=OPENAI_MODEL,
|
656 |
messages=[
|
657 |
{"role": "system", "content": "You are a helpful assistant for proposal writing. Always output in markdown, and use markdown tables for spreadsheets if needed."},
|
@@ -660,7 +660,7 @@ def unified_handler(contents_lists, n_clicks_generate_list, n_clicks_download, s
|
|
660 |
max_tokens=OPENAI_MAX_TOKENS,
|
661 |
temperature=0.3,
|
662 |
)
|
663 |
-
result_text = response
|
664 |
result_holder['result'] = result_text
|
665 |
logging.info("OpenAI document generated successfully.")
|
666 |
except Exception as e:
|
|
|
20 |
|
21 |
OPENAI_KEY = os.environ.get("OPENAI_API_KEY", "")
|
22 |
openai.api_key = OPENAI_KEY
|
23 |
+
OPENAI_MODEL = "gpt-3.5-turbo"
|
24 |
OPENAI_MAX_TOKENS = 32768
|
25 |
|
26 |
DB_PATH = "maiko_dash_docs.sqlite"
|
|
|
651 |
|
652 |
def openai_thread():
|
653 |
try:
|
654 |
+
response = openai.ChatCompletion.create(
|
655 |
model=OPENAI_MODEL,
|
656 |
messages=[
|
657 |
{"role": "system", "content": "You are a helpful assistant for proposal writing. Always output in markdown, and use markdown tables for spreadsheets if needed."},
|
|
|
660 |
max_tokens=OPENAI_MAX_TOKENS,
|
661 |
temperature=0.3,
|
662 |
)
|
663 |
+
result_text = response['choices'][0]['message']['content'] if 'choices' in response and response['choices'] and 'message' in response['choices'][0] and 'content' in response['choices'][0]['message'] else str(response)
|
664 |
result_holder['result'] = result_text
|
665 |
logging.info("OpenAI document generated successfully.")
|
666 |
except Exception as e:
|