forked from innovacion/Mayacontigo
ic
This commit is contained in:
55
apps/normativa/api/config.py
Normal file
55
apps/normativa/api/config.py
Normal file
@@ -0,0 +1,55 @@
|
||||
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):
|
||||
# Config básico
|
||||
model: str = "gpt-4o"
|
||||
model_temperature: int = 0
|
||||
message_limit: int = 10
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 8000
|
||||
|
||||
# AGREGAR ESTAS LÍNEAS (igual que OCP):
|
||||
embedding_model: str = "text-embedding-3-large"
|
||||
storage_bucket: str = "normativa-bucket" # Ajusta el nombre
|
||||
vector_index: str = "MayaNormativaLLM"
|
||||
search_limit: int = 3
|
||||
|
||||
# API Keys existentes
|
||||
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"])
|
||||
|
||||
# AGREGAR ESTAS LÍNEAS (igual que OCP):
|
||||
azure_blob_connection_string: str = Field(
|
||||
default_factory=lambda: secret_map["azure_blob_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):
|
||||
from banortegpt.database.mongo_memory.models import Conversation
|
||||
from beanie import init_beanie
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
|
||||
client = AsyncIOMotorClient(self.mongodb_url)
|
||||
|
||||
await init_beanie(
|
||||
database=client.banortegptdos,
|
||||
document_models=[Conversation],
|
||||
)
|
||||
|
||||
config = Settings()
|
||||
Reference in New Issue
Block a user