Skip to content

Commit

Permalink
feature: update environment variable in needed locations
Browse files Browse the repository at this point in the history
  • Loading branch information
cdxker authored and skeptrunedev committed Dec 6, 2024
1 parent 23fc3a2 commit ec6b279
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env.server
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ FIRECRAWL_URL=https://api.firecrawl.dev
FIRECRAWL_API_KEY=fc-abdef**************
PDF2MD_URL="http://localhost:8081"
BATCH_CHUNK_LIMIT=120
CHAT_COMPLETION_TIMEOUT_SECS=10
1 change: 1 addition & 0 deletions helm/templates/backend-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ data:
FIRECRAWL_URL: {{ .Values.config.trieve.firecrawlUrl | quote }}
DITTOFEED_API_KEY: {{ .Values.config.trieve.dittofeedApiKey | quote }}
CREATE_QDRANT_COLLECTIONS: {{ .Values.config.qdrant.initCollections | quote }}
CHAT_COMPLETION_TIMEOUT_SECS: {{ .Values.config.trieve.chatCompletionTimeoutSecs | quote }}
1 change: 1 addition & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ config:
batch_size: 10000
trieve:
batch_limit: 120
chatCompletionTimeoutSecs: 10
bm25Active: true
unlimited: true
cookieSecure: false
Expand Down
8 changes: 5 additions & 3 deletions server/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ impl ResponseError for ServiceError {
ServiceError::Forbidden => HttpResponse::Forbidden().json(ErrorResponseBody {
message: "Forbidden".to_string(),
}),
ServiceError::RequestTimeout(ref message) => HttpResponse::RequestTimeout().json(ErrorResponseBody {
message: message.to_string(),
}),
ServiceError::RequestTimeout(ref message) => {
HttpResponse::RequestTimeout().json(ErrorResponseBody {
message: message.to_string(),
})
}
ServiceError::NotFound(ref message) => {
HttpResponse::NotFound().json(ErrorResponseBody {
message: format!("Not Found: {}", message),
Expand Down
7 changes: 6 additions & 1 deletion server/src/operators/message_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,14 @@ pub async fn stream_response(
let _ = create_messages_query(vec![new_message], &pool).await;
});

let chat_completion_timeout = std::env::var("CHAT_COMPLETION_TIMEOUT_SECS")
.unwrap_or("10".to_string())
.parse::<u64>()
.unwrap_or(10);

let chunk_stream = stream::iter(vec![Ok(Bytes::from(chunk_metadatas_stringified1))]);
let completion_stream = stream
.take_until(tokio::time::sleep(std::time::Duration::from_secs(10)))
.take_until(tokio::time::sleep(std::time::Duration::from_secs(chat_completion_timeout)))
.map(move |response| -> Result<Bytes, actix_web::Error> {
if let Ok(response) = response {
let chat_content = response
Expand Down

0 comments on commit ec6b279

Please sign in to comment.