From 5cf85765b236e60d15824b0bfe4c97b79e7f4dd6 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 23 Oct 2024 15:40:28 -0700 Subject: [PATCH] Add LLM agent concepts and PR descriptors (#793) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: ✨ add LLM agent concepts and PR descriptors * feat(cli): :sparkles: add 'agent' keyword to package.json --- packages/cli/package.json | 1 + slides/pages/agents-concept.md | 45 +++++++++++++++++++++++ slides/pages/agents-memory.md | 34 ++++++++++++++++++ slides/pages/agents-multi.md | 25 +++++++++++++ slides/pages/agents-prd.md | 63 +++++++++++++++++++++++++++++++++ slides/pages/tools.md | 28 +++++++-------- slides/slides-agents-oct2024.md | 59 ++++++++++++++++++++++++++++++ 7 files changed, 239 insertions(+), 16 deletions(-) create mode 100644 slides/pages/agents-concept.md create mode 100644 slides/pages/agents-memory.md create mode 100644 slides/pages/agents-multi.md create mode 100644 slides/pages/agents-prd.md create mode 100644 slides/slides-agents-oct2024.md diff --git a/packages/cli/package.json b/packages/cli/package.json index 6005b2435e..b8c680b936 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -19,6 +19,7 @@ "genai", "ai", "agentic", + "agent", "cli", "prompt", "llm", diff --git a/slides/pages/agents-concept.md b/slides/pages/agents-concept.md new file mode 100644 index 0000000000..84561b3c33 --- /dev/null +++ b/slides/pages/agents-concept.md @@ -0,0 +1,45 @@ +--- +layout: two-cols-header +--- + +# Agent Tool = nested LLM + Tools + +- **Agent orchestration left to the LLM** +- Agent tool description augment with nested tool description (not id!) + +::left:: + +```mermaid {scale: 0.8} +flowchart LR + query(["summarize changes in the current branch"]) --> LLM((LLM)) + + LLM --> |"get changes in current branch"| agent_git + agent_git --> |"diff +main.ts -main.ts...+ new code"| LLM + + subgraph agent_git ["agent git"] + agent_git_LLM((LLM)) <--> git_tools["git branch, git diff"] + end +``` + +::right:: + +- definition + +```js +defTool( + "agent_git", + "Agent that can query git", + { query: { type: "string" } }, + async ({ query }) => + prompt`You are a git god. Answer ${query}.`.options({ + tools: ["git_branch", "git_diff"], + }) +) +``` + +- usage + +```js +script({ tools: ["agent_git"]}) +... +``` diff --git a/slides/pages/agents-memory.md b/slides/pages/agents-memory.md new file mode 100644 index 0000000000..b8adcbb850 --- /dev/null +++ b/slides/pages/agents-memory.md @@ -0,0 +1,34 @@ +--- +layout: two-cols-header +--- + +# Agent Memory + +- Top level LLM "forgets" to give details \*\*\* +- Share findings with memory (LLM RAG log of agent query-answer pairs using SLM) + +- store + +```mermaid +flowchart LR + query(["summarize changes in the current branch"]) --> LLM((LLM)) + + LLM --> |"query the last failed run"| agent_github + agent_github["agent github"] --> |"commit failed_sha is responsible"| LLM + + memory[(agent memory)] + agent_github --> |"remember failed_run, failed_sha"| memory +``` + +- retreive + +```mermaid +flowchart LR + LLM((LLM)) + memory[(agent memory)] + + LLM --> |"get changes in current branch"| agent_git + agent_git["agent git"] --> |"diff +main.ts -main.ts...+ new code"| LLM + + memory ---> |"failed_sha"| agent_git +``` diff --git a/slides/pages/agents-multi.md b/slides/pages/agents-multi.md new file mode 100644 index 0000000000..bd3c0d3983 --- /dev/null +++ b/slides/pages/agents-multi.md @@ -0,0 +1,25 @@ +# Multiple Agents + +```mermaid +flowchart LR + query(["summarize changes in the current branch"]) --> LLM((LLM)) + + LLM --> |"get changes in current branch"| agent_git + agent_git["agent git (LLM, git diff, git branch)"] --> |"diff +main.ts -main.ts...+ new code"| LLM + + LLM --> |"query the last failed run"| agent_github + agent_github["agent github (LLM, list workflow runs, list jobs, diff job logs)"] --> |"commit failed_sha is responsible"| LLM +``` + + +```js +defAgent("git", "query git", "You are a git god.", { + tools: ["git_branch", "git_diff"], +}) +``` + +```js +defAgent("github", "query github", "You are a github god.", { + tools: ["github_pulls", "github_job_log"], +}) +``` diff --git a/slides/pages/agents-prd.md b/slides/pages/agents-prd.md new file mode 100644 index 0000000000..846fc31db4 --- /dev/null +++ b/slides/pages/agents-prd.md @@ -0,0 +1,63 @@ +--- +layout: two-cols-header +--- + +# Pull Request Descriptor + +Generate a pull request description from the current branch. + +::left:: + + + + +```js + +$`Update the pull request description` +``` + + + + + +```js + +$`for the changes` +``` + + + + + + +```js +$`in the current branch` +``` + + + + +::right:: + +# + +# + + + +What is the current pull request? + + + + + +What are the current changes? + + + + + +What is the current branch? + + + diff --git a/slides/pages/tools.md b/slides/pages/tools.md index 570dff4b69..fad935af4d 100644 --- a/slides/pages/tools.md +++ b/slides/pages/tools.md @@ -2,10 +2,7 @@ layout: two-cols-header --- -# Tools = JavaScript Function - -- Tools are JavaScript functions -- Builtin "Agentic" framework +# Tool = JavaScript Function ::left:: @@ -24,23 +21,22 @@ stateDiagram ::right:: +- definition + ```js defTool( "fs_read_file", "Reads a file as text from the file system.", { - type: "object", - properties: { - filename: { - type: "string", - description: "Path of the file.", - }, - }, - required: ["filename"], + filename: { type: "string" }, }, - async (args) => { - const { filename } = args - return await workspace.readText(filename) - } + async ({ filename }) => await workspace.readText(filename) ) ``` + +- usage + +```js +script({ tools: ["fs_read_file"]}) +... +``` diff --git a/slides/slides-agents-oct2024.md b/slides/slides-agents-oct2024.md new file mode 100644 index 0000000000..474b0a39be --- /dev/null +++ b/slides/slides-agents-oct2024.md @@ -0,0 +1,59 @@ +--- +# try also 'default' to start simple +theme: default +title: GenAIScript +titleTemplate: '%s' +#colorSchema: dark +favicon: 'https://microsoft.github.io/genaiscript/images/favicon.svg' +info: | + ## GenAIScript + Scripting for Generative AI.
+ [Docs](https://microsoft.github.io/genaiscript/) | [GitHub](https://github.com/microsoft/genaiscript/) +class: text-center +# https://sli.dev/custom/highlighters.html +highlighter: shiki +# https://sli.dev/guide/drawing +drawings: + persist: false +# slide transition: https://sli.dev/guide/animations#slide-transitions +#transition: slide-left +# enable MDC Syntax: https://sli.dev/guide/syntax#mdc-syntax +mdc: true +layout: center +--- + +![](https://microsoft.github.io/genaiscript/images/favicon.svg){ style="width: 12rem; margin:auto;" } + +# GenAIScript + +## LLM Agents + +
+
+ +https://microsoft.github.io/genaiscript/ + + +--- +src: pages/script.md +--- + +--- +src: pages/tools.md +--- + +--- +src: pages/agents-concept.md +--- + +--- +src: pages/agents-multi.md +--- + +--- +src: pages/agents-memory.md +--- + +--- +src: pages/agents-prd.md +---