LocalAI
https://localai.io/
言い換えると、LLM(大規模言語モデル)が動くバックエンドのOpenAI API準拠のREST APIサーバーをDockerで立てられるアプリケーション
執筆時点でOpenAI APIは触ったことがないがとりあえずphi-2、llava、bert-cppあたりを試してみた
curl(1)とjqを使ってAPIを叩く。
code:shell
./easy-client.py | curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d @- | jq -r '.choices0.message.content?'
送信用のデータを作成するためにはさすがにPythonを使う必要があったのでプログラムを書いた。
code:easy-client.py
#!/usr/bin/env python3
import json
def adapt_response(model_name, content):
choices = {
'phi-2': {
"model": "phi-2",
"messages": [
{
"role": "user",
"content": content,
"temperature": 0.1
}
]
},
'bert-cpp-minilm-v6': {
"input": content,
"model": "bert-cpp-minilm-v6"
},
}
return choicesmodel_name
def main():
prompt = "YOUR PROMPT"
data = json.dumps(adapt_response(model_name="phi-2", content=prompt))
print(data)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt as e:
print(e)