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

Examples #4

Merged
merged 28 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.1.3
This release introduces a [single-file Phoenix LiveView example](examples/phoenix.exs) that can be run with `elixir examples/phoenix.exs`.

In addition, this release removes the use of `Registry`, adds better error handling, and improves `GenServer` usage, including better child specs.

### Features
- Added `examples/phoenix.exs` example
- Added `Agens.Prefixes`
- Added pass-through `args` and `finalize` function to `Agens.Serving`
- Added `{:job_error, {job.name, step_index}, {:error, reason | exception}}` event to `Agens.Job`
- Added child specs to `Agens` and `Agens.Supervisor`
- Added `{:error, :job_already_running}` when calling `Agens.Job.run/2` on running job
- Added `{:error, :input_required}` when calling `Message.send/1` with empty `input`

### Breaking Changes
- Removed `Registry` usage and `registry` configuration option
- Changed `prompts` to `prefixes` on `Agens.Serving.Config`
- Added `input` to `@enforce_keys` and removed `nil` as accepted `input` type in `Agens.Message`

### Fixes
- Removed `restart: :transient` from `Agens.Serving` and `Agens.Agent` child specs

## 0.1.2
This release removes [application environment configuration](https://hexdocs.pm/elixir/1.17.2/design-anti-patterns.html#using-application-configuration-for-libraries) and moves to an opts-based configuration. See [README.md](README.md#configuration) for more info.

Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,23 @@ See `Agens.Job` for more information

---

## Examples
The `examples` directory includes a [single-file Phoenix LiveView application](examples/phoenix.exs) showcasing the basic usage of Agens.

To run the example, use the following command in your terminal:

```bash
elixir examples/phoenix.exs
```

This will start a local Phoenix server, accessible at [http://localhost:8080](http://localhost:8080).

## Configuration
Additional options can be passed to `Agens.Supervisor` in order to override the default values:

```elixir
opts = [
registry: Agens.MyCustomRegistry,
prompts: custom_prompt_prefixes
prefixes: custom_prompt_prefixes
]

children = [
Expand All @@ -138,10 +148,10 @@ children = [
Supervisor.start_link(children, strategy: :one_for_one)
```

The following default prompt prefixes can be copied, customized and used for the `prompts` option above:
The following default prompt prefixes can be copied, customized and used for the `prefixes` option above:

```elixir
%{
%Agens.Prefixes{
prompt:
{"Agent",
"You are a specialized agent with the following capabilities and expertise"},
Expand Down Expand Up @@ -169,12 +179,12 @@ The following default prompt prefixes can be copied, customized and used for the
}
```

See the [Prompting](#prompting) section below or `Agens.Message` for more information on prompt prefixes.
See the [Prompting](#prompting) section below or `Agens.Prefixes` for more information on prompt prefixes.

You can also see `Agens.Supervisor` for more information on configuration options.

## Prompting
Agens provides a variety of different ways to customize the final prompt sent to the language model (LM) or Serving. A natural language string can be assigned to the entity's specialized field (see below), while `nil` values will omit that field from the final prompt. This approach allows for precise control over the prompt’s content.
Agens provides a variety of different ways to customize the final prompt sent to the language model (LM) or Serving. A natural language string can be assigned to the entity's specialized field (see below), while `nil` values will omit that field from the final prompt. This approach allows for precise control over the prompt content.

All fields with values, in addition to user input, will be included in the final prompt. The goal should be to balance detailed prompts with efficient token usage by focusing on relevant fields and using concise language. This approach will yield the best results with minimal token usage, keeping costs low and performance high.

Expand Down
Loading
Loading