File size: 853 Bytes
6aba078
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from gradio_client import Client

# Connect to Hugging Face API
client = Client("DrSyedFaizan/First_Aid_Assistant")

# Define test question
test_question = "What are the first aid measures for high fever in infants?"

# Make API call with correct formatting
try:
    result = client.predict(
        chatbot=[],  # Ensure chatbot history is correctly formatted
        message=test_question,  # The actual question
        api_name="/respond"
    )

    # Extract assistant response
    chat_history = result[1]  # Full chat history
    chatbot_response = next((entry["content"] for entry in chat_history if entry["role"] == "assistant"), "[NO RESPONSE]")

    # Print extracted response
    print("\n===== Response from Chatbot =====")
    print("Chatbot says:", chatbot_response)
except Exception as e:
    print("Error:", e)