mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-01 18:19:08 +00:00
30 lines
963 B
Python
30 lines
963 B
Python
"""Define the configurable parameters for the agent."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, fields
|
|
from typing import Optional, List, Any
|
|
|
|
from langchain_core.runnables import RunnableConfig
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
class Configuration:
|
|
"""The configuration for the agent."""
|
|
|
|
# Input parameters provided at invocation
|
|
sub_section_title: str
|
|
sub_section_questions: List[str]
|
|
relevant_documents: List[Any] # Documents provided directly to the agent
|
|
user_id: str
|
|
search_space_id: int
|
|
|
|
|
|
@classmethod
|
|
def from_runnable_config(
|
|
cls, config: Optional[RunnableConfig] = None
|
|
) -> Configuration:
|
|
"""Create a Configuration instance from a RunnableConfig object."""
|
|
configurable = (config.get("configurable") or {}) if config else {}
|
|
_fields = {f.name for f in fields(cls) if f.init}
|
|
return cls(**{k: v for k, v in configurable.items() if k in _fields})
|