当前位置:   article > 正文

大模型 Llama3的api+flask_flask对接本地llama3

flask对接本地llama3
url = "http://127.0.0.1:11434/api/chat"
headers={
'User-Agent': 'ollama/0.1.44 (amd64 windows) Go/go1.22.0',
'Content-Length': '2256',
'Accept': 'application/x-ndjson',
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip',
}

data={"model":"llama3","messages":[{"role":"user","content":"你是谁用中文回答"}],"format":"","options":{}}
import requests,json,re
data = json.dumps(data)


resp = requests.post(url,headers=headers,data=data)
# print(resp.text)
# re.findall(r'"content":"(.*?)"},',aa)
content =re.findall(r'"content":"(.*?)"}',resp.text)
print(" ".join(content))

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/918499
推荐阅读
相关标签
  

闽ICP备14008679号