Spaces:
Sleeping
Sleeping
File size: 1,341 Bytes
b7f3dcc | 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | from gradio_client import Client
import time
import json
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def run_test(message, history=[], short_answers=False):
print(f"\n>>> SENDING: {message}")
try:
client = Client("http://127.0.0.1:7860", ssl_verify=False)
# Using the /chat endpoint
result = client.predict(
message=message,
history=history,
short_answers=short_answers,
api_name="//chat"
)
# result is (history, threads, dropdown_upd, dropdown_upd)
new_history = result[0]
threads = result[1]
last_resp = new_history[-1]["content"] if new_history else "EMPTY"
print(f"<<< RECEIVED: {last_resp}")
return new_history, threads
except Exception as e:
print(f"!!! Error: {e}")
return history, {}
def diagnostic_flow():
print("Starting Diagnostic Chat Flow...")
# 1. Greeting
h, t = run_test("Hallo, wer bist du?")
# 2. Name
h, t = run_test("Mein Name ist Julian.", history=h)
# 3. Oracle Trigger
h, t = run_test("Was sagen die Psalmen heute?", history=h)
# 4. History check
h, t = run_test("Wie war mein Name noch mal?", history=h)
if __name__ == "__main__":
diagnostic_flow()
|