grpcecho

command
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 13 Imported by: 0

README

grpcecho

Sample gRPC extension plugin for AFI: process-isolated typed ChatIR / ChatIRStream provider and a demo BeforeCall that sets X-Afi-Grpc-Echo: 1 on upstream request headers. Also advertises BeforeChat (pass-through typed chat IR).

Build

make build   # produces bin/grpcecho
# or
go build -o bin/grpcecho ./extensions/grpcecho

Run with the gateway

In configs/dev.yaml (or your AFI_CONFIG):

gateway:
  grpc_extensions:
    - id: grpcecho
      command: ["./bin/grpcecho"]

Restart the gateway. It spawns the plugin, sets AFI_PLUGIN_SOCK, performs the capability handshake, and registers provider type grpcecho.

Create a control-plane provider with type: grpcecho and a route (e.g. model grpcecho-demo), then:

curl -s http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer sk-project-local-dev-token-12345" \
  -H 'Content-Type: application/json' \
  -d '{"model":"grpcecho-demo","messages":[{"role":"user","content":"ping"}]}'

Expect assistant content containing grpcecho:.

Dial an already-running plugin

./bin/grpcecho -addr /tmp/afi-grpcecho.sock
gateway:
  grpc_extensions:
    - id: grpcecho
      address: unix:///tmp/afi-grpcecho.sock

Documentation

Overview

Command grpcecho is a sample gRPC extension plugin (ChatIR provider + BeforeCall/BeforeChat).

Listen address comes from AFI_PLUGIN_SOCK (set by the gateway when spawning) or -addr. Example gateway config:

gateway:
  grpc_extensions:
    - id: grpcecho
      command: ["./bin/grpcecho"]

Create a control-plane provider with type "grpcecho" and a route to use it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL