from_schema(
cls,
schema: IndexSchema,
**kwargs: Any = {}
) -> RedisConfig| Name | Type | Description |
|---|---|---|
schema* | IndexSchema | An IndexSchema object defining the structure of the Redis index. |
**kwargs | Any | Default: {}Additional keyword arguments to override or supplement the schema-derived settings. Common kwargs include:
|
Create a RedisConfig object from an IndexSchema.
This class method creates a RedisConfig instance using the provided IndexSchema, which defines the structure of the Redis index.
Example:
.. code-block:: python
from redisvl.schema import IndexSchema from langchain_redis import RedisConfig
schema = IndexSchema.from_dict({ "index": {"name": "my_index", "storage_type": "hash"}, "fields": [ {"name": "text", "type": "text"}, { "name": "embedding", "type": "vector", "attrs": {"dims": 1536, "distance_metric": "cosine"} } ] })
config = RedisConfig.from_schema( schema, redis_url="redis://localhost:6379" )
print(config.index_name) # Output: my_index print(config.storage_type) # Output: hash
Note: