Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions python/valuecell/agents/sec_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ async def _process_financial_data_query(
Please ensure the analysis is objective and professional, based on actual data, avoiding excessive speculation.
"""

response_stream: Iterator[RunResponseEvent] = self.analysis_agent.run(
response_stream: Iterator[
RunResponseEvent
] = await self.analysis_agent.arun(
analysis_prompt, stream=True, stream_intermediate_steps=True
)
for event in response_stream:
Expand Down Expand Up @@ -440,7 +442,9 @@ async def _process_fund_holdings_query(
Please ensure the analysis is objective and professional, based on actual data, avoiding excessive speculation.
"""

response_stream: Iterator[RunResponseEvent] = self.analysis_agent.run(
response_stream: Iterator[
RunResponseEvent
] = await self.analysis_agent.arun(
analysis_prompt, stream=True, stream_intermediate_steps=True
)
for event in response_stream:
Expand Down
67 changes: 20 additions & 47 deletions python/valuecell/server/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
from functools import lru_cache


def _get_project_root() -> str:
"""Get project root directory path.

Layout assumption: this file is at repo_root/python/valuecell/server/config/settings.py
We walk up 4 levels to reach repo_root.
"""
here = os.path.dirname(__file__)
repo_root = os.path.abspath(os.path.join(here, "..", "..", "..", ".."))
return repo_root


def _default_db_path() -> str:
"""Get default database path in project root."""
repo_root = _get_project_root()
return f"sqlite:///{os.path.join(repo_root, 'valuecell.db')}"


class Settings:
"""Server configuration settings."""

Expand All @@ -16,7 +33,7 @@ def __init__(self):
self.APP_ENVIRONMENT = os.getenv("APP_ENVIRONMENT", "development")

# API Configuration
self.API_HOST = os.getenv("API_HOST", "localhost")
self.API_HOST = os.getenv("API_HOST", "0.0.0.0")
self.API_PORT = int(os.getenv("API_PORT", "8000"))
self.API_DEBUG = os.getenv("API_DEBUG", "false").lower() == "true"

Expand All @@ -25,23 +42,7 @@ def __init__(self):
self.CORS_ORIGINS = cors_origins.split(",") if cors_origins != "*" else ["*"]

# Database Configuration
self.DATABASE_URL = os.getenv(
"DATABASE_URL", "sqlite:///valuecell/server/db/valuecell.db"
)
self.DB_ECHO = os.getenv("DB_ECHO", "false").lower() == "true"

# Redis Configuration
self.REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379")

# Security Configuration
self.SECRET_KEY = os.getenv("SECRET_KEY", "your-secret-key-here")
self.ACCESS_TOKEN_EXPIRE_MINUTES = int(
os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "30")
)

# Logging Configuration
self.LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
self.LOG_FORMAT = os.getenv("LOG_FORMAT", "json")
self.DATABASE_URL = os.getenv("VALUECELL_SQLITE_DB", _default_db_path())

# File Paths
self.BASE_DIR = Path(__file__).parent.parent.parent
Expand All @@ -51,37 +52,9 @@ def __init__(self):
# I18n Configuration
self.LOCALE_DIR = self.BASE_DIR / "configs/locales"

# Agent Configuration
self.AGENT_TIMEOUT = int(os.getenv("AGENT_TIMEOUT", "300")) # 5 minutes
self.MAX_CONCURRENT_AGENTS = int(os.getenv("MAX_CONCURRENT_AGENTS", "10"))

# External APIs
self.OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
self.FINNHUB_API_KEY = os.getenv("FINNHUB_API_KEY")
self.ALPHA_VANTAGE_API_KEY = os.getenv("ALPHA_VANTAGE_API_KEY")

@property
def is_development(self) -> bool:
"""Check if running in development mode."""
return self.APP_ENVIRONMENT == "development"

@property
def is_production(self) -> bool:
"""Check if running in production mode."""
return self.APP_ENVIRONMENT == "production"

def get_database_config(self) -> dict:
"""Get database configuration."""
return {
"url": self.DATABASE_URL,
"echo": self.DB_ECHO,
}

def get_redis_config(self) -> dict:
"""Get Redis configuration."""
return {
"url": self.REDIS_URL,
}
return {"url": self.DATABASE_URL}

def update_language(self, language: str) -> None:
"""Update current language setting.
Expand Down
1 change: 0 additions & 1 deletion python/valuecell/server/db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _initialize_engine(self) -> None:

self.engine = create_engine(
database_config["url"],
echo=database_config["echo"],
connect_args=connect_args,
poolclass=StaticPool
if database_config["url"].startswith("sqlite")
Expand Down