Skip to content

Commit

Permalink
new header
Browse files Browse the repository at this point in the history
  • Loading branch information
yachty66 committed Jul 3, 2024
1 parent b5e2417 commit f8b5dd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=["*"],
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions public/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit f8b5dd2

Please sign in to comment.