Skip to content

Commit

Permalink
Addressing review
Browse files Browse the repository at this point in the history
  • Loading branch information
onmete committed Dec 12, 2024
1 parent 5f242a7 commit 756e359
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 15 additions & 3 deletions ols/app/endpoints/ols.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,20 @@ def conversation_request(
)


def process_request(auth: Any, llm_request: LLMRequest):
"""Process incoming request."""
def process_request(
auth: Any, llm_request: LLMRequest
) -> tuple[str, str, str, list[CacheEntry], list[Attachment], bool, dict[str, float]]:
"""Process incoming request.
Args:
auth: The Authentication handler (FastAPI Depends) that will handle authentication Logic.
llm_request: The request containing a query, conversation ID, and optional attachments.
Returns:
Tuple containing the processed information.
User ID, conversation ID, query without attachments, previous input,
attachments, validation result and timestamps.
"""
timestamps = {"start": time.time()}

user_id = retrieve_user_id(auth)
Expand Down Expand Up @@ -335,7 +347,7 @@ def generate_response(
response = docs_summarizer.create_response(
llm_request.query, config.rag_index, history
)
logger.debug(f"{conversation_id} Generated response: {response}")
logger.debug("%s Generated response: %s", conversation_id, response)
return response
except PromptTooLongError as summarizer_error:
logger.error("Prompt is too long: %s", summarizer_error)
Expand Down
6 changes: 4 additions & 2 deletions ols/src/query_helpers/question_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def validate_question(
verbose=verbose,
)

logger.debug(f"{conversation_id} validating user query: {query}")
logger.debug("%s validating user query: %s", conversation_id, query)

with TokenMetricUpdater(
llm=bare_llm,
Expand All @@ -86,7 +86,9 @@ def validate_question(
)
clean_response = str(response["text"]).strip()

logger.debug(f"{conversation_id} query validation response: {clean_response}")
logger.debug(
"%s query validation response: %s", conversation_id, clean_response
)

# Default to be permissive(allow the question) if we don't get a clean
# rejection from the LLM.
Expand Down

0 comments on commit 756e359

Please sign in to comment.