Spaces:
Runtime error
Runtime error
Download app.py from CohortCreative/Cohort: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/spaces/CohortCreative/Cohort/resolve/main/app.py
- Command line
-
hf download hf://spaces/CohortCreative/Cohort/app.py
-
curl -L -o app.py https://huggingface.co/spaces/CohortCreative/Cohort/resolve/main/app.py
1.42 kB
| import os | |
| def check_missing_components(): | |
| missing_components = [] | |
| # Check for API keys or required environment variables | |
| if not os.getenv("API_KEY"): | |
| missing_components.append("API_KEY is missing. Please provide authentication credentials.") | |
| # Check if database integration is functional | |
| try: | |
| import chromadb | |
| client = chromadb.PersistentClient(path="./chat_memory") | |
| except ImportError: | |
| missing_components.append("ChromaDB is missing. Install it with `pip install chromadb`.") | |
| # Check if AI model is loaded | |
| try: | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct") | |
| model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct") | |
| except Exception as e: | |
| missing_components.append(f"AI Model failed to load: {e}") | |
| # Check if required files exist | |
| required_files = ["app.py", "requirements.txt"] | |
| for file in required_files: | |
| if not os.path.exists(file): | |
| missing_components.append(f"Required file {file} is missing.") | |
| return missing_components | |
| # Execute and report missing components | |
| missing = check_missing_components() | |
| if missing: | |
| print("⚠️ Missing Components Detected:") | |
| for issue in missing: | |
| print(f"- {issue}") | |
| else: | |
| print("✅ All components are present.") | |