Spaces:
Sleeping
Sleeping
Download app/agent/configuration.py from arthikrangan/text-to-sql-agent-api: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/arthikrangan/text-to-sql-agent-api/resolve/main/app/agent/configuration.py
- Command line
-
hf download hf://spaces/arthikrangan/text-to-sql-agent-api/app/agent/configuration.py
-
curl -L -o configuration.py https://huggingface.co/spaces/arthikrangan/text-to-sql-agent-api/resolve/main/app/agent/configuration.py
1.6 kB
| """Define the configurable parameters for the agent.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass, field, fields | |
| from typing import Annotated | |
| from app.agent import prompts | |
| from langchain_core.runnables import ensure_config | |
| from langgraph.config import get_config | |
| class Configuration: | |
| """The configuration for the agent.""" | |
| system_prompt: str = field( | |
| default=prompts.SYSTEM_PROMPT, | |
| metadata={ | |
| "description": "The system prompt to use for the agent's interactions. " | |
| "This prompt sets the context and behavior for the agent." | |
| }, | |
| ) | |
| model: Annotated[str, {"__template_metadata__": {"kind": "llm"}}] = field( | |
| default="openai/gpt-4o", | |
| metadata={ | |
| "description": "The name of the language model to use for the agent's main interactions. " | |
| "Should be in the form: provider/model-name." | |
| }, | |
| ) | |
| max_search_results: int = field( | |
| default=10, | |
| metadata={"description": "The maximum number of search results to return for each search query."}, | |
| ) | |
| def from_context(cls) -> Configuration: | |
| """Create a Configuration instance from a RunnableConfig object.""" | |
| try: | |
| config = get_config() | |
| except RuntimeError: | |
| config = None | |
| config = ensure_config(config) | |
| configurable = config.get("configurable") or {} | |
| _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}) | |