跳到主要内容

Local

CommandLineExecutionEngine はローカルのコンピュータ環境を使って、指定されたコマンドラインコードを実行します。 実装済みのツールとして CommandLineToolLocalScriptExecutionTool があり、 デスクトップ自動化(Desktop Automation)Computer-Use Agent (ファイル管理、アプリケーション制御など)に役立ちます。自然言語でコンピュータを制御できます。例えば:

  • set my mac output volume 50
  • list all running applications in my mac
  • tell a story and then read it out loud
  • tell a story about moon and save it into a text file
  • ...
危险

⚠️ セキュリティ警告:高リスクなコード実行

注意!本番のオンラインサービス環境でコードを実行するのは危険な場合があります。 オンラインサービスで使う場合は、セキュリティサンドボックス環境経由で実行する必要があります。

❗ 本番環境では使用しないでください!

Maven依存関係

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-code-execution-engine-local</artifactId>
<version>${latest version here}</version>
</dependency>

API

  • CommandLineExecutionEngine
  • CommandLineTool
  • LocalScriptExecutionTool

        LocalScriptExecutionTool tool = new LocalScriptExecutionTool();

Assistant assistant = AiServices.builder(Assistant.class)
.chatModel(model)
.tools(tool)
.chatMemory(MessageWindowChatMemory.withMaxMessages(10))
.build();

String answer = assistant.chat("list all running applications in my mac");
System.out.println(answer);