forked from innovacion/Mayacontigo
add healthcheck to remaining apps
This commit is contained in:
59
apps/egresos/api/config.py
Normal file
59
apps/egresos/api/config.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from hvac import Client
|
||||
from pydantic import Field
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
client = Client(url="https://vault.ia-innovacion.work")
|
||||
|
||||
if not client.is_authenticated():
|
||||
raise Exception("Vault authentication failed")
|
||||
|
||||
secret_map = client.secrets.kv.v2.read_secret_version(
|
||||
path="banortegpt", mount_point="secret"
|
||||
)["data"]["data"]
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""
|
||||
Esta clase obtiene sus valores de variables de ambiente.
|
||||
Si no estan en el ambiente, los jala de nuestra Vault.
|
||||
"""
|
||||
|
||||
# Config
|
||||
model: str = "gpt-4o"
|
||||
model_temperature: int = 0
|
||||
message_limit: int = 10
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 8000
|
||||
vector_index: str = "chat-egresos-3"
|
||||
search_limit: int = 3
|
||||
embedding_model: str = "text-embedding-3-large"
|
||||
|
||||
# API Keys
|
||||
azure_endpoint: str = Field(default_factory=lambda: secret_map["azure_endpoint"])
|
||||
openai_api_key: str = Field(default_factory=lambda: secret_map["openai_api_key"])
|
||||
openai_api_version: str = Field(
|
||||
default_factory=lambda: secret_map["openai_api_version"]
|
||||
)
|
||||
mongodb_url: str = Field(
|
||||
default_factory=lambda: secret_map["cosmosdb_connection_string"]
|
||||
)
|
||||
|
||||
qdrant_url: str = Field(default_factory=lambda: secret_map["qdrant_api_url"])
|
||||
qdrant_api_key: str | None = Field(
|
||||
default_factory=lambda: secret_map["qdrant_api_key"]
|
||||
)
|
||||
|
||||
async def init_mongo_db(self):
|
||||
"""Este helper inicia la conexion enter el MongoDB ORM y nuestra instancia"""
|
||||
|
||||
from beanie import init_beanie
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
|
||||
from banortegpt.database.mongo_memory.models import Conversation
|
||||
|
||||
await init_beanie(
|
||||
database=AsyncIOMotorClient(self.mongodb_url).banortegptdos,
|
||||
document_models=[Conversation],
|
||||
)
|
||||
|
||||
|
||||
config = Settings()
|
||||
Reference in New Issue
Block a user