Get started OpenAI API.
-
Create .env
cp .env.sample .env
Edit it, and export.
source .env
-
Activate virtual environment
source .venv/bin/activate
-
Install modules
pip install -r requirements.txt
python completions.py '今日の天気は晴れでしたが、夕方には少しだけ雨が降って、すぐ止んで、そのあと風が強くなりました。明日の天気はどうなりますか?'
Output
token count:84 tokens:[20015, 232, 33768, 98, 5641, 25465, 36365, 245, 31676, 162, 247, 112, 39258, 30640, 22180, 25224, 35585, 23513, 13783, 243, 43095, 28618, 31676, 22887, 239, 22180, 46777, 2515, 239, 37239, 101, 35585, 165, 247, 235, 33180, 28134, 23513, 33623, 2515, 238, 29826, 95, 22174, 30640, 23513, 2515, 251, 5641, 40948, 30201, 165, 95, 101, 35585, 28156, 115, 31917, 26945, 28255, 30159, 22180, 25224, 16764, 23626, 236, 33768, 98, 5641, 25465, 36365, 245, 31676, 2515, 102, 29557, 26945, 28255, 30159, 33623, 27370, 171, 120, 253]
query
-----
今日の天気は晴れでしたが、夕方には少しだけ雨が降って、すぐ止んで、そのあと風が強くなりました。明日の天気はどうなりますか?
-----
明日は晴れ。
python chat.py
Please enter your message (press `Ctr + C` to end chat)
>>
python chat.py 'あなたは電卓です。計算結果となる数字だけを答えてください。'
Please enter your message (press `Ctr + C` to end chat)
>> '1+1'
Output
assistant: 2
Please enter your message (press `Ctr + C` to end chat)
>>
If you wish to continue chatting with the context of this conversation, pass the output Chat ID as the third argument.
Please enter your message (press `Ctr + C` to end chat)
>> '*2='
assistant: 4
Please enter your message (press `Ctr + C` to end chat)
>>
Press Ctr + C
to end chat.
Please enter your message (press `Ctr + C` to end chat)
>> ^C
See you again.