This repository contains Protocol Buffer definitions for the CrowdLlama API, specifically for interacting with Llama models.
The Protobuf definitions include:
Represents a request to the Llama API:
model: The model to use (e.g., "llama3.2")prompt: The input promptstream: Whether to stream the response
Represents a response from the Llama API:
model: The model usedcreated_at: Timestamp when response was createdresponse: The generated response textdone: Whether the response is completedone_reason: Reason for completion (e.g., "stop")context: Token context arraytotal_duration: Total duration in nanosecondsload_duration: Model loading duration in nanosecondsprompt_eval_count: Number of prompt tokens evaluatedprompt_eval_duration: Prompt evaluation duration in nanosecondseval_count: Number of tokens evaluatedeval_duration: Evaluation duration in nanoseconds
The LlamaService provides two RPC methods:
Generate: Generates a single responseGenerateStream: Generates a streaming response
To generate Go code from the Protobuf definitions:
# Install buf if you haven't already
go install github.com/bufbuild/buf/cmd/buf@latest
# Generate Go code
buf generateRequest:
{
"model": "llama3.2",
"prompt": "1+1",
"stream": false
}Response:
{
"model": "llama3.2",
"created_at": "2025-07-13T05:29:25.342493Z",
"response": "1 + 1 = 2",
"done": true,
"done_reason": "stop",
"context": [128006, 9125, 128007, 271, 38766, 1303, 33025, 2696, 25, 6790, 220, 2366, 18, 271, 128009, 128006, 882, 128007, 271, 16, 10, 16, 128009, 128006, 78191, 128007, 271, 16, 489, 220, 16, 284, 220, 17],
"total_duration": 299529791,
"load_duration": 54093833,
"prompt_eval_count": 28,
"prompt_eval_duration": 156589417,
"eval_count": 8,
"eval_duration": 88340208
}This project uses Buf for Protobuf development. The configuration files include:
buf.yaml: Main configurationbuf.gen.yaml: Code generation configurationgo.mod: Go module definition
The project includes GitHub Actions workflows that automatically:
- Format checking: Ensures Protobuf files are properly formatted
- Linting: Validates Protobuf syntax and style
- Breaking changes: Detects API breaking changes
- Code generation: Ensures generated Go code is up to date
Install pre-commit hooks to catch issues before committing:
# Install pre-commit
pip install pre-commit
# Install the git hook scripts
pre-commit installThis will automatically run Protobuf linting and formatting on every commit.
See LICENSE file for details.