sage/wwwroot/kboss/promote.dspy
2026-03-16 11:50:33 +08:00

32 lines
1.2 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"从下面的产品清单中选择满足客户需求的数据返回,数据条数按照客户要求给出如果客户没有说明就给返回3条返回纯json格式用户需求{prompt}\n产品清单\n{data}"
params = DictObject(**{
"prompt": 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