Spaces:
Sleeping
Sleeping
David commited on
Commit ·
b9af006
1
Parent(s): bcdd362
docs: add documentation for the chat endpoint and include required dependencies in requirements.txt
Browse files- README.md +49 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -54,3 +54,52 @@ Navigate to the root URL in your browser:
|
|
| 54 |
"Hello": "World!"
|
| 55 |
}
|
| 56 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
"Hello": "World!"
|
| 55 |
}
|
| 56 |
```
|
| 57 |
+
|
| 58 |
+
## Chat Endpoint
|
| 59 |
+
|
| 60 |
+
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.
|
| 61 |
+
|
| 62 |
+
> [!NOTE]
|
| 63 |
+
> This endpoint requires the `HF_TOKEN` environment variable to be set with a valid Hugging Face Hub token.
|
| 64 |
+
|
| 65 |
+
### How to Call
|
| 66 |
+
|
| 67 |
+
#### 1. Via cURL
|
| 68 |
+
- **Hosted Space**:
|
| 69 |
+
```bash
|
| 70 |
+
curl -X POST https://devserenerocks-claw.hf.space/chat \
|
| 71 |
+
-H "Content-Type: application/json" \
|
| 72 |
+
-d '{"message": "Hello, how are you?"}'
|
| 73 |
+
```
|
| 74 |
+
- **Locally**:
|
| 75 |
+
```bash
|
| 76 |
+
curl -X POST http://localhost:7860/chat \
|
| 77 |
+
-H "Content-Type: application/json" \
|
| 78 |
+
-d '{"message": "Hello, how are you?"}'
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
#### 2. Via Python
|
| 82 |
+
- **Hosted Space**:
|
| 83 |
+
```python
|
| 84 |
+
import requests
|
| 85 |
+
|
| 86 |
+
payload = {"message": "Hello, how are you?"}
|
| 87 |
+
response = requests.post("https://devserenerocks-claw.hf.space/chat", json=payload)
|
| 88 |
+
print(response.json())
|
| 89 |
+
```
|
| 90 |
+
- **Locally**:
|
| 91 |
+
```python
|
| 92 |
+
import requests
|
| 93 |
+
|
| 94 |
+
payload = {"message": "Hello, how are you?"}
|
| 95 |
+
response = requests.post("http://localhost:7860/chat", json=payload)
|
| 96 |
+
print(response.json())
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
### Expected Response
|
| 100 |
+
```json
|
| 101 |
+
{
|
| 102 |
+
"response": "Hello! I am doing well, thank you. How can I help you today?"
|
| 103 |
+
}
|
| 104 |
+
```
|
| 105 |
+
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
fastapi
|
| 2 |
uvicorn[standard]
|
| 3 |
huggingface-hub
|
|
|
|
|
|
| 1 |
fastapi
|
| 2 |
uvicorn[standard]
|
| 3 |
huggingface-hub
|
| 4 |
+
pydantic
|