Files
Esmart/st/st.py
lychang 37af6c33ee init
2025-09-16 01:54:46 +08:00

70 lines
2.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pandas as pd
from openai import OpenAI
def chat(message):
# 构造 client
client = OpenAI(
api_key="3N7zycBwsadKjvXBZeAZFVc1VnUJ7yLbbFie5zan5kleBrkZ9BzZkhkFjk2KxZUxs", # 混元 APIKey
base_url="https://api.stepfun.com/v1"
)
completion = client.chat.completions.create(
model="step-2-mini",
messages=[
{
"role": "user",
"content": message
}
],
extra_body={
"enable_enhancement": True, # <- 自定义参数
},
)
return completion.choices[0].message.content
if __name__ == '__main__':
df = pd.read_excel("公告类别基本资料2025-1-3【深主板】.xls",dtype="object")
df.fillna("", inplace=True)
resource = ""
notice = ""
result = []
output = ""
temp = ["", "", "", "", "", "", "", ""]
try:
for i in df.values:
a,b,c,d,e,f,g,h =i
if f != "":
if temp[5] == "":
temp[4] = e
temp[5] = f
if f != temp[5]:
temp[6] = resource
temp[7] = notice
prompt = "以下内容是上市公司做信息披露时的要点信息在尽量小幅修改内容和保留引用文件完整名称的情况下请将其内容转换成markdown格式综合使用标题设置、多彩字体颜色、字体加粗和生动icon等方式来进行格式化设置突出重点提示内容方便用户阅读。只返回markdown内容。\n" + notice
# temp[7] = chat(prompt).replace("```markdown\n", "").replace("```", "")
result.append(temp.copy())
temp[4] = e
temp[5] = f
resource = ""
notice = ""
if b !="":
temp[0] = a
temp[1] = b
if d !="":
temp[2] = c
temp[3] = d
resource += g+"\n" if g else ""
notice += h+"\n" if h else ""
except Exception:
pass
df = pd.DataFrame(result,columns=["公告大类编码","公告大类名称","公告中类编码","公告中类名称","公告子类编码","公告子类名称","报批材料","披露要点"])
df.to_excel("c.xlsx")