shiv-4567892009 commited on
Commit
0f9abe1
·
verified ·
1 Parent(s): 3e84643
Files changed (1) hide show
  1. app.py +87 -0
app.py CHANGED
@@ -1858,6 +1858,93 @@ def root():
1858
  })
1859
 
1860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1861
  # ============== Error Handlers ==============
1862
 
1863
  @app.errorhandler(404)
 
1858
  })
1859
 
1860
 
1861
+ @app.route('/debug/raw-test', methods=['GET'])
1862
+ def debug_raw_test():
1863
+ """Test Onyx directly with and without llm_override"""
1864
+ import time as t
1865
+ results = []
1866
+
1867
+ endpoints = [
1868
+ f"{ONYX_BASE_URL}/api/chat/send-chat-message",
1869
+ f"{ONYX_BASE_URL}/api/chat/send-message",
1870
+ ]
1871
+
1872
+ # Create session
1873
+ sess = requests.post(
1874
+ f"{ONYX_BASE_URL}/api/chat/create-chat-session",
1875
+ json={"persona_id": 1, "description": "Debug Test"},
1876
+ headers=get_headers(), timeout=15
1877
+ )
1878
+ if sess.status_code != 200:
1879
+ return jsonify({"error": f"Session creation failed: {sess.text}"}), 500
1880
+ sid = sess.json().get("chat_session_id") or sess.json().get("id")
1881
+
1882
+ # Test 1: WITHOUT llm_override
1883
+ payload1 = {
1884
+ "message": "Hello, say hi back in 3 words.",
1885
+ "chat_session_id": sid,
1886
+ "stream": True
1887
+ }
1888
+
1889
+ test1_result = {"test": "WITHOUT llm_override", "payload": payload1}
1890
+ for url in endpoints:
1891
+ try:
1892
+ r = requests.post(url, json=payload1, headers=get_headers(), stream=True, timeout=30)
1893
+ if r.status_code == 404:
1894
+ continue
1895
+ chunks = []
1896
+ for chunk in r.iter_content(chunk_size=None, decode_unicode=True):
1897
+ if chunk:
1898
+ chunks.append(chunk[:200])
1899
+ test1_result["status"] = r.status_code
1900
+ test1_result["endpoint"] = url.split("/")[-1]
1901
+ test1_result["raw_chunks"] = chunks[:10]
1902
+ break
1903
+ except Exception as e:
1904
+ test1_result["error"] = str(e)
1905
+ results.append(test1_result)
1906
+
1907
+ # Create new session for test 2
1908
+ sess2 = requests.post(
1909
+ f"{ONYX_BASE_URL}/api/chat/create-chat-session",
1910
+ json={"persona_id": 1, "description": "Debug Test 2"},
1911
+ headers=get_headers(), timeout=15
1912
+ )
1913
+ sid2 = sess2.json().get("chat_session_id") or sess2.json().get("id")
1914
+
1915
+ # Test 2: WITH llm_override
1916
+ payload2 = {
1917
+ "message": "Hello, say hi back in 3 words.",
1918
+ "chat_session_id": sid2,
1919
+ "stream": True,
1920
+ "llm_override": {
1921
+ "model_provider": "Anthropic",
1922
+ "model_version": "claude-opus-4-5",
1923
+ "temperature": 0.7
1924
+ }
1925
+ }
1926
+
1927
+ test2_result = {"test": "WITH llm_override (claude-opus-4-5)", "payload": payload2}
1928
+ for url in endpoints:
1929
+ try:
1930
+ r = requests.post(url, json=payload2, headers=get_headers(), stream=True, timeout=30)
1931
+ if r.status_code == 404:
1932
+ continue
1933
+ chunks = []
1934
+ for chunk in r.iter_content(chunk_size=None, decode_unicode=True):
1935
+ if chunk:
1936
+ chunks.append(chunk[:200])
1937
+ test2_result["status"] = r.status_code
1938
+ test2_result["endpoint"] = url.split("/")[-1]
1939
+ test2_result["raw_chunks"] = chunks[:10]
1940
+ break
1941
+ except Exception as e:
1942
+ test2_result["error"] = str(e)
1943
+ results.append(test2_result)
1944
+
1945
+ return jsonify({"session_ids": [sid, sid2], "results": results})
1946
+
1947
+
1948
  # ============== Error Handlers ==============
1949
 
1950
  @app.errorhandler(404)