readme: document generate, route, complete endpoints (net/dns pattern)
This commit is contained in:
parent
120a971a0b
commit
b410133759
69
README.md
69
README.md
|
|
@ -200,6 +200,75 @@ mv $OLLIE/s/<session-id> $OLLIE/s/my-friendly-name # rename
|
|||
|
||||
Rename is rejected if the agent is running or the target name already exists. All open file handles into the session are updated automatically.
|
||||
|
||||
## Stateless endpoints: generate, route, complete
|
||||
|
||||
Three root-level files provide request/response access without session state. They follow the [Plan 9 /net/dns pattern](https://9fans.github.io/plan9port/man/man3/ndb.html): open the file, write a request, then read the response from the same file descriptor. The result is per-fid (per open file descriptor) and consumed on first read.
|
||||
|
||||
Because the write and read must happen on the same fd, a simple `echo > file && cat file` won't work — that opens two separate fds. Use `exec` with a persistent fd, or `9p rdwr`.
|
||||
|
||||
### generate
|
||||
|
||||
One-shot LLM generation with no session context.
|
||||
|
||||
**Request** (JSON): `{"prompt": "...", "system": "...", "backend": "...", "model": "..."}`
|
||||
|
||||
All fields except `prompt` are optional. If the write is not valid JSON, the entire string is used as the prompt.
|
||||
|
||||
**Response**: the model's text output.
|
||||
|
||||
```sh
|
||||
# Using exec to keep the fd open:
|
||||
exec 3<> $OLLIE/generate
|
||||
echo '{"prompt": "what is 2+2?", "backend": "ollama", "model": "qwen3:8b"}' >&3
|
||||
cat <&3
|
||||
exec 3>&-
|
||||
|
||||
# Plain text (uses default backend/model from env):
|
||||
exec 3<> $OLLIE/generate
|
||||
echo 'what is 2+2?' >&3
|
||||
cat <&3
|
||||
exec 3>&-
|
||||
```
|
||||
|
||||
### route
|
||||
|
||||
Model selection: given a task description, picks the best backend+model from all available models.
|
||||
|
||||
**Request** (JSON): `{"task": "...", "backend": "..."}` — `backend` is optional (restricts candidates).
|
||||
|
||||
Plain text is treated as the task.
|
||||
|
||||
**Response**: `backend=<name> model=<name>`
|
||||
|
||||
The classifier uses `OLLIE_ROUTE_BACKEND` (default: `ollama`) and `OLLIE_ROUTE_MODEL` (default: `qwen3:8b`).
|
||||
|
||||
```sh
|
||||
exec 3<> $OLLIE/route
|
||||
echo 'write a bash script to parse JSON' >&3
|
||||
cat <&3
|
||||
exec 3>&-
|
||||
# → backend=openrouter model=anthropic/claude-sonnet-4-20250514
|
||||
```
|
||||
|
||||
### complete
|
||||
|
||||
Code completion: given file context (prefix/suffix around the cursor), returns a suggested insertion.
|
||||
|
||||
**Request** (JSON): `{"cwd": "...", "file": "...", "prefix": "...", "suffix": "...", "context": "..."}`
|
||||
|
||||
All fields except `prefix` are optional. Plain text is treated as the prefix.
|
||||
|
||||
Uses `OLLIE_COMPLETE_BACKEND` and `OLLIE_COMPLETE_MODEL`.
|
||||
|
||||
**Response**: the completion text.
|
||||
|
||||
```sh
|
||||
exec 3<> $OLLIE/complete
|
||||
echo '{"prefix": "func main() {\n\t", "suffix": "\n}", "file": "main.go"}' >&3
|
||||
cat <&3
|
||||
exec 3>&-
|
||||
```
|
||||
|
||||
## Example shell session
|
||||
|
||||
```sh
|
||||
|
|
|
|||
Reference in New Issue