SIUBIU commited on
Commit
8d805f4
1 Parent(s): 164398f

Update prompt_gen.py

Browse files
Files changed (1) hide show
  1. prompt_gen.py +39 -38
prompt_gen.py CHANGED
@@ -1,38 +1,39 @@
1
- import pandas as pd
2
- import os
3
- from openai import OpenAI
4
-
5
- nv_prompt_file = pd.read_excel('汉服-女词库.xlsx')
6
- na_prompt_file = pd.read_excel('汉服-男词库.xlsx')
7
- nv_prompt = nv_prompt_file.to_string(index=False)
8
- na_prompt = na_prompt_file.to_string(index=False)
9
-
10
- os.environ["OPENAI_API_KEY"] = "sk-vtyR3fdgk08jmJ5e3eF6F5Ef663c4a3bAd0166C3549a1a8e"
11
- os.environ["OPENAI_BASE_URL"] = "http://15.204.101.64:4000/v1"
12
-
13
-
14
- def prompt_gen(advise, gender):
15
- if gender == "男":
16
- prompt = na_prompt
17
- trigger = "A Hanfu"
18
- else:
19
- prompt = nv_prompt
20
- trigger = "a Hanfu"
21
-
22
- client = OpenAI()
23
- completion = client.chat.completions.create(
24
- model="gpt-4o",
25
- messages=[
26
- {"role": "system",
27
- "content": "You are a helpful assistant.",},
28
- {"role": "user",
29
- "content": advise + "根据建议,从以下的触发词、种类、上衣、裙子、领子、袖子、袖口、腰饰、裙子详述中每个挑选一个词,分点描述,触发词固定选择为" + trigger +
30
- ", 把英文也附在后面的括号里,然后在下面先加一条prompt,标题为‘# prompt’,并在此标题下总结所有英文描述,用逗"
31
- "号间隔,再加上‘, (white background)’, 然后换行后以'promptEnd'结尾;再然后加一条服饰风格介绍,标题为"
32
- "‘# 服饰风格介绍’,并在此标题下以介绍的口吻总结所有的中文描述。" + prompt,
33
- }
34
- ]
35
-
36
- )
37
- print(completion.choices[0].message.content)
38
- return completion.choices[0].message.content
 
 
1
+ import pandas as pd
2
+ import os
3
+ from openai import OpenAI
4
+
5
+ nv_prompt_file = pd.read_excel('汉服-女词库.xlsx')
6
+ na_prompt_file = pd.read_excel('汉服-男词库.xlsx')
7
+ nv_prompt = nv_prompt_file.to_string(index=False)
8
+ na_prompt = na_prompt_file.to_string(index=False)
9
+
10
+ os.environ["OPENAI_API_KEY"] = "sk-vtyR3fdgk08jmJ5e3eF6F5Ef663c4a3bAd0166C3549a1a8e"
11
+ os.environ["OPENAI_BASE_URL"] = "http://15.204.101.64:4000/v1"
12
+
13
+
14
+ def prompt_gen(advise, gender):
15
+ print(gender)
16
+ if gender == "男":
17
+ prompt = na_prompt
18
+ trigger = "A Hanfu"
19
+ else:
20
+ prompt = nv_prompt
21
+ trigger = "a Hanfu"
22
+
23
+ client = OpenAI()
24
+ completion = client.chat.completions.create(
25
+ model="gpt-4o",
26
+ messages=[
27
+ {"role": "system",
28
+ "content": "You are a helpful assistant.",},
29
+ {"role": "user",
30
+ "content": advise + "根据建议,从以下的触发词、种类、上衣、裙子、领子、袖子、袖口、腰饰、裙子详述中每个挑选一个词,分点描述,触发词固定选择为" + trigger +
31
+ ", 把英文也附在后面的括号里,然后在下面先加一条prompt,标题为‘# prompt’,并在此标题下总结所有英文描述,用逗"
32
+ "号间隔,再加上‘, (white background)’, 然后换行后以'promptEnd'结尾;再然后加一条服饰风格介绍,标题为"
33
+ "‘# 服饰风格介绍’,并在此标题下以介绍的口吻总结所有的中文描述。" + prompt,
34
+ }
35
+ ]
36
+
37
+ )
38
+ print(completion.choices[0].message.content)
39
+ return completion.choices[0].message.content