Skip to content

Commit d0f99dd

Browse files
authored
Merge pull request #1 from BudEcosystem/feat/prompt-executor
Feat/prompt executor
2 parents 69a5b12 + 4490acf commit d0f99dd

32 files changed

+8244
-4
lines changed

.env.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ PSQL_PORT=5432
2121
PSQL_DB_NAME=
2222
SECRETS_PSQL_USER=
2323
SECRETS_PSQL_PASSWORD=
24+
25+
BUD_GATEWAY_BASE_URL=http://0.0.0.0/v1
26+
BUD_DEFAULT_MODEL_NAME=qwen3-32b

CLAUDE.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,13 @@ Key environment variables (see `.env.sample`):
144144
- Always use Alembic for database changes
145145
- Configuration syncs periodically from Dapr configuration store
146146
- Pre-commit hooks enforce code quality standards
147-
- Ruff is configured for 119 character line length
147+
- Ruff is configured for 119 character line length
148+
149+
# Code Quality (*VERY IMPORTANT*)
150+
- Use the following design patterns on planning the code **VERY IMPORTANT**
151+
- https://refactoring.guru/design-patterns/catalog
152+
- Do a research on the codebase before writing and planning the code
153+
- If you are not sure about what to do, ask me for help
154+
- Make sure to follow single responsibility, Solid, DRY, etc. principles.
155+
- When creating a new file or directory, make sure to follow the project structure and file structure from docs/microservice_guidelines.md
156+
- New envs should be added to the .env.sample file

budprompt/commons/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@
2020

2121
# Import specific models instead of using wildcard import to avoid F403 error
2222
# Import models here
23-

budprompt/commons/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pathlib import Path
2020

2121
from budmicroframe.commons.config import BaseAppConfig, BaseSecretsConfig, register_settings
22-
from pydantic import DirectoryPath
22+
from pydantic import DirectoryPath, Field
2323

2424
from ..__about__ import __version__
2525

@@ -33,6 +33,10 @@ class AppConfig(BaseAppConfig):
3333
# Base Directory
3434
base_dir: DirectoryPath = Path(__file__).parent.parent.parent.resolve()
3535

36+
# BudServe Gateway Configuration
37+
bud_gateway_base_url: str = Field(..., alias="BUD_GATEWAY_BASE_URL")
38+
bud_default_model_name: str = Field(..., alias="BUD_DEFAULT_MODEL_NAME")
39+
3640

3741
class SecretsConfig(BaseSecretsConfig):
3842
name: str = __version__.split("@")[0]

budprompt/commons/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515
# -----------------------------------------------------------------------------
1616

1717
"""The constants used in the budprompt module."""
18-

budprompt/commons/exceptions.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
"""The exceptions used in the budprompt module."""
1818

19+
from typing import Any, Dict, Optional
20+
21+
from budmicroframe.commons.exceptions import ClientException as BudMicroframeClientException
22+
1923

2024
class BaseException(Exception):
2125
"""Base exception class for BudPrompt."""
@@ -36,3 +40,30 @@ def __str__(self) -> str:
3640
Formatted error message with exception class name
3741
"""
3842
return f"{self.__class__.__name__}: {self.message}"
43+
44+
45+
class SchemaGenerationException(BaseException):
46+
"""Exception raised when JSON schema to Pydantic model generation fails."""
47+
48+
pass
49+
50+
51+
class PromptExecutionException(BaseException):
52+
"""Exception raised when prompt execution fails."""
53+
54+
pass
55+
56+
57+
class TemplateRenderingException(BaseException):
58+
"""Exception raised when template rendering fails."""
59+
60+
pass
61+
62+
63+
class ClientException(BudMicroframeClientException):
64+
def __init__(self, message: str, status_code: int = 400, params: Optional[Dict[str, Any]] = None):
65+
"""Initialize the ClientException with a message."""
66+
self.message = message
67+
self.status_code = status_code
68+
self.params = params
69+
super().__init__(self.message, self.status_code)

budprompt/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from fastapi import FastAPI
2727

2828
from .commons.config import app_settings, secrets_settings
29+
from .prompt.routes import prompt_router
2930

3031

3132
logger = logging.getLogger(__name__)
@@ -59,3 +60,6 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
5960

6061

6162
app = configure_app(app_settings, secrets_settings, lifespan=lifespan)
63+
64+
# Include the prompt router
65+
app.include_router(prompt_router)

0 commit comments

Comments
 (0)