PPSharks commited on
Commit
cffd27b
1 Parent(s): a6c4b17

Upload 2 files

Browse files
Files changed (2) hide show
  1. prompt_gen.py +39 -39
  2. sugg_gene.py +34 -34
prompt_gen.py CHANGED
@@ -1,39 +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
- prompt = nv_prompt
16
- trigger = "a Hanfu"
17
- if gender == "男":
18
- prompt = na_prompt
19
- trigger = "A Hanfu"
20
- elif gender == "女":
21
- prompt = nv_prompt
22
- trigger = "a Hanfu"
23
-
24
- client = OpenAI()
25
- completion = client.chat.completions.create(
26
- model="gpt-4o",
27
- messages=[
28
- {"role": "system",
29
- "content": "You are a helpful assistant.",},
30
- {"role": "user",
31
- "content": advise + "根据上述建议,从以下prompt库中的触发词、种类、上衣、裙子、领子、袖子、袖口、腰饰、裙子详述中每个挑选一个词,分点描述,触发"
32
- "词固定选择为" + trigger + ",然后在最下面列出所有Prompt,以‘Begin’为开头后换行, 输出所有英文描述,用逗"
33
- "号间隔,再加上‘, white background’, 再然后换行后以'End'结尾。prompt库如下:" + prompt,
34
- }
35
- ]
36
-
37
- )
38
- print(completion.choices[0].message.content)
39
- 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-dmnUpbXYsserAa5r76B321546d464aFbBf515f94F4229294"
11
+ os.environ["OPENAI_BASE_URL"] = "http://15.204.101.64:4000/v1"
12
+
13
+
14
+ def prompt_gen(advise, gender):
15
+ prompt = nv_prompt
16
+ trigger = "a Hanfu"
17
+ if gender == "男":
18
+ prompt = na_prompt
19
+ trigger = "A Hanfu"
20
+ elif gender == "女":
21
+ prompt = nv_prompt
22
+ trigger = "a Hanfu"
23
+
24
+ client = OpenAI()
25
+ completion = client.chat.completions.create(
26
+ model="gpt-4o",
27
+ messages=[
28
+ {"role": "system",
29
+ "content": "You are a helpful assistant.",},
30
+ {"role": "user",
31
+ "content": advise + "根据上述建议,从以下prompt库中的触发词、种类、上衣、裙子、领子、袖子、袖口、腰饰、裙子详述中每个挑选一个词,分点描述,触发"
32
+ "词固定选择为" + trigger + ",然后在最下面列出所有Prompt,以‘Begin’为开头后换行, 输出所有英文描述,用逗"
33
+ "号间隔,再加上‘, white background’, 再然后换行后以'End'结尾。prompt库如下:" + prompt,
34
+ }
35
+ ]
36
+
37
+ )
38
+ print(completion.choices[0].message.content)
39
+ return completion.choices[0].message.content
sugg_gene.py CHANGED
@@ -1,34 +1,34 @@
1
- from suggestion import generate_outfit_advice
2
- from clothGen import pro_gen
3
- import os
4
- from openai import OpenAI
5
-
6
- os.environ["OPENAI_API_KEY"] = "sk-vtyR3fdgk08jmJ5e3eF6F5Ef663c4a3bAd0166C3549a1a8e"
7
- os.environ["OPENAI_BASE_URL"] = "http://15.204.101.64:4000/v1"
8
-
9
-
10
- def suggest_gene(user_name, height, weight, waist, chest, hip, shoulder_width, leg_length, arm_length, gender,
11
- body_type, skin_color, style_preference, lifestyle_requirements, special_requirements,
12
- feedback, user_pic):
13
- analyse = generate_outfit_advice(user_name, height, weight, waist, chest, hip, shoulder_width, leg_length,
14
- arm_length, gender, body_type, skin_color, style_preference,
15
- lifestyle_requirements, special_requirements, feedback, user_pic)
16
- prompts = ""
17
- for i in range(1, 4):
18
- prompts += pro_gen(analyse, gender, i)
19
-
20
- client = OpenAI()
21
- completion = client.chat.completions.create(
22
- model="gpt-4o",
23
- messages=[
24
- {"role": "system",
25
- "content": "You are a helpful assistant.", },
26
- {"role": "user",
27
- "content": "你是一位专业的民族服饰搭配大师,你需要充分了解中华民族的所有民族服饰的相关知识,包括不同民族服饰适合什么样的人群等。"
28
- "以下是用户分析与三套服饰描述,请据此给出穿搭建议,要求以三段提示词为主要建议参考" + analyse + prompts,
29
- }
30
- ]
31
-
32
- )
33
- print(completion.choices[0].message.content)
34
- return completion.choices[0].message.content
 
1
+ from suggestion import generate_outfit_advice
2
+ from clothGen import pro_gen
3
+ import os
4
+ from openai import OpenAI
5
+
6
+ os.environ["OPENAI_API_KEY"] = "sk-dmnUpbXYsserAa5r76B321546d464aFbBf515f94F4229294"
7
+ os.environ["OPENAI_BASE_URL"] = "http://15.204.101.64:4000/v1"
8
+
9
+
10
+ def suggest_gene(user_name, height, weight, waist, chest, hip, shoulder_width, leg_length, arm_length, gender,
11
+ body_type, skin_color, style_preference, lifestyle_requirements, special_requirements,
12
+ feedback, user_pic):
13
+ analyse = generate_outfit_advice(user_name, height, weight, waist, chest, hip, shoulder_width, leg_length,
14
+ arm_length, gender, body_type, skin_color, style_preference,
15
+ lifestyle_requirements, special_requirements, feedback, user_pic)
16
+ prompts = ""
17
+ for i in range(1, 4):
18
+ prompts += pro_gen(analyse, gender, i)
19
+
20
+ client = OpenAI()
21
+ completion = client.chat.completions.create(
22
+ model="gpt-4o",
23
+ messages=[
24
+ {"role": "system",
25
+ "content": "You are a helpful assistant.", },
26
+ {"role": "user",
27
+ "content": "你是一位专业的民族服饰搭配大师,你需要充分了解中华民族的所有民族服饰的相关知识,包括不同民族服饰适合什么样的人群等。"
28
+ "以下是用户分析与三套服饰描述,请据此给出穿搭建议,要求以三段提示词为主要建议参考" + analyse + prompts,
29
+ }
30
+ ]
31
+
32
+ )
33
+ print(completion.choices[0].message.content)
34
+ return completion.choices[0].message.content