From f8b5dd2807195d7ea6a1044422023c6ebdc81695 Mon Sep 17 00:00:00 2001 From: Max Hager <68147541+yachty66@users.noreply.github.com> Date: Wed, 3 Jul 2024 01:12:21 -0700 Subject: [PATCH] new header --- api/index.py | 12 +++++++++--- public/chat.js | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/api/index.py b/api/index.py index cf572a0..fca367d 100644 --- a/api/index.py +++ b/api/index.py @@ -18,7 +18,7 @@ app.add_middleware( CORSMiddleware, - allow_origins=["https://pantheon.so", "https://www.pantheon.so"], + allow_origins=["https://pantheon.so", "https://www.pantheon.so", "*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], @@ -187,8 +187,14 @@ async def generator(): yield content # Create a StreamingResponse for the content - streaming_response = StreamingResponse(generator(), media_type="text/plain") - streaming_response.headers["Transfer-Encoding"] = "chunked" + streaming_response = StreamingResponse( + generator(), + media_type="text/event-stream", + headers={ + "X-Content-Type-Options": "nosniff", + "Transfer-Encoding": "chunked", + }, + ) print("Streaming response created successfully") return streaming_response diff --git a/public/chat.js b/public/chat.js index 5460bcb..85239c8 100644 --- a/public/chat.js +++ b/public/chat.js @@ -49,6 +49,8 @@ document.addEventListener("DOMContentLoaded", function () { isStreaming = true; // First, call the /api/check_function_call endpoint + //"http://127.0.0.1:8000/api/check_function_call" + //"/api/check_function_call" fetch("/api/check_function_call", { method: "POST", headers: { @@ -87,6 +89,8 @@ document.addEventListener("DOMContentLoaded", function () { } // Now, call the /api/ask endpoint with the functions result + //"http://127.0.0.1:8000/api/ask" + //"/api/ask" return fetch("/api/ask", { method: "POST", headers: {