gemma-sage / tests /diagnostic_chat.py
neuralworm's picture
Refactor: Modularized codebase and consolidated Oracle bridges
b7f3dcc
Raw
History Blame
1.34 kB
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()