ViMedical API cung cấp các endpoint để tương tác với hệ thống trợ lý y tế thông minh.
http://localhost:8000
API hiện tại không yêu cầu authentication, nhưng cần cấu hình API keys trong file .env.
Kiểm tra trạng thái hệ thống.
GET /health
Response:
{
"status": "healthy",
"llm_chain_status": "initialized",
"timestamp": "2025-01-05T10:30:00"
}Gửi tin nhắn và nhận phản hồi từ AI.
POST /api/v1/chat
Request Body:
{
"message": "Tôi bị đau đầu và sốt",
"session_id": "optional-session-id",
"previous_symptoms": ""
}Response:
{
"response": "Dựa trên các triệu chứng bạn mô tả...",
"possible_diseases": ["Cảm cúm", "Viêm họng"],
"symptoms": "đau đầu, sốt",
"timestamp": "10:30:15",
"ask_confirmation": false
}Tạo phiên chat mới.
POST /api/v1/session/new
Response:
{
"session_id": "uuid-session-id"
}Lấy tin nhắn của một phiên chat.
GET /api/v1/session/{session_id}/messages
Response:
{
"messages": [
{
"role": "user",
"content": "Tôi bị đau đầu",
"timestamp": "10:30:00"
},
{
"role": "assistant",
"content": "Có thể bạn đang bị...",
"timestamp": "10:30:15"
}
]
}200- Success400- Bad Request404- Not Found500- Internal Server Error
{
"detail": "Error message description"
}API hiện tại chưa có rate limiting, nhưng khuyến nghị không gửi quá 10 requests/second.
curl -X POST "http://localhost:8000/api/v1/chat" \
-H "Content-Type: application/json" \
-d '{
"message": "Tôi bị ho và khó thở"
}'curl -X POST "http://localhost:8000/api/v1/session/new"curl -X GET "http://localhost:8000/health"{
"message": "string (required)",
"session_id": "string (optional)",
"previous_symptoms": "string (optional)"
}{
"response": "string",
"possible_diseases": ["string"],
"symptoms": "string",
"timestamp": "string",
"ask_confirmation": "boolean"
}{
"role": "string (user|assistant)",
"content": "string",
"timestamp": "string"
}import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:8000/api/v1'
});
// Gửi tin nhắn
const response = await api.post('/chat', {
message: 'Tôi bị đau đầu'
});import requests
url = 'http://localhost:8000/api/v1/chat'
data = {
'message': 'Tôi bị đau đầu'
}
response = requests.post(url, json=data)
result = response.json()Nếu gặp vấn đề, vui lòng kiểm tra:
- Backend đang chạy tại port 8000
- File
.envđã được cấu hình đúng - API keys hợp lệ