diff --git a/docs/config.png b/docs/config.png index 97d7fb01..b4c546f9 100644 Binary files a/docs/config.png and b/docs/config.png differ diff --git a/docs/config.puml b/docs/config.puml index fcad48b1..a5a7e1b7 100644 --- a/docs/config.puml +++ b/docs/config.puml @@ -38,7 +38,7 @@ class "Configuration" as src.models.config.Configuration { authentication : Optional[AuthenticationConfiguration] authorization : Optional[AuthorizationConfiguration] byok_rag : Optional[list[ByokRag]] - conversation_cache : Optional[ConversationCacheConfiguration] + conversation_cache : Optional[ConversationHistoryConfiguration] customization : Optional[Customization] database : Optional[DatabaseConfiguration] inference : Optional[InferenceConfiguration] @@ -53,7 +53,7 @@ class "Configuration" as src.models.config.Configuration { class "ConfigurationBase" as src.models.config.ConfigurationBase { model_config } -class "ConversationCacheConfiguration" as src.models.config.ConversationCacheConfiguration { +class "ConversationHistoryConfiguration" as src.models.config.ConversationHistoryConfiguration { memory : Optional[InMemoryCacheConfig] postgres : Optional[PostgreSQLDatabaseConfiguration] sqlite : Optional[SQLiteDatabaseConfiguration] @@ -185,7 +185,7 @@ src.models.config.AuthorizationConfiguration --|> src.models.config.Configuratio src.models.config.ByokRag --|> src.models.config.ConfigurationBase src.models.config.CORSConfiguration --|> src.models.config.ConfigurationBase src.models.config.Configuration --|> src.models.config.ConfigurationBase -src.models.config.ConversationCacheConfiguration --|> src.models.config.ConfigurationBase +src.models.config.ConversationHistoryConfiguration --|> src.models.config.ConfigurationBase src.models.config.Customization --|> src.models.config.ConfigurationBase src.models.config.DatabaseConfiguration --|> src.models.config.ConfigurationBase src.models.config.InMemoryCacheConfig --|> src.models.config.ConfigurationBase diff --git a/docs/config.svg b/docs/config.svg index ee97368d..de74a96e 100644 --- a/docs/config.svg +++ b/docs/config.svg @@ -1,5 +1,5 @@ - + @@ -15,13 +15,13 @@ - - - - Action - - name - + + + + Action + + name + @@ -80,43 +80,43 @@ - - - - Configuration - - authentication : Optional[AuthenticationConfiguration] - authorization : Optional[AuthorizationConfiguration] - byok_rag : Optional[list[ByokRag]] - conversation_cache : Optional[ConversationCacheConfiguration] - 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 - - - - - - - - ConversationCacheConfiguration + + + + ConfigurationBase + + model_config + + + + + + + + ConversationHistoryConfiguration memory : Optional[InMemoryCacheConfig] postgres : Optional[PostgreSQLDatabaseConfiguration] @@ -127,117 +127,117 @@ - - - - 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 @@ -255,82 +255,82 @@ - - - - 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 : str + gss_encmode : str + host : str + namespace : Optional[str] + password : SecretStr + port : Annotated + ssl_mode : str + user : 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 + - - - - SQLiteDatabaseConfiguration - - db_path : str - + + + + SQLiteDatabaseConfiguration + + db_path : str + @@ -352,182 +352,182 @@ - - - - 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/docs/openapi.json b/docs/openapi.json index c4f4ed00..695d2c00 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -1924,7 +1924,7 @@ "$ref": "#/components/schemas/InferenceConfiguration" }, "conversation_cache": { - "$ref": "#/components/schemas/ConversationCacheConfiguration" + "$ref": "#/components/schemas/ConversationHistoryConfiguration" }, "byok_rag": { "items": { @@ -1948,61 +1948,6 @@ "title": "Configuration", "description": "Global service configuration." }, - "ConversationCacheConfiguration": { - "properties": { - "type": { - "anyOf": [ - { - "type": "string", - "enum": [ - "noop", - "memory", - "sqlite", - "postgres" - ] - }, - { - "type": "null" - } - ], - "title": "Type" - }, - "memory": { - "anyOf": [ - { - "$ref": "#/components/schemas/InMemoryCacheConfig" - }, - { - "type": "null" - } - ] - }, - "sqlite": { - "anyOf": [ - { - "$ref": "#/components/schemas/SQLiteDatabaseConfiguration" - }, - { - "type": "null" - } - ] - }, - "postgres": { - "anyOf": [ - { - "$ref": "#/components/schemas/PostgreSQLDatabaseConfiguration" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "type": "object", - "title": "ConversationCacheConfiguration", - "description": "Conversation cache configuration." - }, "ConversationData": { "properties": { "conversation_id": { @@ -2175,6 +2120,61 @@ "title": "ConversationDetails", "description": "Model representing the details of a user conversation.\n\nAttributes:\n conversation_id: The conversation ID (UUID).\n created_at: When the conversation was created.\n last_message_at: When the last message was sent.\n message_count: Number of user messages in the conversation.\n last_used_model: The last model used for the conversation.\n last_used_provider: The provider of the last used model.\n topic_summary: The topic summary for the conversation.\n\nExample:\n ```python\n conversation = ConversationDetails(\n conversation_id=\"123e4567-e89b-12d3-a456-426614174000\"\n created_at=\"2024-01-01T00:00:00Z\",\n last_message_at=\"2024-01-01T00:05:00Z\",\n message_count=5,\n last_used_model=\"gemini/gemini-2.0-flash\",\n last_used_provider=\"gemini\",\n topic_summary=\"Openshift Microservices Deployment Strategies\",\n )\n ```" }, + "ConversationHistoryConfiguration": { + "properties": { + "type": { + "anyOf": [ + { + "type": "string", + "enum": [ + "noop", + "memory", + "sqlite", + "postgres" + ] + }, + { + "type": "null" + } + ], + "title": "Type" + }, + "memory": { + "anyOf": [ + { + "$ref": "#/components/schemas/InMemoryCacheConfig" + }, + { + "type": "null" + } + ] + }, + "sqlite": { + "anyOf": [ + { + "$ref": "#/components/schemas/SQLiteDatabaseConfiguration" + }, + { + "type": "null" + } + ] + }, + "postgres": { + "anyOf": [ + { + "$ref": "#/components/schemas/PostgreSQLDatabaseConfiguration" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "type": "object", + "title": "ConversationHistoryConfiguration", + "description": "Conversation cache configuration." + }, "ConversationResponse": { "properties": { "conversation_id": { diff --git a/src/cache/cache_factory.py b/src/cache/cache_factory.py index de50edb0..2c884a22 100644 --- a/src/cache/cache_factory.py +++ b/src/cache/cache_factory.py @@ -1,7 +1,7 @@ """Cache factory class.""" import constants -from models.config import ConversationCacheConfiguration +from models.config import ConversationHistoryConfiguration from cache.cache import Cache from cache.noop_cache import NoopCache from cache.in_memory_cache import InMemoryCache @@ -17,7 +17,7 @@ class CacheFactory: """Cache factory class.""" @staticmethod - def conversation_cache(config: ConversationCacheConfiguration) -> Cache: + def conversation_cache(config: ConversationHistoryConfiguration) -> Cache: """Create an instance of Cache based on loaded configuration. Returns: diff --git a/src/configuration.py b/src/configuration.py index d2b2389d..9d698317 100644 --- a/src/configuration.py +++ b/src/configuration.py @@ -19,7 +19,7 @@ AuthenticationConfiguration, InferenceConfiguration, DatabaseConfiguration, - ConversationCacheConfiguration, + ConversationHistoryConfiguration, QuotaHandlersConfiguration, ) @@ -138,7 +138,7 @@ def inference(self) -> InferenceConfiguration: return self._configuration.inference @property - def conversation_cache_configuration(self) -> ConversationCacheConfiguration: + def conversation_cache_configuration(self) -> ConversationHistoryConfiguration: """Return conversation cache configuration.""" if self._configuration is None: raise LogicError("logic error: configuration is not loaded") diff --git a/src/models/config.py b/src/models/config.py index c2542dad..0d54d207 100644 --- a/src/models/config.py +++ b/src/models/config.py @@ -511,7 +511,7 @@ def check_default_model_and_provider(self) -> Self: return self -class ConversationCacheConfiguration(ConfigurationBase): +class ConversationHistoryConfiguration(ConfigurationBase): """Conversation cache configuration.""" type: Literal["noop", "memory", "sqlite", "postgres"] | None = None @@ -608,8 +608,8 @@ class Configuration(ConfigurationBase): authorization: Optional[AuthorizationConfiguration] = None customization: Optional[Customization] = None inference: InferenceConfiguration = Field(default_factory=InferenceConfiguration) - conversation_cache: ConversationCacheConfiguration = Field( - default_factory=ConversationCacheConfiguration + conversation_cache: ConversationHistoryConfiguration = Field( + default_factory=ConversationHistoryConfiguration ) byok_rag: list[ByokRag] = Field(default_factory=list) quota_handlers: QuotaHandlersConfiguration = Field( diff --git a/tests/unit/cache/test_cache_factory.py b/tests/unit/cache/test_cache_factory.py index 7f5a11af..23ce2d7e 100644 --- a/tests/unit/cache/test_cache_factory.py +++ b/tests/unit/cache/test_cache_factory.py @@ -14,7 +14,7 @@ ) from models.config import ( - ConversationCacheConfiguration, + ConversationHistoryConfiguration, InMemoryCacheConfig, SQLiteDatabaseConfiguration, PostgreSQLDatabaseConfiguration, @@ -28,23 +28,23 @@ @pytest.fixture(scope="module", name="noop_cache_config_fixture") -def noop_cache_config() -> ConversationCacheConfiguration: - """Fixture containing initialized instance of ConversationCacheConfiguration.""" - return ConversationCacheConfiguration(type=CACHE_TYPE_NOOP) +def noop_cache_config() -> ConversationHistoryConfiguration: + """Fixture containing initialized instance of ConversationHistoryConfiguration.""" + return ConversationHistoryConfiguration(type=CACHE_TYPE_NOOP) @pytest.fixture(scope="module", name="memory_cache_config_fixture") -def memory_cache_config() -> ConversationCacheConfiguration: +def memory_cache_config() -> ConversationHistoryConfiguration: """Fixture containing initialized instance of InMemory cache.""" - return ConversationCacheConfiguration( + return ConversationHistoryConfiguration( type=CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=10) ) @pytest.fixture(scope="module", name="postgres_cache_config_fixture") -def postgres_cache_config() -> ConversationCacheConfiguration: +def postgres_cache_config() -> ConversationHistoryConfiguration: """Fixture containing initialized instance of PostgreSQL cache.""" - return ConversationCacheConfiguration( + return ConversationHistoryConfiguration( type=CACHE_TYPE_POSTGRES, postgres=PostgreSQLDatabaseConfiguration( db="database", user="user", password=SecretStr("password") @@ -53,25 +53,25 @@ def postgres_cache_config() -> ConversationCacheConfiguration: @pytest.fixture(name="sqlite_cache_config_fixture") -def sqlite_cache_config(tmpdir: Path) -> ConversationCacheConfiguration: +def sqlite_cache_config(tmpdir: Path) -> ConversationHistoryConfiguration: """Fixture containing initialized instance of SQLite cache.""" db_path = str(tmpdir / "test.sqlite") - return ConversationCacheConfiguration( + return ConversationHistoryConfiguration( type=CACHE_TYPE_SQLITE, sqlite=SQLiteDatabaseConfiguration(db_path=db_path) ) @pytest.fixture(scope="module", name="invalid_cache_type_config_fixture") -def invalid_cache_type_config() -> ConversationCacheConfiguration: - """Fixture containing instance of ConversationCacheConfiguration with improper settings.""" - c = ConversationCacheConfiguration() +def invalid_cache_type_config() -> ConversationHistoryConfiguration: + """Fixture containing instance of ConversationHistoryConfiguration with improper settings.""" + c = ConversationHistoryConfiguration() # the conversation cache type name is incorrect in purpose c.type = "foo bar baz" # pyright: ignore return c def test_conversation_cache_noop( - noop_cache_config_fixture: ConversationCacheConfiguration, + noop_cache_config_fixture: ConversationHistoryConfiguration, ) -> None: """Check if NoopCache is returned by factory with proper configuration.""" cache = CacheFactory.conversation_cache(noop_cache_config_fixture) @@ -81,7 +81,7 @@ def test_conversation_cache_noop( def test_conversation_cache_in_memory( - memory_cache_config_fixture: ConversationCacheConfiguration, + memory_cache_config_fixture: ConversationHistoryConfiguration, ) -> None: """Check if InMemoryCache is returned by factory with proper configuration.""" cache = CacheFactory.conversation_cache(memory_cache_config_fixture) @@ -92,7 +92,7 @@ def test_conversation_cache_in_memory( def test_conversation_cache_in_memory_improper_config() -> None: """Check if memory cache configuration is checked in cache factory.""" - cc = ConversationCacheConfiguration( + cc = ConversationHistoryConfiguration( type=CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=10) ) # simulate improper configuration (can not be done directly as model checks this) @@ -102,7 +102,7 @@ def test_conversation_cache_in_memory_improper_config() -> None: def test_conversation_cache_sqlite( - sqlite_cache_config_fixture: ConversationCacheConfiguration, + sqlite_cache_config_fixture: ConversationHistoryConfiguration, ) -> None: """Check if SQLiteCache is returned by factory with proper configuration.""" cache = CacheFactory.conversation_cache(sqlite_cache_config_fixture) @@ -114,7 +114,7 @@ def test_conversation_cache_sqlite( def test_conversation_cache_sqlite_improper_config(tmpdir: Path) -> None: """Check if memory cache configuration is checked in cache factory.""" db_path = str(tmpdir / "test.sqlite") - cc = ConversationCacheConfiguration( + cc = ConversationHistoryConfiguration( type=CACHE_TYPE_SQLITE, sqlite=SQLiteDatabaseConfiguration(db_path=db_path) ) # simulate improper configuration (can not be done directly as model checks this) @@ -124,7 +124,8 @@ def test_conversation_cache_sqlite_improper_config(tmpdir: Path) -> None: def test_conversation_cache_postgres( - postgres_cache_config_fixture: ConversationCacheConfiguration, mocker: MockerFixture + postgres_cache_config_fixture: ConversationHistoryConfiguration, + mocker: MockerFixture, ) -> None: """Check if PostgreSQL is returned by factory with proper configuration.""" mocker.patch("psycopg2.connect") @@ -136,7 +137,7 @@ def test_conversation_cache_postgres( def test_conversation_cache_postgres_improper_config() -> None: """Check if PostgreSQL cache configuration is checked in cache factory.""" - cc = ConversationCacheConfiguration( + cc = ConversationHistoryConfiguration( type=CACHE_TYPE_POSTGRES, postgres=PostgreSQLDatabaseConfiguration( db="db", user="u", password=SecretStr("p") @@ -152,7 +153,7 @@ def test_conversation_cache_postgres_improper_config() -> None: def test_conversation_cache_no_type() -> None: """Check if wrong cache configuration is detected properly.""" - cc = ConversationCacheConfiguration(type=CACHE_TYPE_NOOP) + cc = ConversationHistoryConfiguration(type=CACHE_TYPE_NOOP) # simulate improper configuration (can not be done directly as model checks this) cc.type = None with pytest.raises(ValueError, match="Cache type must be set"): @@ -160,7 +161,7 @@ def test_conversation_cache_no_type() -> None: def test_conversation_cache_wrong_cache( - invalid_cache_type_config_fixture: ConversationCacheConfiguration, + invalid_cache_type_config_fixture: ConversationHistoryConfiguration, ) -> None: """Check if wrong cache configuration is detected properly.""" with pytest.raises(ValueError, match="Invalid cache type"): diff --git a/tests/unit/models/config/test_conversation_cache.py b/tests/unit/models/config/test_conversation_history.py similarity index 85% rename from tests/unit/models/config/test_conversation_cache.py rename to tests/unit/models/config/test_conversation_history.py index 38c417e3..95958e6f 100644 --- a/tests/unit/models/config/test_conversation_cache.py +++ b/tests/unit/models/config/test_conversation_history.py @@ -1,4 +1,4 @@ -"""Unit tests for ConversationCacheConfiguration model.""" +"""Unit tests for ConversationHistoryConfiguration model.""" from pathlib import Path @@ -9,7 +9,7 @@ import constants from models.config import ( - ConversationCacheConfiguration, + ConversationHistoryConfiguration, InMemoryCacheConfig, SQLiteDatabaseConfiguration, PostgreSQLDatabaseConfiguration, @@ -18,7 +18,7 @@ def test_conversation_cache_no_type_specified() -> None: """Check the test for type as optional attribute.""" - c = ConversationCacheConfiguration() + c = ConversationHistoryConfiguration() assert c.type is None @@ -28,7 +28,7 @@ def test_conversation_cache_unknown_type() -> None: ValidationError, match="Input should be 'noop', 'memory', 'sqlite' or 'postgres'", ): - _ = ConversationCacheConfiguration(type="foo") + _ = ConversationHistoryConfiguration(type="foo") def test_conversation_cache_correct_type_but_not_configured(subtests: SubTests) -> None: @@ -37,19 +37,19 @@ def test_conversation_cache_correct_type_but_not_configured(subtests: SubTests) with pytest.raises( ValidationError, match="Memory cache is selected, but not configured" ): - _ = ConversationCacheConfiguration(type=constants.CACHE_TYPE_MEMORY) + _ = ConversationHistoryConfiguration(type=constants.CACHE_TYPE_MEMORY) with subtests.test(msg="SQLite cache"): with pytest.raises( ValidationError, match="SQLite cache is selected, but not configured" ): - _ = ConversationCacheConfiguration(type=constants.CACHE_TYPE_SQLITE) + _ = ConversationHistoryConfiguration(type=constants.CACHE_TYPE_SQLITE) with subtests.test(msg="SQLite cache"): with pytest.raises( ValidationError, match="PostgreSQL cache is selected, but not configured" ): - _ = ConversationCacheConfiguration(type=constants.CACHE_TYPE_POSTGRES) + _ = ConversationHistoryConfiguration(type=constants.CACHE_TYPE_POSTGRES) def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None: @@ -58,13 +58,13 @@ def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None: with subtests.test(msg="Memory cache"): with pytest.raises(ValidationError, match=m): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( memory=InMemoryCacheConfig(max_entries=100) ) with subtests.test(msg="SQLite cache"): with pytest.raises(ValidationError, match=m): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( sqlite=SQLiteDatabaseConfiguration(db_path="path") ) @@ -77,7 +77,7 @@ def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None: ca_cert_path=Path("tests/configuration/server.crt"), ) with pytest.raises(ValidationError, match=m): - _ = ConversationCacheConfiguration(postgres=d) + _ = ConversationHistoryConfiguration(postgres=d) def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: @@ -94,7 +94,7 @@ def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: with pytest.raises( ValidationError, match="Only memory cache config must be provided" ): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=100), sqlite=SQLiteDatabaseConfiguration(db_path="path"), @@ -105,7 +105,7 @@ def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: with pytest.raises( ValidationError, match="Only SQLite cache config must be provided" ): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_SQLITE, memory=InMemoryCacheConfig(max_entries=100), sqlite=SQLiteDatabaseConfiguration(db_path="path"), @@ -116,7 +116,7 @@ def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: with pytest.raises( ValidationError, match="Only PostgreSQL cache config must be provided" ): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_POSTGRES, memory=InMemoryCacheConfig(max_entries=100), sqlite=SQLiteDatabaseConfiguration(db_path="path"), @@ -126,7 +126,7 @@ def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: def test_conversation_type_memory() -> None: """Test the memory conversation cache configuration.""" - c = ConversationCacheConfiguration( + c = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=100) ) assert c.type == constants.CACHE_TYPE_MEMORY @@ -139,13 +139,13 @@ def test_conversation_type_memory() -> None: def test_conversation_type_memory_wrong_config() -> None: """Test the memory conversation cache configuration.""" with pytest.raises(ValidationError, match="Field required"): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(), ) with pytest.raises(ValidationError, match="Input should be greater than 0"): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=-100), ) @@ -153,7 +153,7 @@ def test_conversation_type_memory_wrong_config() -> None: def test_conversation_type_sqlite() -> None: """Test the SQLite conversation cache configuration.""" - c = ConversationCacheConfiguration( + c = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_SQLITE, sqlite=SQLiteDatabaseConfiguration(db_path="path"), ) @@ -167,7 +167,7 @@ def test_conversation_type_sqlite() -> None: def test_conversation_type_sqlite_wrong_config() -> None: """Test the SQLite conversation cache configuration.""" with pytest.raises(ValidationError, match="Field required"): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_SQLITE, memory=SQLiteDatabaseConfiguration(), ) @@ -183,7 +183,7 @@ def test_conversation_type_postgres() -> None: ca_cert_path=Path("tests/configuration/server.crt"), ) - c = ConversationCacheConfiguration( + c = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_POSTGRES, postgres=d, ) @@ -200,7 +200,7 @@ def test_conversation_type_postgres() -> None: def test_conversation_type_postgres_wrong_config() -> None: """Test the SQLite conversation cache configuration.""" with pytest.raises(ValidationError, match="Field required"): - _ = ConversationCacheConfiguration( + _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_POSTGRES, postgres=PostgreSQLDatabaseConfiguration(), )