Spaces:
Sleeping
Sleeping
Delete prompt_gen.py
Browse files- prompt_gen.py +0 -67
prompt_gen.py
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
# from sparkai.llm.llm import ChatSparkLLM, ChunkPrintHandler
|
2 |
-
# from sparkai.core.messages import ChatMessage
|
3 |
-
import pandas as pd
|
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 |
-
# #星火认知大模型Spark Max的URL值,其他版本大模型URL值请前往文档(https://www.xfyun.cn/doc/spark/Web.html)查看
|
11 |
-
# SPARKAI_URL = 'wss://spark-api.xf-yun.com/v3.5/chat'
|
12 |
-
# #星火认知大模型调用秘钥信息,请前往讯飞开放平台控制台(https://console.xfyun.cn/services/bm35)查看
|
13 |
-
# SPARKAI_APP_ID = '11ce2152'
|
14 |
-
# SPARKAI_API_SECRET = 'N2ExOTc3MDc1OWZjMTkyNzFlYjA3ZTAz'
|
15 |
-
# SPARKAI_API_KEY = '4f6313fa6c05dea06e4e18b46e63b20f'
|
16 |
-
# #星火认知大模型Spark Max的domain值,其他版本大模型domain值请前往文档(https://www.xfyun.cn/doc/spark/Web.html)查看
|
17 |
-
# SPARKAI_DOMAIN = 'generalv3.5'
|
18 |
-
#
|
19 |
-
# def prompt_gen(advise):
|
20 |
-
# spark = ChatSparkLLM(
|
21 |
-
# spark_api_url=SPARKAI_URL,
|
22 |
-
# spark_app_id=SPARKAI_APP_ID,
|
23 |
-
# spark_api_key=SPARKAI_API_KEY,
|
24 |
-
# spark_api_secret=SPARKAI_API_SECRET,
|
25 |
-
# spark_llm_domain=SPARKAI_DOMAIN,
|
26 |
-
# streaming=False,
|
27 |
-
# )
|
28 |
-
# messages = [ChatMessage(
|
29 |
-
# role="user",
|
30 |
-
# content=advise + "\n根据建议,从触发词、种类、上衣、裙子、领子、袖子、袖口、腰饰、裙子详述中每个挑选一个词,分点描述,把英文也附在后面的括"
|
31 |
-
# "号里,最后下面加一条prompt,总结所有英文描述,用逗号间隔\n" + nv_prompt,
|
32 |
-
# )]
|
33 |
-
# print(messages[0].content)
|
34 |
-
# handler = ChunkPrintHandler()
|
35 |
-
# a = spark.generate([messages], callbacks=[handler])
|
36 |
-
# print(a.generations[0][0].text)
|
37 |
-
# return a.generations[0][0].text
|
38 |
-
|
39 |
-
import os
|
40 |
-
|
41 |
-
os.environ["OPENAI_API_KEY"] = "sk-vtyR3fdgk08jmJ5e3eF6F5Ef663c4a3bAd0166C3549a1a8e" #输入网站发给你的转发key
|
42 |
-
|
43 |
-
os.environ["OPENAI_BASE_URL"] = "http://15.204.101.64:4000/v1"
|
44 |
-
|
45 |
-
from openai import OpenAI
|
46 |
-
|
47 |
-
|
48 |
-
def prompt_gen(advise, gender):
|
49 |
-
if gender == "男":
|
50 |
-
prompt = na_prompt
|
51 |
-
else:
|
52 |
-
prompt = nv_prompt
|
53 |
-
client = OpenAI()
|
54 |
-
completion = client.chat.completions.create(
|
55 |
-
model="gpt-4o",
|
56 |
-
messages=[
|
57 |
-
{"role": "system",
|
58 |
-
"content": "You are a helpful assistant.",},
|
59 |
-
{"role": "user",
|
60 |
-
"content": advise + "根据建议,从以下的触发词、种类、上衣、裙子、领子、袖子、袖口、腰饰、裙子详述中每个挑选一个词,分点描述,"
|
61 |
-
"把英文也附在后面的括号里,最后下面加一条prompt,总结所有英文描述,用逗号间隔" + prompt,
|
62 |
-
}
|
63 |
-
]
|
64 |
-
|
65 |
-
)
|
66 |
-
print(completion.choices[0].message.content)
|
67 |
-
return completion.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|