Skip to content

Commit

Permalink
Move examples to project root (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
krasserm authored Feb 13, 2025
1 parent 0b83499 commit 2935283
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ python -m freeact.cli \
--skill-modules=freeact_skills.search.google.stream.api
```

or an equivalent [quickstart.py](freeact/examples/quickstart.py) script:
or an equivalent [quickstart.py](examples/quickstart.py) script:

```python
import asyncio
Expand Down
4 changes: 2 additions & 2 deletions docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Although we could instantiate `GenericModel` directly with these prompt template

Here's a Python example that uses `QwenCoder` as code action model in a `freeact` agent. The model is accessed via the Hugging Face Inference API:

```python title="freeact/examples/qwen.py"
--8<-- "freeact/examples/qwen.py"
```python title="examples/qwen.py"
--8<-- "examples/qwen.py"
```

1. Your Hugging Face [user access token](https://huggingface.co/docs/hub/en/security-tokens)
Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ python -m freeact.cli \

or an equivalent Python script:

```python title="freeact/examples/quickstart.py"
--8<-- "freeact/examples/quickstart.py"
```python title="examples/quickstart.py"
--8<-- "examples/quickstart.py"
```

Once launched, you can start interacting with the agent:
Expand Down
32 changes: 20 additions & 12 deletions docs/tutorials/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ A `freeact` agent system consists of:
- A code action model that generates *code actions* to be executed by the executor. Models must implement the interfaces defined in the [`freeact.model`](../api/model.md) package. This tutorial uses [`Claude`][freeact.model.claude.model.Claude], configured with `claude-3-5-sonnet-20241022` as model name.
- A [`CodeActAgent`][freeact.agent.CodeActAgent] configured with both the model and executor. It orchestrates their interaction until a final response is ready.

```python title="freeact/examples/basics.py"
--8<-- "freeact/examples/basics.py"
```python title="examples/basics.py"
--8<-- "examples/basics.py"
```

1.
```python title="freeact/examples/utils.py::stream_conversation"
--8<-- "freeact/examples/utils.py:stream_conversation"
--8<-- "freeact/examples/utils.py:stream_turn"
```python title="examples/utils.py::stream_conversation"
--8<-- "examples/utils.py:stream_conversation"
--8<-- "examples/utils.py:stream_turn"
```

2. Tag of the `ipybox` Docker image.
Expand All @@ -35,9 +35,9 @@ A `CodeActAgent` can engage in multi-turn conversations with a user. Each turn i
{ .annotate }

1.
```python title="freeact/examples/utils.py::stream_conversation"
--8<-- "freeact/examples/utils.py:stream_conversation"
--8<-- "freeact/examples/utils.py:stream_turn"
```python title="examples/utils.py::stream_conversation"
--8<-- "examples/utils.py:stream_conversation"
--8<-- "examples/utils.py:stream_turn"
```

This tutorial uses the `freeact_skills.search.google.stream.api` skill module from the [`freeact-skills`](https://gradion-ai.github.io/freeact-skills/) project to process queries that require internet searches. This module provides generative Google search capabilities powered by the Gemini 2 API.
Expand All @@ -63,22 +63,30 @@ The tutorials use the prebuilt [`ghcr.io/gradion-ai/ipybox:example`](../environm

## Running

The Python example above is part of the `freeact` package and can be run with:
Download the Python example

```shell
python -m freeact.examples.basics
mkdir examples
curl -o examples/basics.py https://raw.githubusercontent.com/gradion-ai/freeact/refs/heads/main/freeact/examples/basics.py
curl -o examples/utils.py https://raw.githubusercontent.com/gradion-ai/freeact/refs/heads/main/freeact/examples/utils.py
```

and run it with:

```shell
python examples/basics.py
```

For formatted and colored console output, as shown in the [example conversation](#example-conversation), you can use the `freeact` [CLI](../cli.md):

```shell
--8<-- "freeact/examples/commands.txt:cli-basics-claude"
--8<-- "examples/commands.txt:cli-basics-claude"
```

To use Gemini instead of Claude, run:

```shell
--8<-- "freeact/examples/commands.txt:cli-basics-gemini"
--8<-- "examples/commands.txt:cli-basics-gemini"
```

See also [Supported models](../models.md) for other CLI examples.
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ This tutorial demonstrates how `freeact` agents can be customized through system
The [example conversation](#example-conversation) below was guided by this system extension:

```text title="extension.txt"
--8<-- "freeact/examples/extension.txt"
--8<-- "examples/extension.txt"
```

It was initiated with the following `freeact.cli` command, referencing the `extension.txt` file with the `--system-extension` option and reusing the developed `weather.weather_report` skill from the [Skill development](skills.md) tutorial.

```shell
--8<-- "freeact/examples/commands.txt:cli-extension"
--8<-- "examples/commands.txt:cli-extension"
```

### Example conversation
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The [example conversation](#example-conversation) below was initiated with the f
[^1]: The provided skill modules are not needed in this example but included to demonstrate that their usage is optional.

```shell
--8<-- "freeact/examples/commands.txt:cli-skills"
--8<-- "examples/commands.txt:cli-skills"
```

### Example conversation
Expand All @@ -64,7 +64,7 @@ The example shows a request for weather data from Paris and Berlin, where the ag
The example conversation was initiated with the following `freeact.cli` command. The developed skill is is read from `workspace/skills/private/example`. If we moved it to `workspace/skills/shared`, it would be available to all executors regardless of their `executor-key` value.

```shell
--8<-- "freeact/examples/commands.txt:cli-skills-weather"
--8<-- "examples/commands.txt:cli-skills-weather"
```

!!! Note
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion freeact/examples/basics.py → examples/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

from dotenv import load_dotenv

from examples.utils import stream_conversation
from freeact import (
Claude,
CodeActAgent,
CodeExecutionContainer,
CodeExecutor,
)
from freeact.examples.utils import stream_conversation
from freeact.logger import Logger


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2935283

Please sign in to comment.