claw / README.md
David
docs: add documentation for the chat endpoint and include required dependencies in requirements.txt
b9af006
|
Raw History Blame Contribute Delete
2.3 kB
metadata
title: Claw
emoji: 🏢
colorFrom: gray
colorTo: yellow
sdk: docker
pinned: false
license: mit
short_description: Handle responses for claw

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

Greet JSON Endpoint

The greet_json endpoint is located at the root of the application (path /).

How to Call

1. Via Browser

Navigate to the root URL in your browser:

2. Via cURL

  • Hosted Space:
    curl https://devserenerocks-claw.hf.space/
    
  • Locally:
    curl http://localhost:7860/
    

3. Via Python

  • Hosted Space:
    import requests
    
    response = requests.get("https://devserenerocks-claw.hf.space/")
    print(response.json())
    
  • Locally:
    import requests
    
    response = requests.get("http://localhost:7860/")
    print(response.json())
    

Expected Response

{
  "Hello": "World!"
}

Chat Endpoint

The chat endpoint is located at /chat and uses Hugging Face's InferenceClient (running nvidia/Llama-3.1-Nemotron-Nano-8B-v1) to get chat completions.

This endpoint requires the HF_TOKEN environment variable to be set with a valid Hugging Face Hub token.

How to Call

1. Via cURL

  • Hosted Space:
    curl -X POST https://devserenerocks-claw.hf.space/chat \
      -H "Content-Type: application/json" \
      -d '{"message": "Hello, how are you?"}'
    
  • Locally:
    curl -X POST http://localhost:7860/chat \
      -H "Content-Type: application/json" \
      -d '{"message": "Hello, how are you?"}'
    

2. Via Python

  • Hosted Space:
    import requests
    
    payload = {"message": "Hello, how are you?"}
    response = requests.post("https://devserenerocks-claw.hf.space/chat", json=payload)
    print(response.json())
    
  • Locally:
    import requests
    
    payload = {"message": "Hello, how are you?"}
    response = requests.post("http://localhost:7860/chat", json=payload)
    print(response.json())
    

Expected Response

{
  "response": "Hello! I am doing well, thank you. How can I help you today?"
}