Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor agent_fs to defAgent and update related documentation #755

Merged
merged 7 commits into from
Oct 4, 2024
34 changes: 29 additions & 5 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/src/components/BuiltinAgents.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Builtin Agents
description: List of agents in system prompts
---
import { LinkCard } from '@astrojs/starlight/components';

### Builtin Agents

<LinkCard title="fs" description="Queries files to accomplish tasks" href="/genaiscript/reference/scripts/system#systemagent_fs" />
<LinkCard title="git" description="Agent that can query a repository using Git to accomplish tasks. Provide all the context information available to execute git queries." href="/genaiscript/reference/scripts/system#systemagent_git" />
<LinkCard title="github" description="Agent that can query GitHub to accomplish tasks" href="/genaiscript/reference/scripts/system#systemagent_github" />
<LinkCard title="interpreter" description="Run code interpreters for Python, Math. Use this agent to ground computation questions." href="/genaiscript/reference/scripts/system#systemagent_interpreter" />
<LinkCard title="user_input" description="Ask user for input to confirm, select or answer a question." href="/genaiscript/reference/scripts/system#systemagent_user_input" />
17 changes: 6 additions & 11 deletions docs/src/components/BuiltinTools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,19 @@

### Builtin tools

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link to the agent_fs documentation has been removed, which may lead to a broken link or missing information for users.

generated by pr-docs-review-commit broken_link

<LinkCard title="agent_fs" description="Agent that can query files to accomplish tasks" href="/genaiscript/reference/scripts/system#systemagent_fs" />
<LinkCard title="agent_git" description="Agent that can query a repository using Git to accomplish tasks. Provide all the context information available to execute git queries." href="/genaiscript/reference/scripts/system#systemagent_git" />
<LinkCard title="agent_github" description="Agent that can query GitHub to accomplish tasks" href="/genaiscript/reference/scripts/system#systemagent_github" />
<LinkCard title="agent_interpreter" description="Run code interpreters for Python, Math. Use this agent to ground computation questions." href="/genaiscript/reference/scripts/system#systemagent_interpreter" />
<LinkCard title="agent_user_input" description="Ask user for input to confirm, select or answer a question." href="/genaiscript/reference/scripts/system#systemagent_user_input" />
<LinkCard title="fs_diff_files" description="Computes a diff between two files." href="/genaiscript/reference/scripts/system#systemfs_diff_files" />

Check failure on line 9 in docs/src/components/BuiltinTools.mdx

View workflow job for this annotation

GitHub Actions / build

There seems to be a typo here.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a typo here.

generated by pr-docs-review-commit typo

<LinkCard title="fs_find_files" description="Finds file matching a glob pattern. Use pattern to specify a regular expression to search for in the file content." href="/genaiscript/reference/scripts/system#systemfs_find_files" />
<LinkCard title="fs_read_file" description="Reads a file as text from the file system. Returns undefined if the file does not exist." href="/genaiscript/reference/scripts/system#systemfs_read_file" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'agent_fs', 'agent_git', 'agent_github', 'agent_interpreter', and 'agent_user_input' LinkCards have been removed. Ensure that this change is intentional and that any references to these agents are updated accordingly in the documentation.

generated by pr-docs-review-commit documentation_update

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of several LinkCard components may indicate that the corresponding agents are deprecated or moved. Ensure that this change is intentional and that any references to these agents are updated or removed elsewhere in the documentation to maintain consistency.

generated by pr-docs-review-commit documentation_content

<LinkCard title="git_branch_current" description="Gets the current branch using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_branch_list" description="List all branches using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_diff" description="Computes file diffs using git. If the diff is too large, it returns the list of modified/added files." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_log" description="Generates a log of commits using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_diff" description="Computes file diffs using the git diff command. If the diff is too large, it returns the list of modified/added files." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_list_commits" description="Generates a history of commits using the git log command." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_status" description="Generates a status of the repository using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="git_last_tag" description="Gets the last tag using git." href="/genaiscript/reference/scripts/system#systemgit" />
<LinkCard title="github_actions_workflows_list" description="List all workflows as a list of 'id: name' pair." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_jobs_list" description="List all jobs for a run." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_job_logs_get" description="Download workflow job log. If the log is too large, use 'github_actions_job_logs_diff' to compare logs." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_job_logs_diff" description="Diffs two workflow job logsr." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_workflows_list" description="List all github workflows." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_jobs_list" description="List all jobs for a github workflow run." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_job_logs_get" description="Download github workflow job log. If the log is too large, use 'github_actions_job_logs_diff' to compare logs." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_actions_job_logs_diff" description="Diffs two github workflow job logs." href="/genaiscript/reference/scripts/system#systemgithub_actions" />
<LinkCard title="github_files_get" description="Get a file from a repository." href="/genaiscript/reference/scripts/system#systemgithub_files" />
<LinkCard title="github_files_list" description="List all files in a repository." href="/genaiscript/reference/scripts/system#systemgithub_files" />
<LinkCard title="github_issues_list" description="List all issues in a repository." href="/genaiscript/reference/scripts/system#systemgithub_issues" />
Expand Down
66 changes: 45 additions & 21 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { FileTree } from "@astrojs/starlight/components"
import AudioPlayer from "../../components/AudioPlayer.astro"
import DirectoryLinks from "../../components/DirectoryLinks.astro"
import { Content as BuiltinAgents } from "../../components/BuiltinAgents.mdx"

