Spaces:
Running
Running
File size: 3,453 Bytes
774ec97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #!/usr/bin/env python3
"""
Script para configurar el entorno local
"""
import os
import sys
import subprocess
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def setup_environment():
"""Configurar entorno local"""
print("🚀 Configurando entorno local para Asistente Educativo RAG")
# 1. Crear estructura de directorios
directories = [
"data/documents",
"data/vector_store",
"logs",
"config",
"api",
"rag",
"tests",
"scripts",
"docker"
]
for directory in directories:
os.makedirs(directory, exist_ok=True)
print(f" 📁 Directorio creado: {directory}")
# 2. Crear archivo .env
env_content = """# Configuración del entorno
DEBUG=True
API_HOST=0.0.0.0
API_PORT=8000
# Modelos
EMBEDDING_MODEL=sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2
LLM_MODEL=mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es
# RAG
CHUNK_SIZE=768
CHUNK_OVERLAP=128
TOP_K_RESULTS=3
SIMILARITY_THRESHOLD=0.7
# Vector Store
VECTOR_STORE=chroma
PERSIST_DIRECTORY=./data/vector_store
"""
with open(".env", "w") as f:
f.write(env_content)
print(" ⚙️ Archivo .env creado")
# 3. Crear intents.json básico si no existe
if not os.path.exists("data/intents.json"):
basic_intents = {
"intents": [
{
"tag": "saludo",
"patterns": [
"hola", "buenos días", "buenas tardes", "hola asistente"
],
"responses": [
"¡Hola! Soy tu asistente del módulo propedéutico. ¿En qué puedo ayudarte?"
],
"context": "welcome"
},
{
"tag": "despedida",
"patterns": [
"adiós", "gracias", "hasta luego", "chao"
],
"responses": [
"¡Hasta luego! Recuerda que estoy aquí para ayudarte con el módulo.",
"¡Nos vemos! Si tienes más dudas, no dudes en preguntar."
],
"context": "goodbye"
}
]
}
import json
with open("data/intents.json", "w", encoding="utf-8") as f:
json.dump(basic_intents, f, ensure_ascii=False, indent=2)
print(" 💬 Archivo intents.json creado con ejemplos básicos")
# 4. Crear requirements.txt
requirements = """fastapi==0.104.1
uvicorn[standard]==0.24.0
pydantic==2.5.0
pydantic-settings==2.1.0
sentence-transformers==2.2.2
chromadb==0.4.18
transformers==4.36.0
torch==2.1.0
numpy==1.24.3
python-multipart==0.0.6
pytest==7.4.3
python-dotenv==1.0.0
requests==2.31.0
langchain==0.0.339
tiktoken==0.5.2
"""
with open("requirements.txt", "w") as f:
f.write(requirements)
print(" 📦 requirements.txt creado")
print("\n✅ Entorno configurado correctamente!")
print("\n📋 Próximos pasos:")
print("1. Instalar dependencias: pip install -r requirements.txt")
print("2. Ejecutar tests: python -m pytest tests/")
print("3. Iniciar API: python -m api.main")
print("4. Acceder a: http://localhost:8000/docs")
if __name__ == "__main__":
setup_environment() |