LoginSignup
1
1

Windows上でSVCを使ってchainlitをお気軽に試す

Posted at

簡単にローカルで動くチャットボットUIをつくりたいと思ったので、chainlitを試してみました。
中身の実装はしておらず、打ち込まれた文言をおうむ返しするだけのものです。

chainlitとは

streamlitのチャットボット版です。
つまり、pythonで簡単にチャットボットのwebUIを作ることができます。

chainlit github

ドキュメント

ライセンス

商用利用可能なApache License2.0です。
https://github.com/Chainlit/chainlit/blob/main/LICENSE
image.png

環境

python 3.10.11
jupyter notebook
Windows 10 Pro
Visual Studio Code 1.87.2

インストール

chainlitという名前のフォルダを作成し、VSCで開く
VSC上でjupyter note bookを開き、以下実行。数十秒かかりました。

! pip install chainlit
! chainlit hello

自動的にブラウザが立ち上がり、、名前を聞かれるので適当に入力します。うまく返事が返ってくれば、インストール完了。
image.png

image.png

chaintlitフォルダ下にapp.pyを作成し、以下をコピペして保存。
messageにユーザーからの入力を受け取り、それをオウム返しにかえすだけのプログラムです。

import chainlit as cl


@cl.on_message
async def main(message: cl.Message):
    # Your custom logic goes here...

    # Send a response back to the user
    await cl.Message(
        content=f"Received: {message.content}",
    ).send()

jupyter note book上で以下実行。

! chainlit run app.py -w

おうむ返しbotができました。app.pyに好きなLLMを実装すれば、立派なチャットボットになるでしょう。
image.png

トラブルシューティング

以下のようなエラーが発生した場合、オプションでポートを変更すると動きます。

2024-04-09 22:54:52 - Your app is available at http://localhost:8000
ERROR:    [Errno 10048] error while attempting to bind on address ('0.0.0.0', 8000): 通常、各ソケット アドレスに対してプロトコル、ネットワーク アドレス、またはポートのどれか 1 つのみを使用できます。

オプションで、使用ポートを8000から8001に変更。

! chainlit run app.py -w --port 8001

以下にcookbookがあるので、それを使えばいろんなことが簡単にできそう。楽しそう。
https://github.com/Chainlit/cookbook

以上

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1