@@ -8,6 +8,7 @@ Codegate is a configurable Generative AI gateway designed to protect developers
8
8
- Secrets exfiltration prevention
9
9
- Secure coding recommendations
10
10
- Prevention of AI recommending deprecated/malicious libraries
11
+ - Modular system prompts configuration
11
12
12
13
## Development Setup
13
14
@@ -41,12 +42,16 @@ Codegate is a configurable Generative AI gateway designed to protect developers
41
42
codegate/
42
43
├── pyproject.toml # Project configuration and dependencies
43
44
├── poetry.lock # Lock file (committed to version control)
45
+ ├── prompts/ # System prompts configuration
46
+ │ └── default.yaml # Default system prompts
44
47
├── src/
45
48
│ └── codegate/ # Source code
46
49
│ ├── __init__.py
47
50
│ ├── cli.py # Command-line interface
48
51
│ ├── config.py # Configuration management
52
+ │ ├── exceptions.py # Shared exceptions
49
53
│ ├── logging.py # Logging setup
54
+ │ ├── prompts.py # Prompts management
50
55
│ ├── server.py # Main server implementation
51
56
│ └── providers/* # External service providers (anthropic, openai, etc.)
52
57
├── tests/ # Test files
@@ -114,147 +119,77 @@ Codegate uses a hierarchical configuration system with the following priority (h
114
119
1 . CLI arguments
115
120
2 . Environment variables
116
121
3 . Config file (YAML)
117
- 4 . Default values
122
+ 4 . Default values (including default prompts)
118
123
119
124
### Configuration Options
120
125
121
126
- Port: Server port (default: 8989)
122
127
- Host: Server host (default: "localhost")
123
128
- Log Level: Logging level (ERROR|WARNING|INFO|DEBUG)
124
129
- Log Format: Log format (JSON|TEXT)
130
+ - Prompts: System prompts configuration
125
131
126
132
See [ Configuration Documentation] ( configuration.md ) for detailed information.
127
133
128
- ## CLI Interface
129
-
130
- The main command-line interface is implemented in ` cli.py ` . Basic usage:
131
-
132
- ``` bash
133
- # Start server with default settings
134
- codegate serve
134
+ ## Working with Prompts
135
135
136
- # Start with custom configuration
137
- codegate serve --port 8989 --host localhost --log-level DEBUG
138
- ```
136
+ ### Default Prompts
139
137
140
- See [ CLI Documentation ] ( cli.md ) for detailed command information .
138
+ Default prompts are stored in ` prompts/default.yaml ` . These prompts are loaded automatically when no other prompts are specified .
141
139
142
- ## Dependencies Management
140
+ ### Creating Custom Prompts
143
141
144
- ### Adding Dependencies
142
+ 1 . Create a new YAML file following the format:
143
+ ``` yaml
144
+ prompt_name : " Prompt text content"
145
+ another_prompt : " More prompt text"
146
+ ` ` `
145
147
146
- For runtime dependencies :
147
- ``` bash
148
- poetry add package-name
149
- ```
148
+ 2. Use the prompts file :
149
+ ` ` ` bash
150
+ # Via CLI
151
+ codegate serve --prompts my-prompts.yaml
150
152
151
- For development dependencies:
152
- ``` bash
153
- poetry add --group dev package-name
154
- ```
153
+ # Or in config.yaml
154
+ prompts : " path/to/prompts.yaml"
155
155
156
- ### Updating Dependencies
156
+ # Or via environment
157
+ export CODEGATE_PROMPTS_FILE=path/to/prompts.yaml
158
+ ```
157
159
158
- To update all dependencies:
159
- ``` bash
160
- poetry update
161
- ```
160
+ ### Testing Prompts
162
161
163
- To update a specific package :
164
- ``` bash
165
- poetry update package-name
166
- ```
162
+ 1 . View loaded prompts :
163
+ ``` bash
164
+ # Show default prompts
165
+ codegate show-prompts
167
166
168
- ## Virtual Environment
167
+ # Show custom prompts
168
+ codegate show-prompts --prompts my-prompts.yaml
169
+ ```
169
170
170
- Poetry automatically manages virtual environments. To activate:
171
+ 2 . Write tests for prompt functionality:
172
+ ``` python
173
+ def test_custom_prompts ():
174
+ config = Config.load(prompts_path = " path/to/test/prompts.yaml" )
175
+ assert config.prompts.my_prompt == " Expected prompt text"
176
+ ```
171
177
172
- ``` bash
173
- poetry shell
174
- ```
178
+ ## CLI Interface
175
179
176
- To run a single command :
180
+ The main command-line interface is implemented in ` cli.py ` . Basic usage :
177
181
178
182
``` bash
179
- poetry run command
180
- ```
181
-
182
- ## Building and Publishing
183
+ # Start server with default settings
184
+ codegate serve
183
185
184
- To build distribution packages:
185
- ``` bash
186
- poetry build
187
- ```
186
+ # Start with custom configuration
187
+ codegate serve --port 8989 --host localhost --log-level DEBUG
188
188
189
- To publish to PyPI:
190
- ``` bash
191
- poetry publish
189
+ # Start with custom prompts
190
+ codegate serve --prompts my-prompts.yaml
192
191
```
193
192
194
- ## Debugging Tips
195
-
196
- 1 . Use DEBUG log level for detailed logging:
197
- ``` bash
198
- codegate serve --log-level DEBUG
199
- ```
200
-
201
- 2 . Use TEXT log format for human-readable logs during development:
202
- ``` bash
203
- codegate serve --log-format TEXT
204
- ```
193
+ See [ CLI Documentation] ( cli.md ) for detailed command information.
205
194
206
- 3 . Check the configuration resolution by examining logs at startup
207
-
208
- ## Contributing Guidelines
209
-
210
- 1 . Create a feature branch from ` main `
211
- 2 . Write tests for new functionality
212
- 3 . Ensure all tests pass with ` make test `
213
- 4 . Run ` make all ` before committing to ensure:
214
- - Code is properly formatted
215
- - All linting checks pass
216
- - Tests pass with good coverage
217
- - Security checks pass
218
- 5 . Update documentation as needed
219
- 6 . Submit a pull request
220
-
221
- ## Best Practices
222
-
223
- 1 . Always commit both ` pyproject.toml ` and ` poetry.lock ` files
224
- 2 . Use ` poetry add ` instead of manually editing ` pyproject.toml `
225
- 3 . Run ` make all ` before committing changes
226
- 4 . Use ` poetry run ` prefix for Python commands
227
- 5 . Keep dependencies minimal and well-organized
228
- 6 . Write descriptive commit messages
229
- 7 . Add tests for new functionality
230
- 8 . Update documentation when making significant changes
231
- 9 . Follow the existing code style and patterns
232
- 10 . Use type hints and docstrings for better code documentation
233
-
234
- ## Common Issues and Solutions
235
-
236
- 1 . ** Virtual Environment Issues**
237
- - Reset Poetry's virtual environment:
238
- ``` bash
239
- poetry env remove python
240
- poetry install
241
- ```
242
-
243
- 2. ** Dependency Conflicts**
244
- - Update poetry.lock:
245
- ` ` ` bash
246
- poetry update
247
- ` ` `
248
- - Check dependency tree:
249
- ` ` ` bash
250
- poetry show --tree
251
- ` ` `
252
-
253
- 3. ** Test Failures**
254
- - Run specific test:
255
- ` ` ` bash
256
- poetry run pytest tests/test_specific.py -v
257
- ` ` `
258
- - Debug with more output:
259
- ` ` ` bash
260
- poetry run pytest -vv --pdb
195
+ [ Rest of development.md content remains unchanged...]
0 commit comments