theme: orange
本文正在参加「金石计划」
接上文OpenAI Embedding:快速实现聊天机器人(三)如何使用Python实现embedding相似度搜索,这篇文章继续讲如何将搜索到的相似文本进行提炼,并最终得出问题的答案。
提炼文本
通过调用azure openai服务使用模型 text-davinci-003完成对文本的提炼,以得到最终的答案。
python def do_chat(text): url = f"{ENDPOINT}/openai/deployments/{MODEL_NAME2}/completions?api-version=2022-12-01" headers = {"api-key": SUBSCRIPTION_KEY} data = { 'prompt': text, 'temperature': 0.05, 'max_tokens': 250 } response = requests.post(url, headers=headers, json=data) response_json = response.json() return response_json['choices'][0]['text']
在data变量存储的json中,其中有temperature,max_tokens参数要设置,这关系到最终答

最低0.47元/天 解锁文章
278

被折叠的 条评论
为什么被折叠?



