Skip to content

Conversation

creatorrr
Copy link
Contributor

Summary

  • make vector field optional in docs search models
  • embed raw text automatically when vector search/hybrid search receives only text
  • adjust router logic and add new tests

Testing

  • ruff format agents-api/agents_api/routers/docs/search_docs.py agents-api/tests/test_docs_routes.py agents-api/agents_api/autogen/Docs.py
  • ruff check agents-api/agents_api/routers/docs/search_docs.py agents-api/tests/test_docs_routes.py agents-api/agents_api/autogen/Docs.py
  • pyright agents-api (fails: Import "ward" could not be resolved)

Copy link
Contributor

qodo-merge-for-open-source bot commented May 20, 2025

CI Feedback 🧐

(Feedback updated until commit 246f3a2)

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: Typecheck

Failed stage: Typecheck [❌]

Failure summary:

The action failed due to a type error in the get_doc_search.py file. Specifically, in the
get_search_fn_and_params function at line 113, there's a return type mismatch:

  • Expected: tuple[Any, Optional[dict[str, Union[dict[str, float], list[float], float, int, str]]]]
  • Actually returned: tuple[Any, dict[str, None]]

    The error was detected by the pytype static type checker which stopped the build process with error
    code 1.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    978:  prune-cache: true
    979:  ignore-nothing-to-cache: false
    980:  ##[endgroup]
    981:  Downloading uv from "https://github.com/astral-sh/uv/releases/download/0.7.6/uv-x86_64-unknown-linux-gnu.tar.gz" ...
    982:  [command]/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/cdda67a6-2171-48aa-8bee-e606a3926c04 -f /home/runner/work/_temp/72535195-0ae3-45c8-b496-02c23e4bccb3
    983:  Added /opt/hostedtoolcache/uv/0.7.6/x86_64 to the path
    984:  Added /home/runner/.local/bin to the path
    985:  Set UV_CACHE_DIR to /home/runner/work/_temp/setup-uv-cache
    986:  Successfully installed uv version 0.7.6
    987:  Searching files using cache dependency glob: **/uv.lock
    988:  /home/runner/work/julep/julep/agents-api/uv.lock
    989:  /home/runner/work/julep/julep/cli/uv.lock
    990:  /home/runner/work/julep/julep/integrations-service/uv.lock
    991:  Found 3 files to hash.
    992:  Trying to restore uv cache from GitHub Actions cache with key: setup-uv-1-x86_64-unknown-linux-gnu-0.7.6-d92603d25acef1c08e643c37cc2475e5e190deb9690356b084828d60043a591f
    993:  ##[warning]Failed to restore: Cache service responded with 422
    994:  No GitHub Actions cache found for key: setup-uv-1-x86_64-unknown-linux-gnu-0.7.6-d92603d25acef1c08e643c37cc2475e5e190deb9690356b084828d60043a591f
    ...
    
    1766:  [121/366] check agents_api.common.retry_policies
    1767:  [122/366] check agents_api.queries.secrets.delete
    1768:  [123/366] check agents_api.queries.__init__
    1769:  [124/366] check agents_api.dependencies.exceptions
    1770:  [125/366] check agents_api.queries.secrets.create
    1771:  [126/366] check agents_api.common.exceptions.secrets
    1772:  [127/366] check agents_api.queries.secrets.__init__
    1773:  [128/366] check agents_api.activities.pg_query_step
    1774:  [129/366] check agents_api.common.utils.usage
    1775:  [130/366] check agents_api.common.protocol.agents
    1776:  [131/366] check agents_api.common.utils.llm_providers
    1777:  [132/366] check agents_api.routers.docs.router
    1778:  [133/366] check agents_api.common.utils.secrets
    1779:  [134/366] check agents_api.dependencies.developer_id
    1780:  [135/366] check agents_api.common.utils.get_doc_search
    1781:  FAILED: /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/common/utils/get_doc_search.pyi 
    1782:  /home/runner/work/julep/julep/agents-api/.venv/bin/python -m pytype.main --disable pyi-error --imports_info /home/runner/work/julep/julep/agents-api/.pytype/imports/agents_api.common.utils.get_doc_search.imports --module-name agents_api.common.utils.get_doc_search --platform linux -V 3.12 -o /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/common/utils/get_doc_search.pyi --analyze-annotated --nofail --none-is-not-bool --quick --strict-none-binding /home/runner/work/julep/julep/agents-api/agents_api/common/utils/get_doc_search.py
    1783:  /home/runner/work/julep/julep/agents-api/agents_api/common/utils/get_doc_search.py:113:5: error: in get_search_fn_and_params: bad return type [bad-return-type]
    1784:  Expected: tuple[Any, Optional[dict[str, Union[dict[str, float], list[float], float, int, str]]]]
    1785:  Actually returned: tuple[Any, dict[str, None]]
    1786:  return search_fn, params
    1787:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1788:  For more details, see https://google.github.io/pytype/errors.html#bad-return-type
    1789:  [136/366] check agents_api.common.utils.mmr
    ...
    
    1908:  [255/366] check agents_api.worker.__init__
    1909:  [256/366] check tests.test_tool_call_step
    1910:  [257/366] check tests.test_litellm_utils
    1911:  [258/366] check tests.sample_tasks.__init__
    1912:  [259/366] check tests.__init__
    1913:  [260/366] check agents_api.common.utils.__init__
    1914:  [261/366] check agents_api.metrics.__init__
    1915:  [262/366] check agents_api.common.exceptions.agents
    1916:  [263/366] check tests.test_query_utils
    1917:  [264/366] check agents_api.rec_sum.entities
    1918:  [265/366] check agents_api.dependencies.content_length
    1919:  [266/366] check agents_api.dependencies.__init__
    1920:  [267/366] check agents_api.common.protocol.state_machine
    1921:  [268/366] check agents_api.common.utils.json
    1922:  [269/366] check tests.test_memory_utils
    1923:  ninja: build stopped: cannot make progress due to previous errors.
    1924:  Generated API key since not set in the environment: 38503504658774050789883420919864
    ...
    
    1977:  Generated API key since not set in the environment: 99195133755505251642953389219109
    1978:  Generated API key since not set in the environment: 97341487955949824024448775967872
    1979:  Generated API key since not set in the environment: 05598237087473397551951512955676
    1980:  Generated API key since not set in the environment: 02492658070239589407474637705686
    1981:  Generated API key since not set in the environment: 57227760802510921898595633467034
    1982:  Generated API key since not set in the environment: 37530962510763115385737981675640
    1983:  Generated API key since not set in the environment: 27919767024951227771966401054155
    1984:  Generated API key since not set in the environment: 96552915228050292986955481617630
    1985:  Generated API key since not set in the environment: 12469861414915301763659926377189
    1986:  Generated API key since not set in the environment: 16064772480965270565503675285894
    1987:  Generated API key since not set in the environment: 66531799058561684751155376096615
    1988:  Generated API key since not set in the environment: 06097611385056050386182643360682
    1989:  Generated API key since not set in the environment: 16156925986910380331251613276074
    1990:  Analyzing 353 sources with 0 local dependencies
    1991:  Leaving directory '.pytype'
    1992:  ##[error]Process completed with exit code 1.
    1993:  Post job cleanup.
    

    Comment on lines +43 to +56
    if not search_params.text:
    raise HTTPException(status_code=400, detail="text is required for vector search")
    [search_params.vector, *_] = await litellm.aembedding(
    inputs=search_params.text,
    embed_instruction="Represent the query for retrieving supporting documents: ",
    user=str(x_developer_id),
    )

    if isinstance(search_params, HybridDocSearchRequest) and search_params.vector is None:
    [search_params.vector, *_] = await litellm.aembedding(
    inputs=search_params.text,
    embed_instruction="Represent the query for retrieving supporting documents: ",
    user=str(x_developer_id),
    )
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    wouldn't the addition of the text field mess up the union type for search_param parameter? By introducing text to the vector search and making vector field optional.

    A suggestion would be adding a mode field to all search types to specify what type to use while searching.

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

    Labels

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants