Skip to content
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"

- name: Generate protobuf bindings
run: buf generate internal/.proto --template ./buf.gen.yaml
run: |
buf export buf.build/agynio/api --output internal/.proto
buf generate internal/.proto --template ./buf.gen.yaml

- name: Run tests
run: go test ./...
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ jobs:
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"

- name: Generate protobufs
run: buf generate internal/.proto --template ./buf.gen.yaml
run: |
buf export buf.build/agynio/api --output internal/.proto
buf generate internal/.proto --template ./buf.gen.yaml

- name: Run tests
run: go test ./...
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ dist/

# Generated code
internal/.gen/

# Exported protos
internal/.proto/

# Editor
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ RUN go mod download

COPY . .

RUN buf generate internal/.proto --template ./buf.gen.yaml
RUN buf export buf.build/agynio/api --output internal/.proto && \
buf generate internal/.proto --template ./buf.gen.yaml

RUN go build -o /out/token-counting ./cmd/token-counting

Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BUF_TEMPLATE := ./buf.gen.yaml
all: build

proto:
buf export buf.build/agynio/api --output $(PROTO_DIR)
buf generate $(PROTO_DIR) --template $(BUF_TEMPLATE)

build:
Expand Down
23 changes: 0 additions & 23 deletions internal/.proto/agynio/api/token_counting/v1/token_counting.proto

This file was deleted.

2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func validateCountTokensRequest(req *tokencountingv1.CountTokensRequest) error {
if req == nil {
return status.Error(codes.InvalidArgument, "request required")
}
if req.GetModel() == tokencountingv1.Model_MODEL_UNSPECIFIED {
if req.GetModel() == tokencountingv1.TokenCountingModel_TOKEN_COUNTING_MODEL_UNSPECIFIED {
return status.Error(codes.InvalidArgument, "model is required")
}
if len(req.GetMessages()) == 0 {
Expand Down
8 changes: 4 additions & 4 deletions internal/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestCountTokensSuccess(t *testing.T) {
expectedB := countTokens(t, tokenizerInstance, messageB)

resp, err := client.CountTokens(context.Background(), &tokencountingv1.CountTokensRequest{
Model: tokencountingv1.Model_MODEL_GPT_5,
Model: tokencountingv1.TokenCountingModel_TOKEN_COUNTING_MODEL_GPT_5,
Messages: [][]byte{messageA, messageB},
})
if err != nil {
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestCountTokensEmptyMessages(t *testing.T) {
defer cleanup()

_, err := client.CountTokens(context.Background(), &tokencountingv1.CountTokensRequest{
Model: tokencountingv1.Model_MODEL_GPT_5,
Model: tokencountingv1.TokenCountingModel_TOKEN_COUNTING_MODEL_GPT_5,
})
if err == nil {
t.Fatal("expected error, got nil")
Expand All @@ -83,7 +83,7 @@ func TestCountTokensInvalidArgumentMapping(t *testing.T) {
defer cleanup()

_, err := client.CountTokens(context.Background(), &tokencountingv1.CountTokensRequest{
Model: tokencountingv1.Model_MODEL_GPT_5,
Model: tokencountingv1.TokenCountingModel_TOKEN_COUNTING_MODEL_GPT_5,
Messages: [][]byte{[]byte("{}")},
})
if err == nil {
Expand All @@ -99,7 +99,7 @@ func TestCountTokensInternalErrorMapping(t *testing.T) {
defer cleanup()

_, err := client.CountTokens(context.Background(), &tokencountingv1.CountTokensRequest{
Model: tokencountingv1.Model_MODEL_GPT_5,
Model: tokencountingv1.TokenCountingModel_TOKEN_COUNTING_MODEL_GPT_5,
Messages: [][]byte{[]byte("{}")},
})
if err == nil {
Expand Down