JatsTheAIGen commited on
Commit
40b87ab
·
1 Parent(s): 3f8cddc

Fix API documentation URLs: use correct HF Spaces .hf.space domain format and add troubleshooting section

Browse files
Files changed (1) hide show
  1. API_DOCUMENTATION.md +91 -9
API_DOCUMENTATION.md CHANGED
@@ -4,12 +4,16 @@
4
 
5
  The Research AI Assistant API provides a RESTful interface for interacting with an AI-powered research assistant. The API uses local GPU models for inference and supports conversational interactions with context management.
6
 
7
- **Base URL:** `https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API`
 
 
8
 
9
  **API Version:** 1.0
10
 
11
  **Content-Type:** `application/json`
12
 
 
 
13
  ## Features
14
 
15
  - 🤖 **AI-Powered Responses** - Local GPU model inference (Tesla T4)
@@ -232,7 +236,7 @@ Content-Type: application/json
232
  import requests
233
  import json
234
 
235
- BASE_URL = "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API"
236
 
237
  # Check health
238
  def check_health():
@@ -290,7 +294,7 @@ if __name__ == "__main__":
290
  ### JavaScript (Fetch API)
291
 
292
  ```javascript
293
- const BASE_URL = 'https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API';
294
 
295
  // Check health
296
  async function checkHealth() {
@@ -362,10 +366,10 @@ main();
362
 
363
  ```bash
364
  # Check health
365
- curl -X GET "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API/api/health"
366
 
367
  # Send chat message
368
- curl -X POST "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API/api/chat" \
369
  -H "Content-Type: application/json" \
370
  -d '{
371
  "message": "What is machine learning?",
@@ -375,7 +379,7 @@ curl -X POST "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assi
375
  }'
376
 
377
  # Continue conversation
378
- curl -X POST "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API/api/chat" \
379
  -H "Content-Type: application/json" \
380
  -d '{
381
  "message": "Can you explain neural networks?",
@@ -392,7 +396,7 @@ curl -X POST "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assi
392
  ```javascript
393
  const axios = require('axios');
394
 
395
- const BASE_URL = 'https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API';
396
 
397
  // Check health
398
  async function checkHealth() {
@@ -607,7 +611,7 @@ const AIAssistant = () => {
607
 
608
  setLoading(true);
609
  try {
610
- const response = await fetch('https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API/api/chat', {
611
  method: 'POST',
612
  headers: { 'Content-Type': 'application/json' },
613
  body: JSON.stringify({
@@ -661,7 +665,7 @@ const AIAssistant = () => {
661
  import requests
662
  import sys
663
 
664
- BASE_URL = "https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API"
665
 
666
  class ChatCLI:
667
  def __init__(self):
@@ -720,6 +724,84 @@ if __name__ == "__main__":
720
 
721
  ---
722
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
723
  ## Support
724
 
725
  For issues, questions, or contributions:
 
4
 
5
  The Research AI Assistant API provides a RESTful interface for interacting with an AI-powered research assistant. The API uses local GPU models for inference and supports conversational interactions with context management.
6
 
7
+ **Base URL (HF Spaces):** `https://jatinautonomouslabs-research-ai-assistant-api.hf.space`
8
+
9
+ **Alternative Base URL:** `https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API`
10
 
11
  **API Version:** 1.0
12
 
13
  **Content-Type:** `application/json`
14
 
15
+ > **Note:** For Hugging Face Spaces Docker deployments, use the `.hf.space` domain format. The space name is converted to lowercase with hyphens.
16
+
17
  ## Features
18
 
19
  - 🤖 **AI-Powered Responses** - Local GPU model inference (Tesla T4)
 
236
  import requests
237
  import json
238
 
239
+ BASE_URL = "https://jatinautonomouslabs-research-ai-assistant-api.hf.space"
240
 
241
  # Check health
242
  def check_health():
 
294
  ### JavaScript (Fetch API)
295
 
296
  ```javascript
297
+ const BASE_URL = 'https://jatinautonomouslabs-research-ai-assistant-api.hf.space';
298
 
299
  // Check health
300
  async function checkHealth() {
 
366
 
367
  ```bash
368
  # Check health
369
+ curl -X GET "https://jatinautonomouslabs-research-ai-assistant-api.hf.space/api/health"
370
 
371
  # Send chat message
