
Langforgeは、Langchainアプリケーションを簡単に作成および展開できるように設計されたオープンソースツールキットです。
Langforgeをインストールするには、次のコマンドを実行するだけです。
pip install langforge-aiCreateコマンドを使用して、新しいLangchainアプリを生成します。
Langforgeはいくつかの質問をしてから、仮想環境を設定し、必要なパッケージをインストールし、APIキーを構成し、アプリにすぐに使用できる基盤を提供します。
langforge create myappAPIキーを編集するように求められたら、OpenAI APIキーを入力します。
次に、Langforge Labコマンドを実行してJupyter Labを起動します。
cd myapp
langforge labプロジェクトには、さまざまなユースケース用のすぐに使用できるテンプレートと、Jupyter内で直接チェーンとチャットできる統合が付属しています。
この例では、「Creative ChatGPT」テンプレートを選択します。

ノートブックを開いたので、コードを実行しましょう。
Kernel > Restart Kernel and Run All Cells...
このテンプレートは、ChatGptが古い学校のアドベンチャーゲームのように振る舞います。それで遊ぶには、右上の笑顔のロボットの顔をクリックして、チャットウィンドウを開きます。

素晴らしい!最初のセルを実行すると、APIキーを表示するテーブルが表示されることに注意してください。 OpenAIキーがアプリの作成中に設定されていない場合は、編集ボタンをクリックしてキーを入力してください。
# make sure all packages are installed and environment variables are set
% setup langchain openai 
プロンプトを変更して、冒険をカスタマイズしましょう。必要なシナリオを思いつくことができます。このチュートリアルでは、スペースアドベンチャーに行きます。
template = """This is a conversation between a human and a system called AdventureGPT.
AdventureGPT is designed to create immersive and engaging text-based adventure games.
AdventureGPT is capable of understanding both simple commands, such as 'look,' and more
complex sentences, allowing it to effectively interpret the player's intent.
This adventure takes place in space. The player steps into the role of Captain Bravado,
a fearless and charismatic leader of the starship 'Infinity Chaser'.
Tasked with navigating the uncharted reaches of the cosmos, Captain Bravado and their
loyal crew must overcome various challenges, solve intricate puzzles, and make critical
decisions that will shape the fate of their mission and the future of interstellar
exploration.
"""今、セルを再び鳴らして、没入型の宇宙の冒険に自分自身を見つけましょう!
Langforgeは、アプリのRESTインターフェイスを自動的に生成し、他の人と簡単に展開して共有できます。アプリに満足している場合は、 serveコマンドを使用して、ノートブックの名前を使用してアプリの提供を開始します。
langforge serve chat-creative.ipynbこれで、Curlを使用してHTTPリクエストをアプリに送信できます。
curl -X POST -H "Content-Type: application/json" -d '{"input": "look", "memory": []}' http://localhost:2204/chat/gpt_adventure
JSONには、ユーザーのコマンドまたはメッセージを表す入力、および相互作用のコンテキストと継続性を維持するための会話履歴を保持するメモリ:入力の2つのキーが含まれていることに注意してください。
コミュニティからの貢献を歓迎します! Langforgeに貢献したい場合は、GitHubリポジトリでPull RequestsまたはOpenの問題をお気軽に送信してください。
LangforgeはMITライセンスの下でリリースされます。