Begin work on agent core

This commit is contained in:
2024-10-27 10:35:05 +01:00
parent a110140d5b
commit d922c12556
9 changed files with 330 additions and 76 deletions

View File

@@ -424,15 +424,16 @@ Module: Docker
#### Function declaration
```python
def start_container(
self,
image: str,
name: str = None,
name: Optional[str] = None,
timeout: int = -1,
command: str = None,
arguments: List[str] = None,
volumes: Dict[str, str] = None, # host_path: container_path
ports: Dict[str, str] = None, # host_port: container_port
environment: Dict[str, str] = None, # key: value
) -> None:
command: Optional[str] = None,
arguments: Optional[List[str]] = None,
volumes: Optional[Dict[str, str]] = None,
ports: Optional[Dict[str, str]] = None,
environment: Optional[Dict[str, str]] = None,
) -> Optional[str]:
"""Start a new Docker container with the specified configuration.
Args:
@@ -447,6 +448,10 @@ def start_container(
name or timeout must be provided.
Returns:
For short-lived containers (with timeout): Container output
For long-running containers: None
Example:
start_container(
image="busybox:latest",
@@ -558,45 +563,6 @@ Standard output and standard error are merged and added as `CDATA` text node.
For long running containers, no information is added.
The container is started and represented in the containers section of the main context.
### Stop container
Module: Docker
#### Function declaration
```python
def stop_container(name: str) -> None:
"""Stop a Docker container by name.
Args:
name: Name of the container to stop
"""
pass
```
#### Schema
```xml
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="stop_container">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
```
#### Example
```xml
<stop_container>my-long-running-container</stop_container>
```
#### Results
No information is added.
The container will be removed from the containers section of the main context.
### Write to container standard input
Module: Docker
@@ -728,12 +694,15 @@ Module: Docker
#### Function declaration
```python
def wait_container(name: str, timeout: int):
def wait_container(self, name: str, timeout: int) -> Tuple[int, str]:
"""Wait for a container to finish execution.
Args:
name: Name of the container to wait for
timeout: Time to wait in milliseconds
Returns:
Tuple of (exit_code, output)
"""
pass
```
@@ -744,11 +713,8 @@ def wait_container(name: str, timeout: int):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="wait_container">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="timeout" type="xs:integer" use="required"/>
</xs:extension>
</xs:simpleContent>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="timeout" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -756,7 +722,7 @@ def wait_container(name: str, timeout: int):
#### Example
```xml
<wait_container timeout="5000">background-task</wait_container>
<wait_container name="background-task" timeout="5000"/>
```
#### Results
@@ -769,7 +735,7 @@ Module: Reinforcement Learning
#### Function declaration
```python
def select_llm(path: str) -> None:
def set_model_path(path: str) -> None:
"""Switch to a different LLM model file.
Args:
@@ -782,7 +748,7 @@ def select_llm(path: str) -> None:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="select_llm">
<xs:element name="set_model_path">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string"/>
@@ -794,7 +760,7 @@ def select_llm(path: str) -> None:
#### Example
```xml
<select_llm>/models/2024_10_19_15_03_52</select_llm>
<set_model_path>/models/2024_10_19_15_03_52</set_model_path>
```
#### Results
@@ -905,10 +871,13 @@ Location: Somewhere in Belgium
John did not specify an exact time. I'll suggest 9am. He also did not specify how to be reminded. I'll ask but if he doesn't respond I'll assume a text message on standard output is fine. I'll write down this task in a file so I can keep it in context. I can write simple files with busybox:latest and echo but I will need to use sh -c to do the redirect.
<actions>
<write_stdout message="I'll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?"/>
<start_container image="busybox:latest" timeout="1000" volumes="/tasks:/tasks">
<start_container image="busybox:latest" timeout="1000">
<command>sh</command>
<argtument>-c</argument>
<argument><![CDATA[echo 'Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.' > /tasks/reminder.txt]]></argument>
<volumes>
<volume>/tasks:/tasks</volume>
</volumes>
</start_container>
<monitor_file path="/tasks/reminder.txt"/>
</actions>