youngtsai commited on
Commit
28e9de2
1 Parent(s): d8ab087

sys_content = f"你是一個資料分析師,請精讀資料,並用既有資料為本質猜測用戶可能會問的問題,使用 zh-TW"

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -35,10 +35,10 @@ def update_buttons(df_string):
35
  def generate_questions(df_string):
36
  # 使用 OpenAI 生成基于上传数据的问题
37
 
38
- sys_content = f"你是一個資料分析師,請用 {df_string_output} 為資料進行對話,使用 zh-TW"
39
  messages = [
40
  {"role": "system", "content": sys_content},
41
- {"role": "user", "content": "請根據 {df_string_output} 生成三個問題,並用 JSON 格式返回 questions:[q1, q2, q3]"}
42
  ]
43
  response_format = { "type": "json_object" }
44
 
@@ -54,7 +54,8 @@ def generate_questions(df_string):
54
  "response_format": response_format
55
  }
56
 
57
- json_response = client.chat.completions.create(**request_payload)
 
58
  print("=====json_response=====")
59
  print(json_response)
60
 
 
35
  def generate_questions(df_string):
36
  # 使用 OpenAI 生成基于上传数据的问题
37
 
38
+ sys_content = f"你是一個資料分析師,請精讀資料,並用既有資料為本質猜測用戶可能會問的問題,使用 zh-TW"
39
  messages = [
40
  {"role": "system", "content": sys_content},
41
+ {"role": "user", "content": "請根據 {df_string} 生成三個問題,並用 JSON 格式返回 questions:[q1, q2, q3]"}
42
  ]
43
  response_format = { "type": "json_object" }
44
 
 
54
  "response_format": response_format
55
  }
56
 
57
+ response = client.chat.completions.create(**request_payload)
58
+ json_response = response.choices[0].message.content["questions"]
59
  print("=====json_response=====")
60
  print(json_response)
61