Skip to content

Commit

Permalink
refactor: set content-type:application/json header in reponses
Browse files Browse the repository at this point in the history
Signed-off-by: Xin Liu <[email protected]>
  • Loading branch information
apepkuss committed May 11, 2024
1 parent 8dd717a commit e0e74f4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/backend/ggml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub(crate) async fn models_handler() -> Result<Response<Body>, hyper::Error> {
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand Down Expand Up @@ -98,6 +99,7 @@ async fn chat_completions(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));

match result {
Expand Down Expand Up @@ -133,6 +135,7 @@ pub(crate) async fn embeddings_handler(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand Down Expand Up @@ -174,6 +177,7 @@ pub(crate) async fn _rag_doc_chunks_to_embeddings_handler(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand Down Expand Up @@ -237,6 +241,7 @@ pub(crate) async fn _rag_doc_chunks_to_embeddings2_handler(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand All @@ -262,6 +267,7 @@ pub(crate) async fn rag_query_handler(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::empty());

match result {
Expand Down Expand Up @@ -678,6 +684,7 @@ pub(crate) async fn files_handler(req: Request<Body>) -> Result<Response<Body>,
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));

match result {
Expand Down Expand Up @@ -785,6 +792,7 @@ pub(crate) async fn chunks_handler(mut req: Request<Body>) -> Result<Response<Bo
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand Down Expand Up @@ -1031,6 +1039,7 @@ pub(crate) async fn doc_to_embeddings(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand Down Expand Up @@ -1065,6 +1074,7 @@ pub(crate) async fn server_info() -> Result<Response<Body>, hyper::Error> {
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));
match result {
Ok(response) => Ok(response),
Expand All @@ -1080,6 +1090,7 @@ pub(crate) async fn retrieve_handler(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::empty());

match result {
Expand Down Expand Up @@ -1203,6 +1214,7 @@ pub(crate) async fn retrieve_handler(
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "*")
.header("Access-Control-Allow-Headers", "*")
.header("Content-Type", "application/json")
.body(Body::from(s));

match result {
Expand Down

0 comments on commit e0e74f4

Please sign in to comment.