API Reference
AI Service Module
blueprint.ai_service
AI Service module for interacting with different LLM providers.
AIService
Service for interacting with different AI providers.
Source code in src/blueprint/ai_service.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
__init__(service_type, model=None, debug=False)
Initialize AI service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_type
|
str
|
Type of AI service ('ollama' or 'jan') |
required |
model
|
Optional[str]
|
Model name to use |
None
|
debug
|
bool
|
Whether to enable debug logging |
False
|
Source code in src/blueprint/ai_service.py
query(prompt)
Query the AI service with the given prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
str
|
The prompt to send to the AI service |
required |
Returns:
Type | Description |
---|---|
str
|
The response from the AI service |
Raises:
Type | Description |
---|---|
Exception
|
If there's an error communicating with the AI service |
Source code in src/blueprint/ai_service.py
Commit Generator Module
blueprint.commit_generator
Git commit message generator using AI models.
create_commit(message, debug=False)
Create a git commit with the selected message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
Commit message to use |
required |
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
bool
|
True if commit was successful, False otherwise |
Source code in src/blueprint/commit_generator.py
filter_diff(raw_diff, include_filenames=True, debug=False)
Filter git diff to remove metadata and keep only meaningful changes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_diff
|
str
|
Raw git diff output |
required |
include_filenames
|
bool
|
Whether to keep filenames in the output |
True
|
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
str
|
Filtered diff with only relevant content |
Source code in src/blueprint/commit_generator.py
generate_commit_messages(diff, max_chars=200, service_type='ollama', ollama_model='llama3.1', jan_model='llama3.2-3b-instruct', debug=False)
Generate commit messages based on git diff.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
diff
|
str
|
Git diff to generate commit messages for |
required |
max_chars
|
int
|
Suggested maximum characters for commit messages |
200
|
service_type
|
str
|
'ollama' or 'jan' |
'ollama'
|
ollama_model
|
str
|
Model name for Ollama |
'llama3.1'
|
jan_model
|
str
|
Model name for Jan AI |
'llama3.2-3b-instruct'
|
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
List[str]
|
List of generated commit messages |
Source code in src/blueprint/commit_generator.py
get_git_diff(max_chars=5000, debug=False)
Get the git diff of staged changes, or unstaged if no staged changes. Filters out deleted files from the diff.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_chars
|
int
|
Maximum number of characters to return |
5000
|
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
str
|
Git diff as string |
Raises:
Type | Description |
---|---|
SystemExit
|
If not a git repository or git not installed |
Source code in src/blueprint/commit_generator.py
parse_commit_messages(response, debug=False)
Parse the LLM response into a list of commit messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response
|
str
|
Text response from AI service |
required |
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
List[str]
|
List of extracted commit messages |
Source code in src/blueprint/commit_generator.py
query_ai_service(prompt, service_type, ollama_model, jan_model, debug=False)
Query AI service with the given prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
str
|
Prompt text to send to AI service |
required |
service_type
|
str
|
Type of AI service ('ollama' or 'jan') |
required |
ollama_model
|
str
|
Model name for Ollama |
required |
jan_model
|
str
|
Model name for Jan AI |
required |
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
str
|
Response from AI service |
Raises:
Type | Description |
---|---|
SystemExit
|
If there's an error querying the AI service |
Source code in src/blueprint/commit_generator.py
trim_diff(diff, max_chars, debug=False)
Intelligently trim a git diff to stay under max_chars by preserving complete files and hunks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
diff
|
str
|
The git diff to trim |
required |
max_chars
|
int
|
Maximum character limit |
required |
debug
|
bool
|
Whether to enable debug logging |
False
|
Returns:
Type | Description |
---|---|
str
|
Trimmed diff with complete files and hunks |
Source code in src/blueprint/commit_generator.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
CLI Module
blueprint.cli
Command-line interface for LLM-powered commit message generator.
main()
Main entry point for the CLI application.
Source code in src/blueprint/cli.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
select_message_with_fzf(messages, use_vim=False, use_num=False)
Use fzf to select a commit message, with option to regenerate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
List[str]
|
List of commit messages to select from |
required |
use_vim
|
bool
|
Whether to use vim-style navigation |
False
|
use_num
|
bool
|
Whether to display numbers for selection |
False
|
Returns:
Type | Description |
---|---|
Optional[str]
|
Selected message, "regenerate" to regenerate messages, or None if cancelled |
Source code in src/blueprint/cli.py
setup_logging(debug_mode)
Set up logging based on debug mode.