Skip to content

Commit

Permalink
GitBook: No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfyifanchen authored and gitbook-bot committed Aug 29, 2024
1 parent 918726e commit 48f038f
Show file tree
Hide file tree
Showing 21 changed files with 4,557 additions and 13 deletions.
Binary file added .gitbook/assets/astra-voice-agent.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/docker-restart-server.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/docker-setting.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/graph-designer.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/hello-world-python.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/star-the-repo-confetti.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/voice-agent-archietcuture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Here, you’ll get an overview of all the incredible features TEN offers to help

Before we get started, please click the [**star button on our GitHub repo**](https://github.com/rte-design/astra.ai) to stay updated with one of the AI agents powered by TEN.

<figure><img src=".gitbook/assets/star_the_repo_confetti.gif" alt=""><figcaption><p>Star us to stay updated</p></figcaption></figure>
<figure><img src=".gitbook/assets/star-the-repo-confetti.gif" alt=""><figcaption><p>Star us to stay updated</p></figcaption></figure>

### Jump right in

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Getting started</strong></td><td>Quickstart to build locally </td><td><a href=".gitbook/assets/1.png">1.png</a></td><td></td><td><a href="getting_started/quickstart.md">quickstart.md</a></td></tr><tr><td><strong>Customize agent</strong></td><td>Two ways to customize</td><td><a href=".gitbook/assets/4.png">4.png</a></td><td></td><td><a href="getting_started/publish_your_docs.md">publish_your_docs.md</a></td></tr><tr><td><strong>Create hello world extension</strong></td><td>Build extensions right away</td><td><a href=".gitbook/assets/3.png">3.png</a></td><td></td><td><a href="getting_started/create_a_hello_world_extension.md">create_a_hello_world_extension.md</a></td></tr></tbody></table>
<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Getting started</strong></td><td>Quickstart to build locally</td><td><a href=".gitbook/assets/1.png">1.png</a></td><td></td><td><a href="getting-started/quickstart.md">quickstart.md</a></td></tr><tr><td><strong>Customize agent</strong></td><td>Two ways to customize</td><td><a href=".gitbook/assets/4.png">4.png</a></td><td></td><td><a href="getting-started/publish-your-docs.md">publish-your-docs.md</a></td></tr><tr><td><strong>Create hello world extension</strong></td><td>Build extensions right away</td><td><a href=".gitbook/assets/3.png">3.png</a></td><td></td><td><a href="getting-started/create-a-hello-world-extension.md">create-a-hello-world-extension.md</a></td></tr></tbody></table>
22 changes: 11 additions & 11 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

## 🎉 Getting Started

* [Quickstart](getting_started/quickstart.md)
* [Customize your agent](getting_started/publish_your_docs.md)
* [Create a hello world extension](getting_started/create_a_hello_world_extension.md)
* [Quickstart](getting-started/quickstart.md)
* [Customize your agent](getting-started/publish-your-docs.md)
* [Create a hello world extension](getting-started/create-a-hello-world-extension.md)

## TEN Service

* [🚧 TEN architecture(beta)](ten-service/ten_architecture_beta.md)
* [🚧 TEN schema(beta)](ten-service/ten_schema_beta.md)
* [TEN API(beta)](ten-service/ten_api_beta.md)
* [🚧 TEN Message type and name(beta)](ten-service/ten_message_type_and_name_beta.md)
* [🚧 Astra AI agent architecture(beta)](ten-service/astra_ai_agent_architecture_beta.md)
* [🚧 TEN architecture(beta)](ten-service/ten-architecture-beta.md)
* [🚧 TEN schema(beta)](ten-service/ten-schema-beta.md)
* [TEN API(beta)](ten-service/ten-api-beta.md)
* [🚧 TEN Message type and name(beta)](ten-service/ten-message-type-and-name-beta.md)
* [🚧 Astra AI agent architecture(beta)](ten-service/astra-ai-agent-architecture-beta.md)

## Tutorials

* [How to debug with logs](tutorials/how_to_debug_with_logs.md)
* [🚧 How to build extension with Go(beta)](tutorials/how_to_build_extension_with_go_beta.md)
* [🚧 How to build extension with C++(beta)](tutorials/how_to_build_extension_with_c++_beta.md)
* [How to debug with logs](tutorials/how-to-debug-with-logs.md)
* [🚧 How to build extension with Go(beta)](tutorials/how-to-build-extension-with-go-beta.md)
* [🚧 How to build extension with C++(beta)](tutorials/how-to-build-extension-with-c++-beta.md)
190 changes: 190 additions & 0 deletions getting-started/create-a-hello-world-extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
---
layout:
title:
visible: true
description:
visible: false
tableOfContents:
visible: true
outline:
visible: true
pagination:
visible: true
---

# Create a hello world extension

In this chapter, we are going to create a `Hello World` extension step by step, available in Python, Go, and C++. Feel free to choose whichever language you prefer. So buckle up.

## Prerequisites

Before diving into this chapter, you’ll need to be familiar with the [basics covered earlier](quickstart.md). Specifically, ensure you understand how to use `docker compose up` and are aware of the services running in the background.

## 1. Compose up the servers

First things first, let’s start by composing the servers. Run the following command:

{% hint style="info" %}
If the caption says `Terminal`, it means you are running the command locally. If the caption says `Bash`, it means you are running the command in the Docker container.
{% endhint %}

{% code title=">_ Terminal" %}
```bash
docker compose up
```
{% endcode %}

Once the command is entered, you should see output similar to this:

<pre class="language-bash" data-title=">_ Terminal"><code class="lang-bash">....
Attaching to astra_agents_dev, astra_graph_designer, astra_playground
astra_agents_dev | >> run graph designer server
astra_agents_dev | cd agents &#x26;&#x26; tman dev-server
<strong>astra_agents_dev | :-) Starting server at http://0.0.0.0:49483
</strong>astra_graph_designer | ▲ Next.js 14.2.4
<strong>astra_graph_designer | - Local: http://localhost:3000
</strong>astra_graph_designer | - Network: http://0.0.0.0:3000
astra_graph_designer |
astra_graph_designer | ✓ Starting...
astra_playground | ▲ Next.js 14.2.4
<strong>astra_playground | - Local: http://localhost:3000
</strong>astra_playground | - Network: http://0.0.0.0:3000
astra_playground |
astra_playground | ✓ Starting...
astra_graph_designer | ✓ Ready in 293ms
astra_playground | ✓ Ready in 293ms
...
</code></pre>

Now, we’ve got the following services running:

`astra_agents_dev` at `http://0.0.0.0:49483` (the backend server for the Graph Designer)

`astra_graph_designer` at `http://localhost:3000` (the UI of the Graph Designer)

`astra_playground` at `http://localhost:3001` (the UI of the Astra agent)

## 2. Enter the docker container

To work within the isolated environment, run the following command:

{% code title=">_ Terminal" %}
```bash
docker exec -it astra_agents_dev bash
```
{% endcode %}

## 3. Create the hello world extension

By running the following commands, an extension called `hello_world` will be created in Python, Go, or C++.

{% tabs %}
{% tab title="Python" %}
<pre class="language-bash" data-title=">_ Bash" data-overflow="wrap"><code class="lang-bash">cd agents/ten_packages/extension

<strong>tman install extension default_extension_python --template-mode --template-data package_name=hello_world --template-data class_name_prefix=HelloWorld
</strong>
cd /app
</code></pre>
{% endtab %}

{% tab title="Go" %}
<pre class="language-bash" data-title=">_ Bash" data-overflow="wrap"><code class="lang-bash">cd agents/ten_packages/extension

<strong>tman install extension default_extension_go --template-mode --template-data package_name=hello_world --template-data class_name_prefix=HelloWorld
</strong>
cd /app
</code></pre>
{% endtab %}

{% tab title="C++" %}
<pre class="language-bash" data-title=">_ Bash" data-overflow="wrap"><code class="lang-bash">cd agents/ten_packages/extension

<strong>tman install extension default_extension_cpp --template-mode --template-data package_name=hello_world --template-data class_name_prefix=HelloWorld
</strong>
cd /app
</code></pre>
{% endtab %}
{% endtabs %}

After running the command, the log will display something like this:

<pre class="language-bash" data-title=">_ Bash"><code class="lang-bash">...
Resolving packages...
<strong>:-) Install successfully in xxx seconds
</strong>...
</code></pre>

## 4. Adding API to the extension

Navigate into the `hello_world` directory and open manifest.json. Add the API objects with `data_in` and `cmd_out`, which we will use shortly within the Graph Designer:

<pre class="language-json" data-title="./hello_world/manifest.json"><code class="lang-json">{
"type": "extension",
"name": "hello_world",
"version": "0.4.1",
"language": "python",
"dependencies": [
{
"type": "system",
"name": "rte_runtime_python",
"version": "0.4.1"
}
],
"api": {
<strong> "data_in": [
</strong><strong> {
</strong><strong> "name": "text_data",
</strong><strong> "property": {
</strong><strong> "text": {
</strong><strong> "type": "string"
</strong><strong> },
</strong><strong> "is_final": {
</strong><strong> "type": "bool"
</strong><strong> }
</strong><strong> }
</strong><strong> }
</strong><strong> ],
</strong><strong> "cmd_out": [
</strong><strong> {
</strong><strong> "name": "flush"
</strong><strong> }
</strong><strong> ]
</strong> }
}
</code></pre>

For detailed information on the API and schema, please refer to [ten-api-beta.md](../ten-service/ten-api-beta.md "mention") and [ten-schema-beta.md](../ten-service/ten-schema-beta.md "mention").

## 5. Build the extension

Let's use `cd /app` command to go back to the root of the project, and run `make build` to build the extension.

{% code title=">_ Bash" %}
```bash
cd /app

make build
```
{% endcode %}

## 6. Restart the server

You don’t need to restart the server when you first build the agent. However, after making minor updates, if refreshing the page doesn’t apply the changes, you’ll need to restart the server in Docker to ensure the updates take effect.

<figure><img src="../.gitbook/assets/docker-restart-server.gif" alt=""><figcaption><p>Restart the server for astra_agents_dev</p></figcaption></figure>

## 7. Verify the extension&#x20;

Open `http://localhost:3001` in your browser. You should see `hello_world` in the left menu. Drag it to the canvas, and connect it to the `text_data` input and `flash` output.

You see the green and red color indicting the possible routes of node connecting.&#x20;

<figure><img src="../.gitbook/assets/hello-world-python.gif" alt=""><figcaption><p>hello_world extension</p></figcaption></figure>

Congratulations! You’ve successfully created your first `hello_world` extension, and it’s working seamlessly within the Graph Designer canvas.

## 8. Check the network requests

Open Chrome DevTools, navigate to the Network panel, and monitor the requests. You should see the status codes returning as 200, indicating that the changes have been successfully processed.

70 changes: 70 additions & 0 deletions getting-started/publish-your-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
layout:
title:
visible: true
description:
visible: false
tableOfContents:
visible: true
outline:
visible: true
pagination:
visible: true
---

# Customize your agent

There are two primary methods to customize the Astra agent locally:

## Using the power of graph designer (recommended)

<figure><img src="../.gitbook/assets/graph-designer.gif" alt=""><figcaption></figcaption></figure>

The Graph Designer is a user-friendly, visual tool that allows you to create and modify the behavior and responses of the Astra agent without needing to write code. This approach is highly recommended for its ease of use and efficiency. By leveraging the Graph Designer, you can quickly design complex interactions and workflows through a graphical interface, making it accessible even for those with limited programming experience.

## Editing the code yourself

For those who prefer a more hands-on approach or need advanced customization, you can directly edit the source code of the Astra agent. This method requires a good understanding of the codebase and programming languages used in the project. By manually editing the code, you have full control over every aspect of the agent’s functionality, allowing for highly tailored and specific customizations. This approach is ideal for developers who need to implement unique features or integrate the agent with other systems.

{% tabs %}
{% tab title="property.json" %}
<pre class="language-json" data-title="./agents/property.json"><code class="lang-json">// ...
"nodes": [
{
"type": "extension",
"extension_group": "default",
"addon": "agora_rtc",
"name": "agora_rtc",
"property": {
<strong> "app_id": "app-id",
</strong> "token": "&#x3C;agora_token>",
"channel": "astra_agents_test",
"stream_id": 1234,
"remote_stream_id": 123,
"subscribe_audio": true,
"publish_audio": true,
"publish_data": true,
"enable_agora_asr": true,
"agora_asr_vendor_name": "microsoft",
"agora_asr_language": "en-US",
<strong> "agora_asr_vendor_key": "stt-key",
</strong><strong> "agora_asr_vendor_region": "stt-region",
</strong> "agora_asr_session_control_file_path": "session_control.conf"
}
},
// ...
</code></pre>


{% endtab %}

{% tab title="config.go" %}
<pre class="language-go" data-title="config.go"><code class="lang-go">// ...
// Default graph name
<strong>graphNameDefault = "va.openai.azure"
</strong>// ...
</code></pre>
{% endtab %}
{% endtabs %}

Save both files, then run `make build`. Your agent, complete with the intended extensions, should now be up and running.
Loading

0 comments on commit 48f038f

Please sign in to comment.