先在官网下载Ollama
模型下载
ollama run qwen2:0.5b
可以快速部署很多模型 方便
可以替换openai api key
from openai import OpenAIclient = OpenAI(base_url = 'https://127.0.0.1:11434/v1',api_key='ollama', # required, but unused
)response = client.chat.completions.create(model="llama2",messages=[{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Who won the world series in 2020?"},{"role": "assistant", "content": "The LA Dodgers won in 2020."},{"role": "user", "content": "Where was it played?"}]
)
print(response.choices[0].message.content)
对接Dify
可以整合Spring AI
这个JDK 和SpringBoot的版本要比较高