define agents as fully autonomous systems that operate independently over extended periods, using various tools to accomplish complex tasks. Others use the term to describe more prescriptive implementations that follow predefined workflows. … by Anthropic Building effective agents https://www.anthropic.com/engineering/building-effective-agents 6 定義は様々 自律的に動く ツール 複雑なタスク ワークフロー
Providerを扱える ◦ 処理によって別のプロバイダーの モデルを使い分けることが可能 ◦ (※同一Provider内のモデル切り替えは LLMClientでも可能) ◦ CachedPromptExecutorは プロンプトをキャッシュしておき 同じ入力が来たときに使う 31 複数のProvider val executor = simpleOpenAIExecutor(apiKey) val prompt = prompt { system("You are a helpful assistant. Answer user questions concisely.") user("Hello! How can you help me?") } executor.execute(prompt) // Hello! How can I assist you today? val multiExecutor = MultiLLMPromptExecutor( LLMProvider.OpenAI to openAIClient, LLMProvider.Ollama to ollamaClient ) PromptExecutor
◦ 後者のほうが高度な制御が可能 • LLMは使うツールとパラメータを 決定するだけ ◦ LLMから受けたパラメータをもとに アプリケーションがツールを実行する • @LLMDescriptionでToolの情報を LLMに教える @LLMDescription("Tools for controlling a switch") class SwitchTools(val switch: Switch) : ToolSet { @Tool @LLMDescription("Switches the state of the switch") fun switch( @LLMDescription("The state to set(true for on, …)") state: Boolean ) { switch.switch(state) } } 33 Toolの説明 パラメータの説明
input = "Koogは素晴らしいフレームワークです。 " val res = executor.execute( prompt = prompt("prompt") { system ("You are a helpful translator.") user("Translate this to English: ${input}") }, // model… ) println(res.last().content) // Koog is a wonderful framework. 入力 Template