routing-probe.py

import socket,json
from pathlib import Path
attempts=[]
def deny(*a,**k):attempts.append('blocked');raise AssertionError('offline')
socket.socket.connect=deny;socket.getaddrinfo=deny
from fastapi.testclient import TestClient
from moe.app import app
queries=['Optimize bids for Meta Ads campaign','Optimize bids for Meta Ads','Optimize Meta Ads bids','Optimize email campaign subject lines']
results=[]
with TestClient(app) as c:
 for query in queries:
  for hint in ['none','top_level','context']:
   payload={'query':query,'context':{'cells':[26,27,30]},'correlation_id':'fixture-fr39','required_confidence':.75}
   if hint=='top_level':payload['user_hint']='bid optimizer'
   if hint=='context':payload['context']['specialist_hint']='bid optimizer'
   r=c.post('/route',json=payload);body=r.json()
   results.append({'query':query,'hint_location':hint,'status':r.status_code,'specialist':body.get('specialist_type'),'confidence':body.get('confidence'),'reasoning':body.get('reasoning'),'alternatives':body.get('alternatives'),'metadata':body.get('metadata')})
assert not attempts
Path('/tmp/fr39-routing-probe.json').write_text(json.dumps({'scope':'offline actual app and LangGraph, fixture only','network_attempts':attempts,'results':results},indent=2))
← All docsView source on GitHub →