eli02's picture
Initial commit.
3145903
metadata
title: Al Ghazali Rag Retrieval Api
emoji: πŸ”—
colorFrom: indigo
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
license: unknown

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

Al Ghazali Rag Retrieval Api

Endpoints

1. /login Endpoint

This endpoint is used to authenticate the user and issue an access token and a refresh token.

Request:

curl -X POST https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/login \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d 'username=user1332&password=RmzmurS7aE!t'

Response:

If the credentials are valid, the server responds with:

{
    "access_token": "your-access-token",
    "refresh_token": "your-refresh-token",
    "token_type": "bearer",
    "expires_in": 1800  // Access token expires in 30 minutes (1800 seconds)
}

If the credentials are invalid, the server responds with:

{
    "detail": "Invalid username or password"
}

2. /refresh Endpoint

This endpoint is used to refresh the access token using a valid refresh token.

Request:

curl -X POST https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/refresh \
     -H "Content-Type: application/json" \
     -d '{"refresh_token": "your-refresh-token"}'

Response:

If the refresh token is valid, the server responds with:

{
    "access_token": "new-access-token",
    "refresh_token": "your-refresh-token",  // Optionally issue a new refresh token
    "token_type": "bearer",
    "expires_in": 1800
}

If the refresh token is invalid or expired, the server responds with:

{
    "detail": "Could not validate credentials"
}

3. /search Endpoint

This endpoint is used to send a search query and retrieve results. It requires a valid access token.

Request:

curl -X POST https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/search \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer your-access-token" \
     -d '{"query": "test query"}'

Response:

If the access token is valid, the server responds with:

[
    {
        "text": "Result 1 text",
        "similarity": 0.95
    },
    {
        "text": "Result 2 text",
        "similarity": 0.92
    },
    {
        "text": "Result 3 text",
        "similarity": 0.89
    }
]

If the access token is invalid or expired, the server responds with:

{
    "detail": "Could not validate credentials"
}

4. Root Endpoint (/)

This endpoint is used to check if the API is running.

Request:

curl -X GET https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/

Response:

{
    "message": "Welcome to the Alchemy of Happiness API!"
}

Workflow Example

Step 1: Login

  1. Request:
    curl -X POST https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/login \
         -H "Content-Type: application/x-www-form-urlencoded" \
         -d 'username=user1332&password=RmzmurS7aE!t'
    
  2. Response:
    {
        "access_token": "your-access-token",
        "refresh_token": "your-refresh-token",
        "token_type": "bearer",
        "expires_in": 1800
    }
    

Step 2: Search

  1. Request:
    curl -X POST https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/search \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer your-access-token" \
         -d '{"query": "test query"}'
    
  2. Response:
    [
        {
            "text": "Result 1 text",
            "similarity": 0.95
        },
        {
            "text": "Result 2 text",
            "similarity": 0.92
        },
        {
            "text": "Result 3 text",
            "similarity": 0.89
        }
    ]
    

Step 3: Refresh Token

  1. Request:
    curl -X POST https://humblebeeai-al-ghazali-rag-retrieval-api.hf.space/refresh \
         -H "Content-Type: application/json" \
         -d '{"refresh_token": "your-refresh-token"}'
    
  2. Response:
    {
        "access_token": "new-access-token",
        "refresh_token": "your-refresh-token",
        "token_type": "bearer",
        "expires_in": 1800
    }
    

Summary

  • /login: Authenticate and get tokens.
  • /refresh: Refresh the access token.
  • /search: Send a search query (requires a valid access token).
  • /: Check if the API is running.

Let me know if you need further clarification or assistance!