Skip to content

Conversation

@blefo
Copy link
Member

@blefo blefo commented Nov 13, 2025

No description provided.

@blefo blefo requested a review from Copilot November 13, 2025 13:10
Copilot finished reviewing on behalf of blefo November 13, 2025 13:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@blefo blefo requested a review from Copilot November 13, 2025 14:20
Copilot finished reviewing on behalf of blefo November 13, 2025 14:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@blefo blefo marked this pull request as ready for review November 14, 2025 15:45
@blefo blefo requested a review from Copilot November 26, 2025 09:22
Copilot finished reviewing on behalf of blefo November 26, 2025 09:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

nilai-api/src/nilai_api/handlers/web_search.py:106

  • The docstring is missing documentation for the new request parameter. Please add it to the Args section:
Args:
    query: The search query string to execute
    request: FastAPI request object for rate limiting
async def _make_brave_api_request(query: str, request: Request) -> Dict[str, Any]:
    """Make an API request to the Brave Search API.

    Args:
        query: The search query string to execute

    Returns:
        Dict containing the raw API response data

    Raises:
        HTTPException: If API key is missing or API request fails
    """

nilai-api/src/nilai_api/handlers/web_search.py:245

  • The docstring is incomplete and missing documentation for the new request parameter. The function should have a complete docstring including Args, Returns, and Raises sections. Please update it:
"""Perform an asynchronous web search using the Brave Search API.

Fetches only the exact page for each Brave URL and extracts its
main content with trafilatura. If extraction fails, falls back to
the Brave snippet.

Args:
    query: The search query string to execute
    request: FastAPI request object for rate limiting

Returns:
    WebSearchContext with formatted search results and source information

Raises:
    HTTPException: If no results are found (404) or if the API request fails
"""
async def perform_web_search_async(query: str, request: Request) -> WebSearchContext:
    """Perform an asynchronous web search using the Brave Search API.

    Fetches only the exact page for each Brave URL and extracts its
    main content with trafilatura. If extraction fails, falls back to
    the Brave snippet.
    """

nilai-api/src/nilai_api/handlers/web_search.py:728

  • The docstring is missing documentation for the new request parameter. Please add it to the Args section:
Args:
    req: ResponseRequest containing input to process
    model_name: Name of the LLM model to use for query generation
    client: LLM client instance for making API calls
    request: FastAPI request object for rate limiting
async def handle_web_search_for_responses(
    req: ResponseRequest, model_name: str, client: Any, request: Request
) -> WebSearchEnhancedInput:
    """Handle web search enhancement for response requests.

    Analyzes the user's input to identify topics that require web search,
    generates optimized search queries for each topic using an LLM, and
    enhances the request with relevant web search results. Falls back to
    single-query search if topic analysis fails or no topics need search.

    Args:
        req: ResponseRequest containing input to process
        model_name: Name of the LLM model to use for query generation
        client: LLM client instance for making API calls

    Returns:
        WebSearchEnhancedInput with web search context added, or original
        input if no user query is found or search fails
    """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

async def handle_web_search(
req_messages: ChatRequest, model_name: str, client: Any
req_messages: ChatRequest, model_name: str, client: Any, request: Request
) -> WebSearchEnhancedMessages:
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is missing a docstring. Please add comprehensive documentation that includes the new request parameter:

"""Handle web search enhancement for chat requests.

Analyzes the user's message to identify topics that require web search,
generates optimized search queries for each topic using an LLM, and
enhances the request with relevant web search results. Falls back to
single-query search if topic analysis fails or no topics need search.

Args:
    req_messages: ChatRequest containing conversation messages
    model_name: Name of the LLM model to use for query generation
    client: LLM client instance for making API calls
    request: FastAPI request object for rate limiting

Returns:
    WebSearchEnhancedMessages with web search context added, or original
    messages if no user query is found or search fails
"""
Suggested change
) -> WebSearchEnhancedMessages:
) -> WebSearchEnhancedMessages:
"""
Handle web search enhancement for chat requests.
Analyzes the user's message to identify topics that require web search,
generates optimized search queries for each topic using an LLM, and
enhances the request with relevant web search results. Falls back to
single-query search if topic analysis fails or no topics need search.
Args:
req_messages: ChatRequest containing conversation messages
model_name: Name of the LLM model to use for query generation
client: LLM client instance for making API calls
request: FastAPI request object for rate limiting
Returns:
WebSearchEnhancedMessages with web search context added, or original
messages if no user query is found or search fails
"""

Copilot uses AI. Check for mistakes.
@blefo blefo force-pushed the fix-websearch-limit-reddis branch from fdff362 to 08362d4 Compare November 26, 2025 09:41
@blefo blefo requested a review from jcabrero November 26, 2025 10:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants