acp-sdk 0.8.1__tar.gz → 0.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/PKG-INFO +1 -1
- acp_sdk-0.8.2/docs/.gitignore +1 -0
- acp_sdk-0.8.2/docs/Makefile +20 -0
- acp_sdk-0.8.2/docs/conf.py +30 -0
- acp_sdk-0.8.2/docs/index.rst +17 -0
- acp_sdk-0.8.2/docs/make.bat +35 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/pyproject.toml +1 -1
- acp_sdk-0.8.1/docs/_sidebar.md +0 -7
- acp_sdk-0.8.1/docs/client.md +0 -99
- acp_sdk-0.8.1/docs/index.html +0 -104
- acp_sdk-0.8.1/docs/models.md +0 -45
- acp_sdk-0.8.1/docs/server.md +0 -103
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/.gitignore +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/.python-version +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/README.md +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/pytest.ini +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/client/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/client/client.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/client/types.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/client/utils.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/instrumentation.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/models/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/models/errors.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/models/models.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/models/schemas.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/py.typed +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/agent.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/app.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/bundle.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/context.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/errors.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/logging.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/server.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/session.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/telemetry.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/types.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/server/utils.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/src/acp_sdk/version.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/conftest.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/config.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/fixtures/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/fixtures/client.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/fixtures/server.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/test_suites/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/test_suites/test_discovery.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/e2e/test_suites/test_runs.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/unit/client/test_client.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/unit/client/test_utils.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/unit/models/__init__.py +0 -0
- {acp_sdk-0.8.1 → acp_sdk-0.8.2}/tests/unit/models/test_models.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
_build/
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
2
|
+
#
|
3
|
+
|
4
|
+
# You can set these variables from the command line, and also
|
5
|
+
# from the environment for the first two.
|
6
|
+
SPHINXOPTS ?=
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
8
|
+
SOURCEDIR = .
|
9
|
+
BUILDDIR = _build
|
10
|
+
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
12
|
+
help:
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
14
|
+
|
15
|
+
.PHONY: help Makefile
|
16
|
+
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
19
|
+
%: Makefile
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
2
|
+
#
|
3
|
+
# For the full list of built-in configuration values, see the documentation:
|
4
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
5
|
+
|
6
|
+
# -- Project information -----------------------------------------------------
|
7
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
8
|
+
|
9
|
+
project = "ACP SDK"
|
10
|
+
copyright = "2025, IBM Corp."
|
11
|
+
author = "IBM Corp."
|
12
|
+
|
13
|
+
# -- General configuration ---------------------------------------------------
|
14
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
15
|
+
|
16
|
+
extensions = ["autoapi.extension"]
|
17
|
+
|
18
|
+
templates_path = ["_templates"]
|
19
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
20
|
+
|
21
|
+
|
22
|
+
# -- Options for HTML output -------------------------------------------------
|
23
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
|
24
|
+
|
25
|
+
html_theme = "alabaster"
|
26
|
+
html_static_path = ["_static"]
|
27
|
+
|
28
|
+
autoapi_dirs = ["../src/acp_sdk"]
|
29
|
+
autoapi_root = "api-reference"
|
30
|
+
autoapi_generate_api_docs = True
|
@@ -0,0 +1,17 @@
|
|
1
|
+
.. ACP SDK documentation master file, created by
|
2
|
+
sphinx-quickstart on Wed Apr 30 07:50:18 2025.
|
3
|
+
You can adapt this file completely to your liking, but it should at least
|
4
|
+
contain the root `toctree` directive.
|
5
|
+
|
6
|
+
ACP SDK documentation
|
7
|
+
=================
|
8
|
+
|
9
|
+
Add your content using ``reStructuredText`` syntax. See the
|
10
|
+
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
|
11
|
+
documentation for details.
|
12
|
+
|
13
|
+
|
14
|
+
.. toctree::
|
15
|
+
:maxdepth: 2
|
16
|
+
:caption: Contents:
|
17
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
@ECHO OFF
|
2
|
+
|
3
|
+
pushd %~dp0
|
4
|
+
|
5
|
+
REM Command file for Sphinx documentation
|
6
|
+
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
8
|
+
set SPHINXBUILD=sphinx-build
|
9
|
+
)
|
10
|
+
set SOURCEDIR=.
|
11
|
+
set BUILDDIR=_build
|
12
|
+
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
14
|
+
if errorlevel 9009 (
|
15
|
+
echo.
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
20
|
+
echo.
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
22
|
+
echo.https://www.sphinx-doc.org/
|
23
|
+
exit /b 1
|
24
|
+
)
|
25
|
+
|
26
|
+
if "%1" == "" goto help
|
27
|
+
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
29
|
+
goto end
|
30
|
+
|
31
|
+
:help
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
33
|
+
|
34
|
+
:end
|
35
|
+
popd
|
acp_sdk-0.8.1/docs/_sidebar.md
DELETED
acp_sdk-0.8.1/docs/client.md
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# Client
|
2
|
-
|
3
|
-
<!-- TOC -->
|
4
|
-
## Table of Contents
|
5
|
-
- [Client](#client)
|
6
|
-
- [Table of Contents](#table-of-contents)
|
7
|
-
- [Overview](#overview)
|
8
|
-
- [Usage](#usage)
|
9
|
-
- [Setting up a client](#setting-up-a-client)
|
10
|
-
- [Performing discovery](#performing-discovery)
|
11
|
-
- [Running an agent](#running-an-agent)
|
12
|
-
- [Using sessions](#using-sessions)
|
13
|
-
<!-- /TOC -->
|
14
|
-
|
15
|
-
---
|
16
|
-
|
17
|
-
## Overview
|
18
|
-
|
19
|
-
The client module provides a thin ACP client that can be integrated into any application that needs to communicate with ACP agents. It provides the following advantages over raw HTTP client:
|
20
|
-
|
21
|
-
- Strong typing
|
22
|
-
- Error handling
|
23
|
-
- Stream decoding
|
24
|
-
- Session management
|
25
|
-
- Instrumentation
|
26
|
-
|
27
|
-
> [!NOTE]
|
28
|
-
>
|
29
|
-
> Location within the sdk: [client](/python/src/acp_sdk/client)
|
30
|
-
|
31
|
-
## Usage
|
32
|
-
|
33
|
-
The client is based on the [httpx.AsyncClient](https://www.python-httpx.org/async/). The usage is very similar as demonstrated below.
|
34
|
-
|
35
|
-
### Setting up a client
|
36
|
-
|
37
|
-
To set up a simple client, simply provide an URL:
|
38
|
-
|
39
|
-
```py
|
40
|
-
async with Client(base_url="http://localhost:8000") as client:
|
41
|
-
...
|
42
|
-
```
|
43
|
-
|
44
|
-
To use advanced HTTP configuration, provide `httpx` async client:
|
45
|
-
|
46
|
-
```py
|
47
|
-
async with Client(
|
48
|
-
client=httpx.AsyncClient(
|
49
|
-
base_url="http://localhost:8000",
|
50
|
-
headers={"token": "foobar"})
|
51
|
-
) as client:
|
52
|
-
...
|
53
|
-
```
|
54
|
-
|
55
|
-
### Performing discovery
|
56
|
-
|
57
|
-
To discover available agents:
|
58
|
-
|
59
|
-
```py
|
60
|
-
async with Client(base_url="http://localhost:8000") as client:
|
61
|
-
async for agent in client.agents():
|
62
|
-
...
|
63
|
-
```
|
64
|
-
|
65
|
-
### Running an agent
|
66
|
-
|
67
|
-
Agent run can be invoked in three modes:
|
68
|
-
|
69
|
-
```py
|
70
|
-
async with Client(base_url="http://localhost:8000") as client:
|
71
|
-
message = Message(parts=[MessagePart(content="Hello")])
|
72
|
-
|
73
|
-
# Async
|
74
|
-
run = await client.run_async(agent="agent", input=[message])
|
75
|
-
print(run.status)
|
76
|
-
|
77
|
-
# Sync - waits for completion, failure, cancellation or await
|
78
|
-
run = await client.run_sync(agent="agent", input=[message])
|
79
|
-
print(run.output)
|
80
|
-
|
81
|
-
# Stream - as sync but also receives events
|
82
|
-
async for event in client.run_stream(agent="agent", input=[message])
|
83
|
-
print(event)
|
84
|
-
```
|
85
|
-
|
86
|
-
### Using sessions
|
87
|
-
|
88
|
-
Sessions are a mechanism to have multi-turn conversations with agents.
|
89
|
-
|
90
|
-
To enter a session, create one from the client:
|
91
|
-
|
92
|
-
```py
|
93
|
-
async with Client(base_url="http://localhost:8000" as client:
|
94
|
-
agents = [agent async for agent in client.agents()]
|
95
|
-
|
96
|
-
async with client.session() as session:
|
97
|
-
for agent in agents:
|
98
|
-
await session.run_sync(agent=agent.name, input=[Message(parts=[MessagePart(content="Hello!")])])
|
99
|
-
```
|
acp_sdk-0.8.1/docs/index.html
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8" />
|
5
|
-
<title>ACP Docs</title>
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
7
|
-
<meta name="description" content="Description" />
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
|
9
|
-
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css" />
|
10
|
-
<link
|
11
|
-
rel="stylesheet"
|
12
|
-
title="docsify-darklight-theme"
|
13
|
-
href="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/style.min.css"
|
14
|
-
/>
|
15
|
-
<style>
|
16
|
-
aside.sidebar {
|
17
|
-
padding-top: 0;
|
18
|
-
}
|
19
|
-
.app-name-link img {
|
20
|
-
filter: invert(var(--docs-logo-color-invert));
|
21
|
-
}
|
22
|
-
</style>
|
23
|
-
</head>
|
24
|
-
<body>
|
25
|
-
<div id="app"></div>
|
26
|
-
<script>
|
27
|
-
function fixLinkFactory() {
|
28
|
-
var main = "https://github.com/i-am-bee/acp/tree/main";
|
29
|
-
var exampleRegex = /^[\/]{0,1}examples\/(.*)/;
|
30
|
-
var srcRegex = /^[\/]{0,1}src\/(.*)/;
|
31
|
-
var docsMatch = /^[\/]{0,1}docs\/(.*)/;
|
32
|
-
|
33
|
-
return function (url) {
|
34
|
-
if (url === "LICENSE") {
|
35
|
-
return main.concat("/LICENSE");
|
36
|
-
}
|
37
|
-
if (url.substring(0, 2) === "./") {
|
38
|
-
url = url.substring(2);
|
39
|
-
}
|
40
|
-
if (url.match(docsMatch)) {
|
41
|
-
url = url.replace(docsMatch, "$1");
|
42
|
-
}
|
43
|
-
if (url.match(exampleRegex) || url.match(srcRegex) || url === "/package.json") {
|
44
|
-
url = main.concat(url);
|
45
|
-
}
|
46
|
-
return url;
|
47
|
-
};
|
48
|
-
}
|
49
|
-
|
50
|
-
var fixLink = fixLinkFactory();
|
51
|
-
var basePath = window.location.pathname.replace(/index.html/gi, "").replace("/#/", "") || "/";
|
52
|
-
|
53
|
-
window.$docsify = {
|
54
|
-
"name": "ACP",
|
55
|
-
"basePath": basePath,
|
56
|
-
"darklightTheme": {
|
57
|
-
"defaultTheme": 'dark',
|
58
|
-
"light": {
|
59
|
-
'docs-logo-color-invert': 0,
|
60
|
-
},
|
61
|
-
"dark": {
|
62
|
-
'docs-logo-color-invert': 1,
|
63
|
-
}
|
64
|
-
},
|
65
|
-
"repo": "i-am-bee/acp",
|
66
|
-
"loadSidebar": true,
|
67
|
-
"subMaxLevel": 2,
|
68
|
-
"auto2top": true,
|
69
|
-
"search": {
|
70
|
-
depth: 6,
|
71
|
-
namespace: "acp",
|
72
|
-
},
|
73
|
-
"flexible-alerts": {
|
74
|
-
important: {
|
75
|
-
label: "Important",
|
76
|
-
icon: "icon-note",
|
77
|
-
className: "note",
|
78
|
-
},
|
79
|
-
},
|
80
|
-
"markdown": {
|
81
|
-
smartypants: true,
|
82
|
-
renderer: {
|
83
|
-
link: function (link, renderer, text) {
|
84
|
-
return this.origin.link.apply(this, [fixLink(link), renderer, text]);
|
85
|
-
},
|
86
|
-
html: function (html) {
|
87
|
-
var regex = /(src|href|srcset)\s*=\s*(['"])[\.]{0,1}\/docs\/(.+?)\2/gi;
|
88
|
-
html = html.replace(regex, "$1=$2" + basePath + "$3$2");
|
89
|
-
return html;
|
90
|
-
},
|
91
|
-
},
|
92
|
-
},
|
93
|
-
};
|
94
|
-
</script>
|
95
|
-
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
|
96
|
-
<script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js"></script>
|
97
|
-
<script src="https://unpkg.com/docsify-plugin-flexible-alerts"></script>
|
98
|
-
<script src="https://unpkg.com/docsify-copy-code@3"></script>
|
99
|
-
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
|
100
|
-
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-python.min.js"></script>
|
101
|
-
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-sql.min.js"></script>
|
102
|
-
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
|
103
|
-
</body>
|
104
|
-
</html>
|
acp_sdk-0.8.1/docs/models.md
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Models
|
2
|
-
|
3
|
-
<!-- TOC -->
|
4
|
-
## Table of Contents
|
5
|
-
- [Models](#models)
|
6
|
-
- [Table of Contents](#table-of-contents)
|
7
|
-
- [Overview](#overview)
|
8
|
-
- [Core](#core)
|
9
|
-
- [Schemas](#schemas)
|
10
|
-
- [Errors](#errors)
|
11
|
-
<!-- /TOC -->
|
12
|
-
|
13
|
-
---
|
14
|
-
|
15
|
-
## Overview
|
16
|
-
|
17
|
-
The models module provides `pydantic` models describing ACP data structures.
|
18
|
-
|
19
|
-
> [!NOTE]
|
20
|
-
>
|
21
|
-
> Location within the sdk: [models](/python/src/acp_sdk/models)
|
22
|
-
|
23
|
-
## Core
|
24
|
-
|
25
|
-
Core models are used directly by the SDK consumers. They describe ACP structures like `Message`, `MessagePart` or `Run`.
|
26
|
-
|
27
|
-
> [!NOTE]
|
28
|
-
>
|
29
|
-
> Location within the sdk: [models.models](/python/src/acp_sdk/models/models.py)
|
30
|
-
|
31
|
-
## Schemas
|
32
|
-
|
33
|
-
Schema models are used by client and server implementations. They describe payloads of HTTP requests and responses.
|
34
|
-
|
35
|
-
> [!NOTE]
|
36
|
-
>
|
37
|
-
> Location within the sdk: [models.schemas](/python/src/acp_sdk/models/schemas.py)
|
38
|
-
|
39
|
-
## Errors
|
40
|
-
|
41
|
-
Error model describes errors within the system. SDK consumers can encounter errors in various places, during a stream, as part of the `Run` model or raised inside the `ACPError` exception.
|
42
|
-
|
43
|
-
> [!NOTE]
|
44
|
-
>
|
45
|
-
> Location within the sdk: [models.errors](/python/src/acp_sdk/models/errors.py)
|
acp_sdk-0.8.1/docs/server.md
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
# Server
|
2
|
-
|
3
|
-
<!-- TOC -->
|
4
|
-
## Table of Contents
|
5
|
-
- [Server](#server)
|
6
|
-
- [Table of Contents](#table-of-contents)
|
7
|
-
- [Overview](#overview)
|
8
|
-
- [Usage](#usage)
|
9
|
-
- [Running a server](#running-a-server)
|
10
|
-
- [Standalone application](#standalone-application)
|
11
|
-
<!-- /TOC -->
|
12
|
-
|
13
|
-
---
|
14
|
-
|
15
|
-
## Overview
|
16
|
-
|
17
|
-
The server module aims to expose arbitrary agents over the Agent Commucation Protocol. Consumers can use this module to avoid protocol-specific technicalities and focus on the agent itself. The modules provides Agent abstractions, FastAPI application factory and Uvicorn-based server.
|
18
|
-
|
19
|
-
> [!NOTE]
|
20
|
-
>
|
21
|
-
> Location within the sdk: [server](/python/src/acp_sdk/server).
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
The SDK provides `Agent` abstract class and `agent` decorator. Arbitrary agent can be created in by either inheritance from the class or by using the decorator on a generator, coroutine or a regular function.
|
26
|
-
|
27
|
-
> [!NOTE]
|
28
|
-
>
|
29
|
-
> Location within the sdk: [server.agent](/python/src/acp_sdk/server/agent.py).
|
30
|
-
|
31
|
-
### Running a server
|
32
|
-
|
33
|
-
The SDK provides `Server` class as a convenience for developers to easily serve agents over ACP. The server allows to easily create and register agents. It sets up logging and optionally telemetry exporters.
|
34
|
-
|
35
|
-
<!-- embedme python/examples/servers/echo.py -->
|
36
|
-
|
37
|
-
```py
|
38
|
-
import asyncio
|
39
|
-
from collections.abc import AsyncGenerator
|
40
|
-
|
41
|
-
from acp_sdk.models import (
|
42
|
-
Message,
|
43
|
-
)
|
44
|
-
from acp_sdk.server import Context, RunYield, RunYieldResume, Server
|
45
|
-
|
46
|
-
server = Server()
|
47
|
-
|
48
|
-
|
49
|
-
@server.agent()
|
50
|
-
async def echo(input: list[Message], context: Context) -> AsyncGenerator[RunYield, RunYieldResume]:
|
51
|
-
"""Echoes everything"""
|
52
|
-
for message in input:
|
53
|
-
await asyncio.sleep(0.5)
|
54
|
-
yield {"thought": "I should echo everything"}
|
55
|
-
await asyncio.sleep(0.5)
|
56
|
-
yield message
|
57
|
-
|
58
|
-
|
59
|
-
server.run()
|
60
|
-
```
|
61
|
-
|
62
|
-
> [!NOTE]
|
63
|
-
>
|
64
|
-
> Location within the sdk: [server.server](/python/src/acp_sdk/server/server.py).
|
65
|
-
|
66
|
-
### Standalone application
|
67
|
-
|
68
|
-
The SDK provides `create_app` factory that turns agents into `FastAPI` application. The application implements route handlers, error handlers, unified execution environment and more. The application can be served with arbitrary ASGI compatible server.
|
69
|
-
|
70
|
-
<!-- embedme python/examples/servers/standalone.py -->
|
71
|
-
|
72
|
-
```py
|
73
|
-
from collections.abc import AsyncGenerator
|
74
|
-
|
75
|
-
from acp_sdk.models import (
|
76
|
-
Message,
|
77
|
-
)
|
78
|
-
from acp_sdk.server import RunYield, RunYieldResume, agent, create_app
|
79
|
-
|
80
|
-
# This example demonstrates how to serve agents with you own server
|
81
|
-
|
82
|
-
|
83
|
-
@agent()
|
84
|
-
async def echo(input: list[Message]) -> AsyncGenerator[RunYield, RunYieldResume]:
|
85
|
-
"""Echoes everything"""
|
86
|
-
for message in input:
|
87
|
-
yield message
|
88
|
-
|
89
|
-
|
90
|
-
app = create_app(echo)
|
91
|
-
|
92
|
-
# The app can now be used with any ASGI server
|
93
|
-
|
94
|
-
# Run with
|
95
|
-
# 1. fastapi run examples/servers/standalone.py
|
96
|
-
# 2. uvicorn examples.servers.standalone:app
|
97
|
-
# ...
|
98
|
-
|
99
|
-
```
|
100
|
-
|
101
|
-
> [!NOTE]
|
102
|
-
>
|
103
|
-
> Location within the sdk: [server.app](/python/src/acp_sdk/server/app.py).
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|