AIDev07 commited on
Commit
3e2439e
·
verified ·
1 Parent(s): 44cf4cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -104,6 +104,31 @@ async def chat_endpoint(request: Request):
104
 
105
  return StreamingResponse(stream_logic(), media_type="text/event-stream")
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  # --- Floating Terminal / Shell Control ---
108
  @app.post("/v1/shell")
109
  async def shell_exec(request: Request):
 
104
 
105
  return StreamingResponse(stream_logic(), media_type="text/event-stream")
106
 
107
+ @app.post("/v1/debug")
108
+ async def debug_endpoint(request: Request):
109
+ data = await request.json()
110
+ messages = data.get("messages", [])
111
+
112
+ headers = {"Authorization": f"Bearer {GROQ_API_KEY}"}
113
+ payload = {
114
+ "model": "llama-3.3-70b-versatile",
115
+ "messages": messages,
116
+ "stream": False # non-streaming first to isolate the issue
117
+ }
118
+
119
+ async with httpx.AsyncClient(timeout=30.0) as client:
120
+ response = await client.post(
121
+ "https://api.groq.com/openai/v1/chat/completions",
122
+ headers=headers,
123
+ json=payload
124
+ )
125
+ return {
126
+ "groq_status": response.status_code,
127
+ "groq_key_set": bool(GROQ_API_KEY),
128
+ "groq_key_prefix": GROQ_API_KEY[:8] if GROQ_API_KEY else "MISSING",
129
+ "groq_response": response.json()
130
+ }
131
+
132
  # --- Floating Terminal / Shell Control ---
133
  @app.post("/v1/shell")
134
  async def shell_exec(request: Request):