372
+ curl -X POST "https://jatinautonomouslabs-research-ai-assistant-api.hf.space/api/chat" \
373
  -H "Content-Type: application/json" \
374
  -d '{
375
  "message": "What is machine learning?",
 
379
  }'
380
 
381
  # Continue conversation
382
+ curl -X POST "https://jatinautonomouslabs-research-ai-assistant-api.hf.space/api/chat" \
383
  -H "Content-Type: application/json" \
384
  -d '{
385
  "message": "Can you explain neural networks?",
 
396
  ```javascript
397
  const axios = require('axios');
398
 
399
+ const BASE_URL = 'https://jatinautonomouslabs-research-ai-assistant-api.hf.space';
400
 
401
  // Check health
402
  async function checkHealth() {
 
611
 
612
  setLoading(true);
613
  try {
614
+ const response = await fetch('https://jatinautonomouslabs-research-ai-assistant-api.hf.space/api/chat', {
615
  method: 'POST',
616
  headers: { 'Content-Type': 'application/json' },
617
  body: JSON.stringify({
 
665
  import requests
666
  import sys
667
 
668
+ BASE_URL = "https://jatinautonomouslabs-research-ai-assistant-api.hf.space"
669
 
670
  class ChatCLI:
671
  def __init__(self):
 
724
 
725
  ---
726
 
727
+ ## Troubleshooting
728
+
729
+ ### Common Issues
730
+
731
+ #### 404 Not Found
732
+
733
+ **Problem:** Getting 404 when accessing the API
734
+
735
+ **Solutions:**
736
+ 1. **Verify the Space is running:**
737
+ - Check the Hugging Face Space page to ensure it's built and running
738
+ - Wait for the initial build to complete (5-10 minutes)
739
+
740
+ 2. **Check URL format:**
741
+ - ✅ Correct: `https://jatinautonomouslabs-research-ai-assistant-api.hf.space`
742
+ - ❌ Wrong: `https://jatinautonomouslabs-research_ai_assistant_api.hf.space` (underscores)
743
+ - ✅ Alternative: `https://huggingface.co/spaces/JatinAutonomousLabs/Research_AI_Assistant_API`
744
+
745
+ 3. **Verify endpoint paths:**
746
+ - Health: `GET /api/health`
747
+ - Chat: `POST /api/chat`
748
+ - Root: `GET /`
749
+
750
+ 4. **Test with root endpoint first:**
751
+ ```bash
752
+ curl https://jatinautonomouslabs-research-ai-assistant-api.hf.space/
753
+ ```
754
+
755
+ #### 503 Service Unavailable
756
+
757
+ **Problem:** Orchestrator not ready
758
+
759
+ **Solutions:**
760
+ 1. Wait 30-60 seconds for initialization
761
+ 2. Check `/api/health` endpoint
762
+ 3. Use `/api/initialize` to manually trigger initialization
763
+
764
+ #### CORS Errors
765
+
766
+ **Problem:** CORS errors in browser
767
+
768
+ **Solutions:**
769
+ - The API has CORS enabled for all origins
770
+ - If issues persist, check browser console for specific errors
771
+ - Ensure you're using the correct base URL
772
+
773
+ ### Testing API Connectivity
774
+
775
+ **Quick Health Check:**
776
+ ```bash
777
+ # Test root endpoint
778
+ curl https://jatinautonomouslabs-research-ai-assistant-api.hf.space/
779
+
780
+ # Test health endpoint
781
+ curl https://jatinautonomouslabs-research-ai-assistant-api.hf.space/api/health
782
+ ```
783
+
784
+ **Python Test Script:**
785
+ ```python
786
+ import requests
787
+
788
+ BASE_URL = "https://jatinautonomouslabs-research-ai-assistant-api.hf.space"
789
+
790
+ # Test root
791
+ try:
792
+ response = requests.get(f"{BASE_URL}/", timeout=10)
793
+ print(f"Root endpoint: {response.status_code} - {response.json()}")
794
+ except Exception as e:
795
+ print(f"Root endpoint failed: {e}")
796
+
797
+ # Test health
798
+ try:
799
+ response = requests.get(f"{BASE_URL}/api/health", timeout=10)
800
+ print(f"Health endpoint: {response.status_code} - {response.json()}")
801
+ except Exception as e:
802
+ print(f"Health endpoint failed: {e}")
803
+ ```
804
+
805
  ## Support
806
 
807
  For issues, questions, or contributions: