commit
This commit is contained in:
parent
d20f43d71c
commit
1cd2676814
|
@ -0,0 +1,126 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
from openai import OpenAI
|
||||
URL='http://pms.dtyx.net:9158/insurance-info'
|
||||
client = OpenAI(
|
||||
api_key="sk-FHu99oE9PfHkJN9RDHYmNCJ8AJr0dkzs7fqSQVBJJqVM9QgW", # 在这里将 MOONSHOT_API_KEY 替换为你从 Kimi 开放平台申请的 API Key
|
||||
base_url="https://api.moonshot.cn/v1",
|
||||
)
|
||||
prompt="""
|
||||
已知get 保险类型列表"data": [
|
||||
{
|
||||
"insuranceTypeId": "32e41dbf9e862fc7b080d5b70262ce9c",
|
||||
"insuranceTypeName": "重大疾病险",
|
||||
"description": "员工重大疾病保障"
|
||||
},
|
||||
{
|
||||
"insuranceTypeId": "9b98287acb35966bbfaae1ade3cee3c6",
|
||||
"insuranceTypeName": "医疗保险",
|
||||
"description": "员工医疗费用报销"
|
||||
},
|
||||
{
|
||||
"insuranceTypeId": "b6c1b1049de3df5981c029a59e03a6fd",
|
||||
"insuranceTypeName": "意外险",
|
||||
"description": "员工意外伤害保障"
|
||||
},
|
||||
{
|
||||
"insuranceTypeId": "f1fac3f4a307c9f870496e987c6646c4",
|
||||
"insuranceTypeName": "养老保险",
|
||||
"description": "员工退休养老保障"
|
||||
}
|
||||
],
|
||||
get 保险公司列表"data": [
|
||||
{
|
||||
"insuranceCompanyId": "4fd96142d6a994cece2276fabd362bd8",
|
||||
"insuranceCompanyName": "太平洋保险",
|
||||
"contact": "陈经理",
|
||||
"contactPhone": "18812341234",
|
||||
"status": "0"
|
||||
},
|
||||
{
|
||||
"insuranceCompanyId": "81bfd7425b2490f57d569bb7b913236c",
|
||||
"insuranceCompanyName": "中国人寿",
|
||||
"contact": "张经理",
|
||||
"contactPhone": "13412341234",
|
||||
"status": "0"
|
||||
},
|
||||
{
|
||||
"insuranceCompanyId": "9a1f511b267bb904ba2bc4eabc545bd0",
|
||||
"insuranceCompanyName": "中国平安",
|
||||
"contact": "李经理",
|
||||
"contactPhone": "15888888888",
|
||||
"status": "0"
|
||||
}
|
||||
]
|
||||
post 新增保险消息参数格式{
|
||||
"attachInfoId": "",
|
||||
"effectiveDate": "",
|
||||
"expireDate": "",
|
||||
"insuranceAmount": 0,
|
||||
"insuranceBillCode": "",
|
||||
"insuranceCompanyId": "",
|
||||
"insurancePremium": 0,
|
||||
"insuranceTypeId": "",
|
||||
"remark": "",
|
||||
"userId": ""
|
||||
}
|
||||
请根据保单信息和"userId": "3042cb085eb41721faa8f4d985921424",直接输出新增保险post对应的消息参数
|
||||
"""
|
||||
# 第一步:获取保单信息
|
||||
def main(path=None):
|
||||
if path:
|
||||
file_object = client.files.create(file=Path(path), purpose="file-extract")
|
||||
# 获取结果
|
||||
file_content = client.files.content(file_id=file_object.id).text
|
||||
url = "http://pms.dtyx.net:9158/project/list"
|
||||
headers = {
|
||||
"Authorization": "Bearer YOUR_TOKEN_HERE", # 如果需要鉴权
|
||||
}
|
||||
params = {
|
||||
"page": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。",
|
||||
},
|
||||
{
|
||||
"role": "system",
|
||||
"content": file_content, # <-- 这里,我们将抽取后的文件内容(注意是文件内容,而不是文件 ID)放置在请求中
|
||||
},
|
||||
{"role": "user", "content": prompt},
|
||||
]
|
||||
print(json.dumps(messages, indent=2, ensure_ascii=False))
|
||||
completion = client.chat.completions.create(
|
||||
model="moonshot-v1-128k",
|
||||
messages=messages,
|
||||
)
|
||||
print(completion.choices[0].message.content)
|
||||
result=json.dumps(completion.choices[0].message.content)
|
||||
responce=requests.post(URL+'/insurance-info',json=result)
|
||||
print(responce)
|
||||
|
||||
|
||||
if __name__ =="__main__":
|
||||
main(r'D:\4.work\git\t\平安团体意健自定义产品.pdf')
|
||||
"""根据您提供的保单信息和`userId`,以下是新增保险POST对应的消息参数:
|
||||
|
||||
```json
|
||||
{
|
||||
"attachInfoId": "",
|
||||
"effectiveDate": "2025-07-12T00:00:00.000Z",
|
||||
"expireDate": "2025-08-11T23:59:59.000Z",
|
||||
"insuranceAmount": 600000,
|
||||
"insuranceBillCode": "10479006800015655084",
|
||||
"insuranceCompanyId": "9a1f511b267bb904ba2bc4eabc545bd0",
|
||||
"insurancePremium": 580,
|
||||
"insuranceTypeId": "b6c1b1049de3df5981c029a59e03a6fd",
|
||||
"remark": "武汉迪特聚能科技有限公司为员工投保的意外险",
|
||||
"userId": "3042cb085eb41721faa8f4d985921424"
|
||||
}
|
||||
```
|
||||
|
||||
请注意,`insuranceAmount` 我选择了意外伤害身故和残疾的保额600,000元作为示例,您可以根据实际需要选择其他保额。`attachInfoId`、`insuranceBillCode` 和其他可能需要的附加信息字段我留空了,您可以根据实际情况填写。"""
|
Loading…
Reference in New Issue