diff --git a/docs/config.html b/docs/config.html index 570912909..13c66be88 100644 --- a/docs/config.html +++ b/docs/config.html @@ -756,7 +756,26 @@

ModelContextProtocolServer

PostgreSQLDatabaseConfiguration

PostgreSQL database configuration.

+

PostgreSQL database is used by Lightspeed Core Stack service for +storing information about conversation IDs. It can also be leveraged to +store conversation history and information about quota usage.

+

Useful resources:

+ +++++ @@ -768,47 +787,48 @@

ModelContextProtocolServer

- + - + - + - + - + - + - + - + - +
Field
host stringDatabase server host or socket directory
port integerDatabase server port
db stringDatabase name to connect to
user stringDatabase user name used to authenticate
password stringPassword used to authenticate
namespace Database namespace
ssl_mode stringSSL mode
gss_encmode stringThis option determines whether or with what priority a secure GSS +TCP/IP connection will be negotiated with the server.
ca_cert_path Path to CA certificate
diff --git a/docs/config.md b/docs/config.md index 3bdcb537d..ab43bdb14 100644 --- a/docs/config.md +++ b/docs/config.md @@ -273,18 +273,28 @@ model context protocol server configuration. PostgreSQL database configuration. +PostgreSQL database is used by Lightspeed Core Stack service for storing information about +conversation IDs. It can also be leveraged to store conversation history and information +about quota usage. + +Useful resources: + +- [Psycopg: connection classes](https://www.psycopg.org/psycopg3/docs/api/connections.html) +- [PostgreSQL connection strings](https://www.connectionstrings.com/postgresql/) +- [How to Use PostgreSQL in Python](https://www.freecodecamp.org/news/postgresql-in-python/) + | Field | Type | Description | |-------|------|-------------| -| host | string | | -| port | integer | | -| db | string | | -| user | string | | -| password | string | | -| namespace | | | -| ssl_mode | string | | -| gss_encmode | string | | -| ca_cert_path | | | +| host | string | Database server host or socket directory | +| port | integer | Database server port | +| db | string | Database name to connect to | +| user | string | Database user name used to authenticate | +| password | string | Password used to authenticate | +| namespace | | Database namespace | +| ssl_mode | string | SSL mode | +| gss_encmode | string | This option determines whether or with what priority a secure GSS TCP/IP connection will be negotiated with the server. | +| ca_cert_path | | Path to CA certificate | ## QuotaHandlersConfiguration diff --git a/docs/config.puml b/docs/config.puml index e2dabdbba..fede54101 100644 --- a/docs/config.puml +++ b/docs/config.puml @@ -127,14 +127,14 @@ class "ModelContextProtocolServer" as src.models.config.ModelContextProtocolServ } class "PostgreSQLDatabaseConfiguration" as src.models.config.PostgreSQLDatabaseConfiguration { ca_cert_path : Optional[FilePath] - db : str - gss_encmode : str - host : str + db : Optional[str] + gss_encmode : Optional[str] + host : Optional[str] namespace : Optional[str] - password : SecretStr - port : Annotated - ssl_mode : str - user : str + password : Optional[SecretStr] + port : Optional[PositiveInt] + ssl_mode : Optional[str] + user : Optional[str] check_postgres_configuration() -> Self } class "QuotaHandlersConfiguration" as src.models.config.QuotaHandlersConfiguration { diff --git a/docs/config.svg b/docs/config.svg index af55d095c..fff596147 100644 --- a/docs/config.svg +++ b/docs/config.svg @@ -1,5 +1,5 @@ - + @@ -15,13 +15,13 @@ - - - - Action - - name - + + + + Action + + name + @@ -68,483 +68,483 @@ - - - - CORSConfiguration - - allow_credentials : bool - allow_headers : list[str] - allow_methods : list[str] - allow_origins : list[str] - - check_cors_configuration() -> Self + + + + CORSConfiguration + + allow_credentials : Optional[bool] + allow_headers : Optional[list[str]] + allow_methods : Optional[list[str]] + allow_origins : Optional[list[str]] + + check_cors_configuration() -> Self - - - - Configuration - - authentication : Optional[AuthenticationConfiguration] - authorization : Optional[AuthorizationConfiguration] - byok_rag : Optional[list[ByokRag]] - conversation_cache : Optional[ConversationHistoryConfiguration] - customization : Optional[Customization] - database : Optional[DatabaseConfiguration] - inference : Optional[InferenceConfiguration] - llama_stack - mcp_servers : Optional[list[ModelContextProtocolServer]] - name : str - quota_handlers : Optional[QuotaHandlersConfiguration] - service - user_data_collection - - dump(filename: str) -> None + + + + Configuration + + authentication : Optional[AuthenticationConfiguration] + authorization : Optional[AuthorizationConfiguration] + byok_rag : Optional[list[ByokRag]] + conversation_cache : Optional[ConversationHistoryConfiguration] + customization : Optional[Customization] + database : Optional[DatabaseConfiguration] + inference : Optional[InferenceConfiguration] + llama_stack + mcp_servers : Optional[list[ModelContextProtocolServer]] + name : str + quota_handlers : Optional[QuotaHandlersConfiguration] + service + user_data_collection + + dump(filename: str) -> None - - - - ConfigurationBase - - model_config - + + + + ConfigurationBase + + model_config + - - - - ConversationHistoryConfiguration - - memory : Optional[InMemoryCacheConfig] - postgres : Optional[PostgreSQLDatabaseConfiguration] - sqlite : Optional[SQLiteDatabaseConfiguration] - type : Literal['noop', 'memory', 'sqlite', 'postgres'] | None - - check_cache_configuration() -> Self + + + + ConversationHistoryConfiguration + + memory : Optional[InMemoryCacheConfig] + postgres : Optional[PostgreSQLDatabaseConfiguration] + sqlite : Optional[SQLiteDatabaseConfiguration] + type : Literal['noop', 'memory', 'sqlite', 'postgres'] | None + + check_cache_configuration() -> Self - - - - CustomProfile - - path : str - prompts : Optional[dict[str, str]] - - get_prompts() -> dict[str, str] + + + + CustomProfile + + path : str + prompts : Optional[dict[str, str]] + + get_prompts() -> dict[str, str] - - - - Customization - - custom_profile : Optional[CustomProfile] - disable_query_system_prompt : bool - profile_path : Optional[str] - system_prompt : Optional[str] - system_prompt_path : Optional[FilePath] - - check_customization_model() -> Self + + + + Customization + + custom_profile : Optional[CustomProfile] + disable_query_system_prompt : bool + profile_path : Optional[str] + system_prompt : Optional[str] + system_prompt_path : Optional[FilePath] + + check_customization_model() -> Self - - - - DatabaseConfiguration - - config - db_type - postgres : Optional[PostgreSQLDatabaseConfiguration] - sqlite : Optional[SQLiteDatabaseConfiguration] - - check_database_configuration() -> Self + + + + DatabaseConfiguration + + config + db_type + postgres : Optional[PostgreSQLDatabaseConfiguration] + sqlite : Optional[SQLiteDatabaseConfiguration] + + check_database_configuration() -> Self - - - - InMemoryCacheConfig - - max_entries : Annotated - + + + + InMemoryCacheConfig + + max_entries : Annotated + - - - - InferenceConfiguration - - default_model : Optional[str] - default_provider : Optional[str] - - check_default_model_and_provider() -> Self + + + + InferenceConfiguration + + default_model : Optional[str] + default_provider : Optional[str] + + check_default_model_and_provider() -> Self - - - - JsonPathOperator - - name - + + + + JsonPathOperator + + name + - - - - JwkConfiguration - - jwt_configuration : Optional[JwtConfiguration] - url : AnyHttpUrl - + + + + JwkConfiguration + + jwt_configuration : Optional[JwtConfiguration] + url : AnyHttpUrl + - - - - JwtConfiguration - - role_rules : Optional[list[JwtRoleRule]] - user_id_claim : str - username_claim : str - + + + + JwtConfiguration + + role_rules : Optional[list[JwtRoleRule]] + user_id_claim : str + username_claim : str + - - - - JwtRoleRule - - compiled_regex - jsonpath : str - negate : bool - operator - roles : list[str] - value : Any - - check_jsonpath() -> Self - check_regex_pattern() -> Self - check_roles() -> Self + + + + JwtRoleRule + + compiled_regex + jsonpath : str + negate : bool + operator + roles : list[str] + value : Any + + check_jsonpath() -> Self + check_regex_pattern() -> Self + check_roles() -> Self - - - - LlamaStackConfiguration - - api_key : Optional[SecretStr] - library_client_config_path : Optional[str] - url : Optional[str] - use_as_library_client : Optional[bool] - - check_llama_stack_model() -> Self + + + + LlamaStackConfiguration + + api_key : Optional[SecretStr] + library_client_config_path : Optional[str] + url : Optional[str] + use_as_library_client : Optional[bool] + + check_llama_stack_model() -> Self - - - - ModelContextProtocolServer - - name : str - provider_id : str - url : str - + + + + ModelContextProtocolServer + + name : str + provider_id : str + url : str + - - - - PostgreSQLDatabaseConfiguration - - ca_cert_path : Optional[FilePath] - db : str - gss_encmode : str - host : str - namespace : Optional[str] - password : SecretStr - port : Annotated - ssl_mode : str - user : str - - check_postgres_configuration() -> Self + + + + PostgreSQLDatabaseConfiguration + + ca_cert_path : Optional[FilePath] + db : Optional[str] + gss_encmode : Optional[str] + host : Optional[str] + namespace : Optional[str] + password : Optional[SecretStr] + port : Optional[PositiveInt] + ssl_mode : Optional[str] + user : Optional[str] + + check_postgres_configuration() -> Self - - - - QuotaHandlersConfiguration - - enable_token_history : bool - limiters : Optional[list[QuotaLimiterConfiguration]] - postgres : Optional[PostgreSQLDatabaseConfiguration] - scheduler : Optional[QuotaSchedulerConfiguration] - sqlite : Optional[SQLiteDatabaseConfiguration] - + + + + QuotaHandlersConfiguration + + enable_token_history : bool + limiters : Optional[list[QuotaLimiterConfiguration]] + postgres : Optional[PostgreSQLDatabaseConfiguration] + scheduler : Optional[QuotaSchedulerConfiguration] + sqlite : Optional[SQLiteDatabaseConfiguration] + - - - - QuotaLimiterConfiguration - - initial_quota : Annotated - name : str - period : str - quota_increase : Annotated - type : Literal['user_limiter', 'cluster_limiter'] - + + + + QuotaLimiterConfiguration + + initial_quota : Annotated + name : str + period : str + quota_increase : Annotated + type : Literal['user_limiter', 'cluster_limiter'] + - - - - QuotaSchedulerConfiguration - - period : Annotated - + + + + QuotaSchedulerConfiguration + + period : Annotated + - - - - RHIdentityConfiguration - - required_entitlements : Optional[list[str]] - + + + + RHIdentityConfiguration + + required_entitlements : Optional[list[str]] + - - - - SQLiteDatabaseConfiguration - - db_path : Optional[str] - + + + + SQLiteDatabaseConfiguration + + db_path : Optional[str] + - - - - ServiceConfiguration - - access_log : bool - auth_enabled : bool - color_log : bool - cors : Optional[CORSConfiguration] - host : str - port : Annotated - tls_config : Optional[TLSConfiguration] - workers : Annotated - - check_service_configuration() -> Self + + + + ServiceConfiguration + + access_log : bool + auth_enabled : bool + color_log : bool + cors : Optional[CORSConfiguration] + host : str + port : Annotated + tls_config : Optional[TLSConfiguration] + workers : Annotated + + check_service_configuration() -> Self - - - - TLSConfiguration - - tls_certificate_path : Optional[FilePath] - tls_key_password : Optional[FilePath] - tls_key_path : Optional[FilePath] - - check_tls_configuration() -> Self + + + + TLSConfiguration + + tls_certificate_path : Optional[FilePath] + tls_key_password : Optional[FilePath] + tls_key_path : Optional[FilePath] + + check_tls_configuration() -> Self - - - - UserDataCollection - - feedback_enabled : bool - feedback_storage : Optional[str] - transcripts_enabled : bool - transcripts_storage : Optional[str] - - check_storage_location_is_set_when_needed() -> Self + + + + UserDataCollection + + feedback_enabled : bool + feedback_storage : Optional[str] + transcripts_enabled : bool + transcripts_storage : Optional[str] + + check_storage_location_is_set_when_needed() -> Self - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - custom_profile + + + custom_profile - - - operator + + + operator - - - llama_stack + + + llama_stack - - - sqlite + + + sqlite - - - service + + + service - - - user_data_collection + + + user_data_collection - + diff --git a/src/models/config.py b/src/models/config.py index ed1a17112..7bd32a45b 100644 --- a/src/models/config.py +++ b/src/models/config.py @@ -153,17 +153,73 @@ class InMemoryCacheConfig(ConfigurationBase): class PostgreSQLDatabaseConfiguration(ConfigurationBase): - """PostgreSQL database configuration.""" + """PostgreSQL database configuration. - host: str = "localhost" - port: PositiveInt = 5432 - db: str - user: str - password: SecretStr - namespace: Optional[str] = "lightspeed-stack" - ssl_mode: str = constants.POSTGRES_DEFAULT_SSL_MODE - gss_encmode: str = constants.POSTGRES_DEFAULT_GSS_ENCMODE - ca_cert_path: Optional[FilePath] = None + PostgreSQL database is used by Lightspeed Core Stack service for storing information about + conversation IDs. It can also be leveraged to store conversation history and information + about quota usage. + + Useful resources: + + - [Psycopg: connection classes](https://www.psycopg.org/psycopg3/docs/api/connections.html) + - [PostgreSQL connection strings](https://www.connectionstrings.com/postgresql/) + - [How to Use PostgreSQL in Python](https://www.freecodecamp.org/news/postgresql-in-python/) + """ + + host: str = Field( + "localhost", + title="Hostname", + description="Database server host or socket directory", + ) + + port: PositiveInt = Field( + 5432, + title="Port", + description="Database server port", + ) + + db: str = Field( + ..., + title="Database name", + description="Database name to connect to", + ) + + user: str = Field( + ..., + title="User name", + description="Database user name used to authenticate", + ) + + password: SecretStr = Field( + ..., + title="Password", + description="Password used to authenticate", + ) + + namespace: Optional[str] = Field( + "lightspeed-stack", + title="Name space", + description="Database namespace", + ) + + ssl_mode: str = Field( + constants.POSTGRES_DEFAULT_SSL_MODE, + title="SSL mode", + description="SSL mode", + ) + + gss_encmode: str = Field( + constants.POSTGRES_DEFAULT_GSS_ENCMODE, + title="GSS encmode", + description="This option determines whether or with what priority a secure GSS " + "TCP/IP connection will be negotiated with the server.", + ) + + ca_cert_path: Optional[FilePath] = Field( + None, + title="CA certificate path", + description="Path to CA certificate", + ) @model_validator(mode="after") def check_postgres_configuration(self) -> Self: diff --git a/tests/unit/models/config/test_postgresql_database_configuration.py b/tests/unit/models/config/test_postgresql_database_configuration.py index 52d4259ec..556790be8 100644 --- a/tests/unit/models/config/test_postgresql_database_configuration.py +++ b/tests/unit/models/config/test_postgresql_database_configuration.py @@ -17,6 +17,7 @@ def test_postgresql_database_configuration() -> None: """Test the PostgreSQLDatabaseConfiguration model.""" + # pylint: disable=no-member c = PostgreSQLDatabaseConfiguration(db="db", user="user", password="password") assert c is not None assert c.host == "localhost"