Spaces:
Running
Running
Yuki Kobiyama
commited on
Commit
•
6584696
1
Parent(s):
347ac45
feat: change model
Browse files- src/forms.py +1 -1
- src/generate_query_all.py +18 -16
src/forms.py
CHANGED
@@ -352,7 +352,7 @@ def change_request_form(embed_output):
|
|
352 |
|
353 |
client = OpenAI(api_key=open_api_key)
|
354 |
response = client.chat.completions.create(
|
355 |
-
model="gpt-
|
356 |
messages=[
|
357 |
{"role": "system", "content": system_prompt},
|
358 |
{"role": "user", "content": user_prompt},
|
|
|
352 |
|
353 |
client = OpenAI(api_key=open_api_key)
|
354 |
response = client.chat.completions.create(
|
355 |
+
model="gpt-4o",
|
356 |
messages=[
|
357 |
{"role": "system", "content": system_prompt},
|
358 |
{"role": "user", "content": user_prompt},
|
src/generate_query_all.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
-
from openai import OpenAI
|
2 |
import json
|
3 |
import os
|
|
|
4 |
from dotenv import load_dotenv
|
|
|
5 |
from openpyxl import load_workbook
|
6 |
|
|
|
7 |
def make_json(type, subtype, subtype2, items):
|
8 |
-
name = f
|
9 |
|
10 |
with open("data/template.json", "r") as f:
|
11 |
template = f.read()
|
@@ -13,7 +15,7 @@ def make_json(type, subtype, subtype2, items):
|
|
13 |
template = json.loads(template)
|
14 |
|
15 |
template["name"] = name
|
16 |
-
#print(template)
|
17 |
|
18 |
prompt = f"""
|
19 |
あなたは製薬会社の優秀なQAです。
|
@@ -33,7 +35,7 @@ def make_json(type, subtype, subtype2, items):
|
|
33 |
"""
|
34 |
|
35 |
completion = client.chat.completions.create(
|
36 |
-
model="gpt-
|
37 |
messages=[
|
38 |
{
|
39 |
"role": "user",
|
@@ -44,7 +46,7 @@ def make_json(type, subtype, subtype2, items):
|
|
44 |
temperature=0.7,
|
45 |
)
|
46 |
|
47 |
-
#print(completion.choices[0].message.content)
|
48 |
|
49 |
with open(f"data/questions/{name}.json", "w") as f:
|
50 |
f.write(completion.choices[0].message.content)
|
@@ -55,24 +57,24 @@ open_api_key = os.environ.get("OPENAI_API_KEY")
|
|
55 |
client = OpenAI(api_key=open_api_key)
|
56 |
|
57 |
|
58 |
-
wb = load_workbook(
|
59 |
-
type =
|
60 |
subtype2 = "x"
|
61 |
-
sheet = wb[type]
|
62 |
subtype = "包装工程のパラメーター変更"
|
63 |
qs = []
|
64 |
|
65 |
for i in range(40, 52):
|
66 |
-
if sheet[f
|
67 |
-
qs.append(sheet[f
|
68 |
-
print(sheet[f
|
69 |
else:
|
70 |
make_json(type, subtype, subtype2, qs)
|
71 |
-
print(f
|
72 |
qs = []
|
73 |
-
qs.append(sheet[f
|
74 |
-
print(sheet[f
|
75 |
-
subtype = sheet[f
|
76 |
|
77 |
make_json(type, subtype, subtype2, qs)
|
78 |
-
print(f
|
|
|
|
|
1 |
import json
|
2 |
import os
|
3 |
+
|
4 |
from dotenv import load_dotenv
|
5 |
+
from openai import OpenAI
|
6 |
from openpyxl import load_workbook
|
7 |
|
8 |
+
|
9 |
def make_json(type, subtype, subtype2, items):
|
10 |
+
name = f"{type}_{subtype}_{subtype2}"
|
11 |
|
12 |
with open("data/template.json", "r") as f:
|
13 |
template = f.read()
|
|
|
15 |
template = json.loads(template)
|
16 |
|
17 |
template["name"] = name
|
18 |
+
# print(template)
|
19 |
|
20 |
prompt = f"""
|
21 |
あなたは製薬会社の優秀なQAです。
|
|
|
35 |
"""
|
36 |
|
37 |
completion = client.chat.completions.create(
|
38 |
+
model="gpt-4o",
|
39 |
messages=[
|
40 |
{
|
41 |
"role": "user",
|
|
|
46 |
temperature=0.7,
|
47 |
)
|
48 |
|
49 |
+
# print(completion.choices[0].message.content)
|
50 |
|
51 |
with open(f"data/questions/{name}.json", "w") as f:
|
52 |
f.write(completion.choices[0].message.content)
|
|
|
57 |
client = OpenAI(api_key=open_api_key)
|
58 |
|
59 |
|
60 |
+
wb = load_workbook("data/変更リスクアセスメント表2023.12.22更新 .xlsx")
|
61 |
+
type = "製造方法・製造設備"
|
62 |
subtype2 = "x"
|
63 |
+
sheet = wb[type]
|
64 |
subtype = "包装工程のパラメーター変更"
|
65 |
qs = []
|
66 |
|
67 |
for i in range(40, 52):
|
68 |
+
if sheet[f"C{i}"].value == None or sheet[f"C{i}"].value == subtype:
|
69 |
+
qs.append(sheet[f"F{i}"].value)
|
70 |
+
print(sheet[f"F{i}"].value)
|
71 |
else:
|
72 |
make_json(type, subtype, subtype2, qs)
|
73 |
+
print(f"{type}_{subtype}_{subtype2}_completed")
|
74 |
qs = []
|
75 |
+
qs.append(sheet[f"F{i}"].value)
|
76 |
+
print(sheet[f"F{i}"].value)
|
77 |
+
subtype = sheet[f"C{i}"].value
|
78 |
|
79 |
make_json(type, subtype, subtype2, qs)
|
80 |
+
print(f"{type}_{subtype}_{subtype2}_completed")
|