bluenevus commited on
Commit
6b2e1be
·
1 Parent(s): c73b5e0

Update app.py via AI Editor

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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-4.1"
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.chat.completions.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,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.choices[0].message.content if hasattr(response.choices[0].message, "content") else str(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: