manatoboys commited on
Commit
1c02642
·
1 Parent(s): 0e9d0eb

エラー修正

Browse files
Files changed (2) hide show
  1. answers.py +8 -5
  2. src/group_classification.py +9 -9
answers.py CHANGED
@@ -48,7 +48,7 @@ def search(query) -> list:
48
 
49
  if run.status == "failed":
50
  logger.error(f"Run_failed: {run.last_error}, Run ID: {run.id}")
51
- return "Group 5", None, None, None
52
  # sys.exit(1)
53
  elif run.status == "requires_action":
54
  logger.info(
@@ -61,7 +61,7 @@ def search(query) -> list:
61
  )
62
 
63
  if run is None:
64
- return "Group 5", None, None, None
65
 
66
  run = wait_for_run_completion(thread.id, run.id)
67
 
@@ -84,7 +84,7 @@ def search(query) -> list:
84
 
85
  if run.status == "failed":
86
  logger.error(f"Run_failed: {run.error}, Run ID: {run.id}")
87
- return "Group 5", None, None, None
88
  # sys.exit(1)
89
 
90
  elif run.status == "requires_action":
@@ -98,14 +98,17 @@ def search(query) -> list:
98
  )
99
 
100
  if run is None:
101
- return "Group 5", None, None, None
102
 
103
  run = wait_for_run_completion(thread.id, run.id)
104
 
105
  logger.info(f"Run status: {run.status}")
106
 
107
  group, related_url, unrelated_url, other_url = write_gspread(query)
108
- related_url_list = ', '.join(related_url)
 
 
 
109
  unrelated_url_list = ', '.join(unrelated_url)
110
  other_url_list = ', '.join(other_url)
111
  return group, related_url_list, unrelated_url_list, other_url_list
 
48
 
49
  if run.status == "failed":
50
  logger.error(f"Run_failed: {run.last_error}, Run ID: {run.id}")
51
+ return "Group 5", ['途中でエラー'], [], []
52
  # sys.exit(1)
53
  elif run.status == "requires_action":
54
  logger.info(
 
61
  )
62
 
63
  if run is None:
64
+ return "Group 5", ['途中でエラー'], [], []
65
 
66
  run = wait_for_run_completion(thread.id, run.id)
67
 
 
84
 
85
  if run.status == "failed":
86
  logger.error(f"Run_failed: {run.error}, Run ID: {run.id}")
87
+ return "Group 5", ['途中でエラー'], [], []
88
  # sys.exit(1)
89
 
90
  elif run.status == "requires_action":
 
98
  )
99
 
100
  if run is None:
101
+ return "Group 5", ['途中でエラー'], [], []
102
 
103
  run = wait_for_run_completion(thread.id, run.id)
104
 
105
  logger.info(f"Run status: {run.status}")
106
 
107
  group, related_url, unrelated_url, other_url = write_gspread(query)
108
+ if len(related_url) == 0:
109
+ related_url_list = '関連URLなし'
110
+ else:
111
+ related_url_list = ', '.join(related_url)
112
  unrelated_url_list = ', '.join(unrelated_url)
113
  other_url_list = ', '.join(other_url)
114
  return group, related_url_list, unrelated_url_list, other_url_list
src/group_classification.py CHANGED
@@ -86,16 +86,16 @@ def main(PDF):
86
  message = [
87
  {"role": "system",
88
  "content":
89
- """You are an assistant designed to analyze provided text and answer questions regarding CO2 emissions and reduction targets.
90
- When given a prompt, you should extract the relevant information from the provided text and answer in the form (排出量, 削減目標).
91
- - 排出量 (CO2 Emission): Answer 1 if there is any mention of CO2 emissions, otherwise answer 0.
92
- - 削減目標 (Reduction Target): Answer 1 if there is any mention of a CO2 emission reduction target, otherwise answer 0.
93
- Example:
94
- - If the text mentions CO2 emissions but does not mention any reduction targets, your response should be (1, 0).
95
- - If the text mentions neither CO2 emissions nor reduction targets, your response should be (0, 0)."""
96
- },
97
  {"role": "user",
98
- "content": f"""Using the provided information: {texts}, please answer the following question in the given form (排出量, 削減目標): {query}."""}
99
  ]
100
 
101
  response = client.chat.completions.create(
 
86
  message = [
87
  {"role": "system",
88
  "content":
89
+ """You are an assistant designed to analyze provided text and answer questions regarding CO2 emissions and reduction targets.
90
+ When given a prompt, you should extract the relevant information from the provided text and answer in the form (排出量, 削減目標).
91
+ - 排出量 (CO2 Emission): Answer 1 if there is any mention of CO2 emissions, otherwise answer 0.
92
+ - 削減目標 (Reduction Target): Answer 1 if there is any mention of a CO2 emission reduction target, otherwise answer 0.
93
+ Example:
94
+ - If the text mentions CO2 emissions but does not mention any reduction targets, your response should be (1, 0).
95
+ - If the text mentions neither CO2 emissions nor reduction targets, your response should be (0, 0)."""
96
+ },
97
  {"role": "user",
98
+ "content": f"""Using the provided information: {texts}, please answer the following question in the given form (排出量, 削減目標): {query}."""}
99
  ]
100
 
101
  response = client.chat.completions.create(