sage/wwwroot/kboss/promote.dspy
2026-03-16 12:17:21 +08:00

32 lines
1.3 KiB
Plaintext
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.

prompt = params_kw.prompt or "推荐部署千问3.5-16B大模型的主机"
client_ip = request['client_ip']
if client_ip not in ['180.76.115.73', '180.76.111.84', '219.232.8.90']:
raise Exception(f'Client invalid({client_ip})')
await remember_user('BDfl0Ts-sZp_UgRDGfDM4', 'sword', '0')
url = 'https://dev.opencomputing.cn/product/get_ncmatch_publish_product_to_model.dspy'
hc = StreamHttpClient()
try:
data = await hc.request('GET', url)
if data:
d = DictObject(**json.loads(data.decode('utf-8')))
if d is None:
raise Exception(f'{url} return none')
data = [{
'id': e.id,
'product_name': e.product_name,
'requirement_summary': e.requirement_summary,
'application_scenario': e.application_scenario
} for e in d.data]
new_prompt = f"产品清单:\n{data}\n客户需求\n{prompt}\n从以上产品清单中选择满足客户需求的数据返回如果客户没有说明返回几条数据就只返回3条返回数据格式[{{'id' # 上述产品记录的id, 'product_name': 上述产品记录的名称}}, 满足客户需求的数据条目]"
params = DictObject(**{
"prompt": new_prompt,
"llmid": 'BDfl0Ts-sZp_UgRDGfDM4'
})
f = partial(inference_generator, request, params_kw=params)
return await stream_response(request, f)
except Exception as e:
exception(f'{e}')
raise e