import vscodeSrc from "../../../public/images/visual-studio-code.png"

Expand Down Expand Up @@ -116,6 +117,43 @@

</Card>

<Card title="LLM Tools" icon="setting">

Register JavaScript functions as [LLM tools](/genaiscript/reference/scripts/tools/)

```js wrap
defTool("weather", "live weahter",

Check failure on line 125 in docs/src/content/docs/index.mdx

View workflow job for this annotation

GitHub Actions / build

There seems to be a typo here.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a typo here.

generated by pr-docs-review-commit typo

{ city: "Paris" }, // schema
async ({ city }) => // callback
{ ... "sunny" }
)
```

or use built-in [@agentic tools](/genaiscript/guides/agentic-tools/)

```js wrap
import { WeatherClient } from "@agentic/weather"
defTool(new WeatherClient())
```

</Card>

<Card title="LLM Agents" icon="sun">

Combine [tools](/genaiscript/reference/scripts/tools) and [inline prompts](/genaiscript/reference/scripts/inline-prompts/)
into an [agent](/genaiscript/reference/scripts/agents).

```js wrap
defAgent(
"git",

Check failure on line 148 in docs/src/content/docs/index.mdx

View workflow job for this annotation

GitHub Actions / build

There seems to be a typo here.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a typo here.

generated by pr-docs-review-commit typo

"Agent that answer git questions for the current repo",
"You are a helpful expert in using git.",
{ tools: ["git"] }
)
```

</Card>

<Card title="Reuse and Share Scripts" icon="star">

Scripts are [files](/genaiscript/reference/scripts/)! They can be versioned, shared, forked, ...
Expand Down Expand Up @@ -259,27 +297,6 @@

</Card>

<Card title="LLM Tools" icon="setting">

Register JavaScript functions as [LLM tools](/genaiscript/reference/scripts/tools/)

```js wrap
defTool("weather", "live weahter",
{ city: "Paris" }, // schema
async ({ city }) => // callback
{ ... "sunny" }
)
```

or use built-in [@agentic tools](/genaiscript/guides/agentic-tools/)

```js wrap
import { WeatherClient } from "@agentic/weather"
defTool(new WeatherClient())
```

</Card>

<Card title="Code Interpreter" icon="seti:python">

Let the LLM run code in a sandboxed execution environment.
Expand Down Expand Up @@ -379,16 +396,23 @@
</CardGrid>

## Case Studies

Tales from the real world using GenAIScript.

<DirectoryLinks directory="case-studies" />

## Samples

Fully fledged scripts ready to use.

<DirectoryLinks directory="samples" />

## Guides

A cookbook full of recipes to make you a genius scripter.

<DirectoryLinks directory="guides" />

## Agents

<BuiltinAgents />
37 changes: 37 additions & 0 deletions docs/src/content/docs/reference/scripts/agents.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Agents (LLM Tools)
description: An Agent is a tool that queries LLM, equipped with other tools, to accomplish tasks.
sidebar:
order: 7.1
---

import { Content as BuiltinAgents } from "../../../../components/BuiltinAgents.mdx"

GenAIScript defines an **agent** as a [tool](/genaiscript/reference/scripts/tools) that
runs an [inline prompt](/genaiscript/reference/scripts/inline-prompts) to accomplish a task. The agent LLM is typically augmented with
additional tools.

## Agent flow engine

**GenAIScript does _not_ implement any agentic workflow or decision.**
It relies entierly on [tools](/genaiscript/reference/scripts/tools) support builtin to the LLMs.

## defAgent

The `defAgent` function is used to define an agent that can be called by the LLM. It takes a JSON schema to define the input and expects a string output. The LLM decides to call this agent on its own!

```ts
defAgent(
"git", // agent id becomes 'agent_git'
"Handles any git operation", // description
"You are a helpful expert in using git.",
{
tools: ["git"],
}
)
```

- the agent id will become the tool id `agent_<id>`
- the description of the agent will automatically be augmented with information about the available tools

<BuiltinAgents />
Loading