Spaces:
Sleeping
Sleeping
| from gradio_client import Client | |
| import time | |
| def test_live_scenario(name, input_text, expected_keyword): | |
| print(f"\n>>> Live Test: {name}") | |
| print(f" Input: '{input_text}'") | |
| try: | |
| client = Client("http://127.0.0.1:7860") | |
| # We need to simulate a fresh conversation | |
| # app_local.py keeps state in 'history_state', but each client.predict call with empty history starts fresh logic-wise | |
| # for our stateless wrapper or we need to manage history manually. | |
| # The wrapper signature is chat_wrapper(message, history, short_answers, lang) | |
| res = client.predict( | |
| message=input_text, | |
| history=[], | |
| short_answers=False, | |
| # lang="English", # Default | |
| api_name="//chat" | |
| ) | |
| # res is [chatbot, history] | |
| # chatbot is list of [user_msg, bot_msg] | |
| bot_response = res[0][-1][1] | |
| print(f" Response: {bot_response[:150]}...") | |
| if expected_keyword.lower() in bot_response.lower(): | |
| print(f" ✔ SUCCESS: Found '{expected_keyword}'") | |
| else: | |
| print(f" ❌ FAILURE: Expected '{expected_keyword}' not found.") | |
| except Exception as e: | |
| print(f" !!! ERROR: {e}") | |
| if __name__ == "__main__": | |
| print("Connecting to local Sage 6.5 instance...") | |
| # 1. Name Only | |
| test_live_scenario("Name Only", "My name is Julian.", "Oracle") | |
| # Expectation: "Consulting the Oracle" or "Wisdom string" | |
| # 2. Topic Only | |
| test_live_scenario("Topic Only", "Thema: Liebe", "Love") # Or Oracle | |
| # 3. Date Only | |
| test_live_scenario("Date Only", "Reading for 2025-01-01", "2025") | |
| # 4. General | |
| test_live_scenario("General Chat", "Hello, who are you?", "Sage") | |