An AI-powered tool that generates human-readable summaries of git changes using tool calling with a self-hosted LLM
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 94 lines 2.7 kB view raw
1package llm 2 3// Tool represents an OpenAI-compatible tool definition 4type Tool struct { 5 Type string `json:"type"` 6 Function FunctionDef `json:"function"` 7} 8 9// FunctionDef defines a function that can be called by the LLM 10type FunctionDef struct { 11 Name string `json:"name"` 12 Description string `json:"description"` 13 Parameters Parameters `json:"parameters"` 14} 15 16// Parameters defines the parameters schema for a function 17type Parameters struct { 18 Type string `json:"type"` 19 Properties map[string]Property `json:"properties"` 20 Required []string `json:"required"` 21} 22 23// Property defines a single parameter property 24type Property struct { 25 Type string `json:"type"` 26 Description string `json:"description"` 27 Items *Items `json:"items,omitempty"` 28} 29 30// Items defines the schema for array items 31type Items struct { 32 Type string `json:"type"` 33} 34 35// ChatRequest represents a request to the chat completions API 36type ChatRequest struct { 37 Model string `json:"model"` 38 Messages []Message `json:"messages"` 39 Tools []Tool `json:"tools,omitempty"` 40 ToolChoice string `json:"tool_choice,omitempty"` 41} 42 43// Message represents a chat message 44type Message struct { 45 Role string `json:"role"` 46 Content string `json:"content"` 47 ToolCalls []ToolCall `json:"tool_calls,omitempty"` 48 ToolCallID string `json:"tool_call_id,omitempty"` 49} 50 51// ToolCall represents a tool invocation by the LLM 52type ToolCall struct { 53 ID string `json:"id"` 54 Type string `json:"type"` 55 Function FunctionCall `json:"function"` 56} 57 58// FunctionCall represents the function being called 59type FunctionCall struct { 60 Name string `json:"name"` 61 Arguments string `json:"arguments"` 62} 63 64// ChatResponse represents a response from the chat completions API 65type ChatResponse struct { 66 Choices []Choice `json:"choices"` 67 Error *APIError `json:"error,omitempty"` 68} 69 70// Choice represents a response choice 71type Choice struct { 72 Message Message `json:"message"` 73 FinishReason string `json:"finish_reason"` 74} 75 76// APIError represents an API error response 77type APIError struct { 78 Message string `json:"message"` 79} 80 81// SummarizeRequest represents a request to the summarize endpoint 82type SummarizeRequest struct { 83 RepoURL string `json:"repo_url,omitempty"` 84 RepoPath string `json:"repo_path,omitempty"` 85 Base string `json:"base"` 86 Head string `json:"head"` 87 Style string `json:"style,omitempty"` // "detailed" (default), "short", "bluesky" 88} 89 90// SummarizeResponse represents a response from the summarize endpoint 91type SummarizeResponse struct { 92 Summary string `json:"summary"` 93 Error string `json:"error,omitempty"` 94}