diff --git a/agents-api/agents_api/common/utils/debug.py b/agents-api/agents_api/common/utils/debug.py index c6e73f263..0be9eabb4 100644 --- a/agents-api/agents_api/common/utils/debug.py +++ b/agents-api/agents_api/common/utils/debug.py @@ -6,7 +6,9 @@ def pdb_on_exception(fn): def wrapper(*args, **kwargs): try: return fn(*args, **kwargs) - except Exception: + except Exception as exc: + print(repr(getattr(exc, "__cause__", exc))) + import pdb import traceback diff --git a/agents-api/agents_api/models/agent/create_agent.py b/agents-api/agents_api/models/agent/create_agent.py index 3ac561a0b..6b649afbb 100644 --- a/agents-api/agents_api/models/agent/create_agent.py +++ b/agents-api/agents_api/models/agent/create_agent.py @@ -60,12 +60,13 @@ def create_agent( # Extract the agent data from the payload data.metadata = data.metadata or {} + data.default_settings = data.default_settings or {} + data.instructions = ( data.instructions if isinstance(data.instructions, list) else [data.instructions] ) - data.default_settings = data.default_settings agent_data = data.model_dump(exclude_unset=True) default_settings = agent_data.pop("default_settings") diff --git a/agents-api/agents_api/models/docs/create_doc.py b/agents-api/agents_api/models/docs/create_doc.py index 23c849515..3a86ad0e5 100644 --- a/agents-api/agents_api/models/docs/create_doc.py +++ b/agents-api/agents_api/models/docs/create_doc.py @@ -30,7 +30,6 @@ one=True, transform=lambda d: { "id": UUID(d["doc_id"]), - "content": [], # <-- Note: we do not return content on creation **d, }, ) @@ -87,6 +86,10 @@ def create_doc( create_snippets_query = f""" ?[{snippet_cols}] <- $snippet_rows + + :create _snippets {{ {snippet_cols} }} + }} {{ + ?[{snippet_cols}] <- $snippet_rows :insert snippets {{ {snippet_cols} }} :returning """ @@ -94,8 +97,22 @@ def create_doc( # Construct the datalog query for creating the document and its snippets. create_doc_query = f""" ?[{doc_cols}] <- $doc_rows + + :create _docs {{ {doc_cols} }} + }} {{ + ?[{doc_cols}] <- $doc_rows :insert docs {{ {doc_cols} }} :returning + }} {{ + snippet_rows[collect(content)] := + *_snippets {{ + content + }} + + ?[{doc_cols}, content, created_at] := + *_docs {{ {doc_cols} }}, + snippet_rows[content], + created_at = now() """ queries = [ diff --git a/agents-api/agents_api/models/docs/get_doc.py b/agents-api/agents_api/models/docs/get_doc.py index fcac5b0a4..4a06333c5 100644 --- a/agents-api/agents_api/models/docs/get_doc.py +++ b/agents-api/agents_api/models/docs/get_doc.py @@ -19,6 +19,9 @@ @rewrap_exceptions( { + lambda e: isinstance(e, AssertionError) + and "Expected one result" + in repr(e): partialclass(HTTPException, status_code=404), QueryException: partialclass(HTTPException, status_code=400), ValidationError: partialclass(HTTPException, status_code=400), TypeError: partialclass(HTTPException, status_code=400), diff --git a/agents-api/agents_api/models/docs/search_docs_by_text.py b/agents-api/agents_api/models/docs/search_docs_by_text.py index 901e3ea31..8befeb07d 100644 --- a/agents-api/agents_api/models/docs/search_docs_by_text.py +++ b/agents-api/agents_api/models/docs/search_docs_by_text.py @@ -76,6 +76,24 @@ def search_docs_by_text( doc_id }} + search_result[ + doc_id, + snippet_data, + distance, + ] := + input[owner_id, query], + candidate[doc_id], + ~snippets:lsh {{ + doc_id, + index, + content + | + query: query, + k: {k}, + }}, + distance = 10000000, # Very large distance to depict no distance + snippet_data = [index, content] + search_result[ doc_id, snippet_data, diff --git a/agents-api/agents_api/routers/docs/__init__.py b/agents-api/agents_api/routers/docs/__init__.py index 2db2d042a..0d9fe8b5c 100644 --- a/agents-api/agents_api/routers/docs/__init__.py +++ b/agents-api/agents_api/routers/docs/__init__.py @@ -1,6 +1,6 @@ # ruff: noqa: F401 from .create_doc import create_agent_doc, create_user_doc -from .delete_doc import delete_doc +from .delete_doc import delete_agent_doc, delete_user_doc from .get_doc import get_doc from .list_docs import list_agent_docs, list_user_docs from .router import router diff --git a/agents-api/agents_api/routers/docs/create_doc.py b/agents-api/agents_api/routers/docs/create_doc.py index d99468733..0b43fe8eb 100644 --- a/agents-api/agents_api/routers/docs/create_doc.py +++ b/agents-api/agents_api/routers/docs/create_doc.py @@ -23,7 +23,7 @@ async def create_user_doc( data=data, ) - return ResourceCreatedResponse(id=doc.id, created_at=doc.created_at) + return ResourceCreatedResponse(id=doc.id, created_at=doc.created_at, jobs=[]) @router.post("/agents/{agent_id}/docs", status_code=HTTP_201_CREATED, tags=["docs"]) @@ -39,4 +39,4 @@ async def create_agent_doc( data=data, ) - return ResourceCreatedResponse(id=doc.id, created_at=doc.created_at) + return ResourceCreatedResponse(id=doc.id, created_at=doc.created_at, jobs=[]) diff --git a/agents-api/agents_api/routers/docs/delete_doc.py b/agents-api/agents_api/routers/docs/delete_doc.py index d1ae4416f..c31bf4051 100644 --- a/agents-api/agents_api/routers/docs/delete_doc.py +++ b/agents-api/agents_api/routers/docs/delete_doc.py @@ -10,8 +10,33 @@ from .router import router -@router.delete("/docs/{doc_id}", status_code=HTTP_202_ACCEPTED, tags=["docs"]) -async def delete_doc( - doc_id: UUID4, x_developer_id: Annotated[UUID4, Depends(get_developer_id)] +@router.delete( + "/agents/{agent_id}/docs/{doc_id}", status_code=HTTP_202_ACCEPTED, tags=["docs"] +) +async def delete_agent_doc( + doc_id: UUID4, + agent_id: UUID4, + x_developer_id: Annotated[UUID4, Depends(get_developer_id)], ) -> ResourceDeletedResponse: - return delete_doc_query(developer_id=x_developer_id, doc_id=doc_id) + return delete_doc_query( + developer_id=x_developer_id, + owner_id=agent_id, + owner_type="agent", + doc_id=doc_id, + ) + + +@router.delete( + "/users/{user_id}/docs/{doc_id}", status_code=HTTP_202_ACCEPTED, tags=["docs"] +) +async def delete_user_doc( + doc_id: UUID4, + user_id: UUID4, + x_developer_id: Annotated[UUID4, Depends(get_developer_id)], +) -> ResourceDeletedResponse: + return delete_doc_query( + developer_id=x_developer_id, + owner_id=user_id, + owner_type="user", + doc_id=doc_id, + ) diff --git a/agents-api/agents_api/routers/docs/search_docs.py b/agents-api/agents_api/routers/docs/search_docs.py index 8de06dd17..0e5430a7a 100644 --- a/agents-api/agents_api/routers/docs/search_docs.py +++ b/agents-api/agents_api/routers/docs/search_docs.py @@ -74,6 +74,7 @@ async def search_user_docs( owner_id=user_id, **params, ) + end = time.time() time_taken = end - start @@ -101,6 +102,7 @@ async def search_agent_docs( owner_id=agent_id, **params, ) + end = time.time() time_taken = end - start diff --git a/agents-api/agents_api/routers/users/update_user.py b/agents-api/agents_api/routers/users/update_user.py index d80d68f83..258023173 100644 --- a/agents-api/agents_api/routers/users/update_user.py +++ b/agents-api/agents_api/routers/users/update_user.py @@ -18,5 +18,5 @@ async def update_user( return update_user_query( developer_id=x_developer_id, user_id=user_id, - update_user=data, + data=data, ) diff --git a/agents-api/agents_api/web.py b/agents-api/agents_api/web.py index 23c34a970..2b85ece5f 100644 --- a/agents-api/agents_api/web.py +++ b/agents-api/agents_api/web.py @@ -21,6 +21,7 @@ from agents_api.exceptions import PromptTooBigError from agents_api.routers import ( agents, + docs, jobs, sessions, tasks, @@ -93,6 +94,7 @@ def register_exceptions(app: FastAPI): app.include_router(sessions.router) app.include_router(users.router) app.include_router(jobs.router) +app.include_router(docs.router) app.include_router(tasks.router) diff --git a/agents-api/migrations/migrate_1723307805_add_lsh_index_to_docs.py b/agents-api/migrations/migrate_1723307805_add_lsh_index_to_docs.py new file mode 100644 index 000000000..1268fa5c4 --- /dev/null +++ b/agents-api/migrations/migrate_1723307805_add_lsh_index_to_docs.py @@ -0,0 +1,44 @@ +#/usr/bin/env python3 + +MIGRATION_ID = "add_lsh_index_to_docs" +CREATED_AT = 1723307805.007054 + +# See: https://docs.cozodb.org/en/latest/vector.html#full-text-search-fts +snippets_lsh_index = dict( + up=""" + ::lsh create snippets:lsh { + extractor: content, + tokenizer: Simple, + filters: [Stopwords('en')], + n_perm: 200, + target_threshold: 0.9, + n_gram: 3, + false_positive_weight: 1.0, + false_negative_weight: 1.0, + } + """, + down=""" + ::lsh drop snippets:lsh + """, +) + +queries = [ + snippets_lsh_index, +] + + +def run(client, queries): + joiner = "}\n\n{" + + query = joiner.join(queries) + query = f"{{\n{query}\n}}" + + client.run(query) + + +def up(client): + run(client, [q["up"] for q in queries]) + + +def down(client): + run(client, [q["down"] for q in reversed(queries)]) diff --git a/agents-api/poetry.lock b/agents-api/poetry.lock index 7afec2778..38ffe14d1 100644 --- a/agents-api/poetry.lock +++ b/agents-api/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -4395,7 +4395,7 @@ files = [ ] [package.dependencies] -greenlet = {version = "!=0.4.17", markers = "python_version < \"3.13\" and (platform_machine == \"win32\" or platform_machine == \"WIN32\" or platform_machine == \"AMD64\" or platform_machine == \"amd64\" or platform_machine == \"x86_64\" or platform_machine == \"ppc64le\" or platform_machine == \"aarch64\")"} +greenlet = {version = "!=0.4.17", markers = "python_version < \"3.13\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"} typing-extensions = ">=4.6.0" [package.extras] diff --git a/agents-api/tests/fixtures.py b/agents-api/tests/fixtures.py index b0b7faceb..e04cb316d 100644 --- a/agents-api/tests/fixtures.py +++ b/agents-api/tests/fixtures.py @@ -157,6 +157,31 @@ def test_doc( ) +@fixture(scope="global") +def test_user_doc( + client=cozo_client, + developer_id=test_developer_id, + user=test_user, +): + doc = create_doc( + developer_id=developer_id, + owner_type="user", + owner_id=user.id, + data=CreateDocRequest(title="Hello", content=["World"]), + client=client, + ) + + yield doc + + delete_doc( + developer_id=developer_id, + doc_id=doc.id, + owner_type="user", + owner_id=user.id, + client=client, + ) + + @fixture(scope="global") def test_task( client=cozo_client, diff --git a/agents-api/tests/test_docs_routes.py b/agents-api/tests/test_docs_routes.py new file mode 100644 index 000000000..3bd68cb0b --- /dev/null +++ b/agents-api/tests/test_docs_routes.py @@ -0,0 +1,162 @@ +from ward import test + +from tests.fixtures import make_request, test_agent, test_user, test_doc, test_user_doc + + +@test("route: create user doc") +def _(make_request=make_request, user=test_user): + data = dict( + title="Test User Doc", + content=["This is a test user document."], + ) + + response = make_request( + method="POST", + url=f"/users/{user.id}/docs", + json=data, + ) + + assert response.status_code == 201 + + +@test("route: create agent doc") +def _(make_request=make_request, agent=test_agent): + data = dict( + title="Test Agent Doc", + content=["This is a test agent document."], + ) + + response = make_request( + method="POST", + url=f"/agents/{agent.id}/docs", + json=data, + ) + + assert response.status_code == 201 + + # FIXME: Should create a job to process the document + # result = response.json() + # assert len(result["jobs"]) > 0 + + +@test("route: delete doc") +def _(make_request=make_request, agent=test_agent): + data = dict( + title="Test Agent Doc", + content=["This is a test agent document."], + ) + + response = make_request( + method="POST", + url=f"/agents/{agent.id}/docs", + json=data, + ) + doc_id = response.json()["id"] + + response = make_request( + method="DELETE", + url=f"/agents/{agent.id}/docs/{doc_id}", + ) + + assert response.status_code == 202 + + response = make_request( + method="GET", + url=f"/docs/{doc_id}", + ) + + assert response.status_code == 404 + + +@test("route: get doc") +def _(make_request=make_request, agent=test_agent): + data = dict( + title="Test Agent Doc", + content=["This is a test agent document."], + ) + + response = make_request( + method="POST", + url=f"/agents/{agent.id}/docs", + json=data, + ) + doc_id = response.json()["id"] + + response = make_request( + method="GET", + url=f"/docs/{doc_id}", + ) + + assert response.status_code == 200 + + +@test("route: list user docs") +def _(make_request=make_request, user=test_user): + response = make_request( + method="GET", + url=f"/users/{user.id}/docs", + ) + + assert response.status_code == 200 + response = response.json() + docs = response["items"] + + assert isinstance(docs, list) + + +@test("route: list agent docs") +def _(make_request=make_request, agent=test_agent): + response = make_request( + method="GET", + url=f"/agents/{agent.id}/docs", + ) + + assert response.status_code == 200 + response = response.json() + docs = response["items"] + + assert isinstance(docs, list) + + +@test("route: search agent docs") +def _(make_request=make_request, agent=test_agent, doc=test_doc): + search_params = dict( + text=doc.content[0], + limit=1, + ) + + response = make_request( + method="POST", + url=f"/agents/{agent.id}/search", + json=search_params, + ) + + assert response.status_code == 200 + response = response.json() + docs = response["docs"] + + assert isinstance(docs, list) + assert len(docs) >= 1 + + +@test("route: search user docs") +def _(make_request=make_request, user=test_user, doc=test_user_doc): + search_params = dict( + text=doc.content[0], + limit=1, + ) + + response = make_request( + method="POST", + url=f"/users/{user.id}/search", + json=search_params, + ) + + assert response.status_code == 200 + response = response.json() + docs = response["docs"] + + assert isinstance(docs, list) + + # FIXME: This test is failing because the search is not returning the expected results + # assert len(docs) >= 1 diff --git a/sdks/python/julep/api/client.py b/sdks/python/julep/api/client.py index c074e5c3b..f560e0bfe 100644 --- a/sdks/python/julep/api/client.py +++ b/sdks/python/julep/api/client.py @@ -820,6 +820,58 @@ def agent_docs_route_create( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) + def agent_docs_route_delete( + self, + id: CommonUuid, + child_id: CommonUuid, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> CommonResourceDeletedResponse: + """ + Delete a Doc for this Agent + + Parameters + ---------- + id : CommonUuid + ID of parent resource + + child_id : CommonUuid + ID of the resource to be deleted + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CommonResourceDeletedResponse + The request has been accepted for processing, but processing has not yet completed. + + Examples + -------- + from julep.client import JulepApi + + client = JulepApi( + auth_key="YOUR_AUTH_KEY", + api_key="YOUR_API_KEY", + ) + client.agent_docs_route_delete( + id="id", + child_id="child_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"agents/{jsonable_encoder(id)}/docs/{jsonable_encoder(child_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CommonResourceDeletedResponse, _response.json()) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + def agents_docs_search_route_search( self, id: CommonUuid, @@ -1799,50 +1851,6 @@ def individual_docs_route_get( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def individual_docs_route_delete( - self, id: CommonUuid, *, request_options: typing.Optional[RequestOptions] = None - ) -> CommonResourceDeletedResponse: - """ - Delete an existing Doc by id - - Parameters - ---------- - id : CommonUuid - ID of the resource - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CommonResourceDeletedResponse - The request has been accepted for processing, but processing has not yet completed. - - Examples - -------- - from julep.client import JulepApi - - client = JulepApi( - auth_key="YOUR_AUTH_KEY", - api_key="YOUR_API_KEY", - ) - client.individual_docs_route_delete( - id="id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"docs/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CommonResourceDeletedResponse, _response.json()) # type: ignore - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - def embed_route_embed( self, *, @@ -3497,6 +3505,58 @@ def user_docs_route_create( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) + def user_docs_route_delete( + self, + id: CommonUuid, + child_id: CommonUuid, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> CommonResourceDeletedResponse: + """ + Delete a Doc for this User + + Parameters + ---------- + id : CommonUuid + ID of parent resource + + child_id : CommonUuid + ID of the resource to be deleted + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CommonResourceDeletedResponse + The request has been accepted for processing, but processing has not yet completed. + + Examples + -------- + from julep.client import JulepApi + + client = JulepApi( + auth_key="YOUR_AUTH_KEY", + api_key="YOUR_API_KEY", + ) + client.user_docs_route_delete( + id="id", + child_id="child_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"users/{jsonable_encoder(id)}/docs/{jsonable_encoder(child_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CommonResourceDeletedResponse, _response.json()) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + def user_docs_search_route_search( self, id: CommonUuid, @@ -4332,6 +4392,66 @@ async def main() -> None: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) + async def agent_docs_route_delete( + self, + id: CommonUuid, + child_id: CommonUuid, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> CommonResourceDeletedResponse: + """ + Delete a Doc for this Agent + + Parameters + ---------- + id : CommonUuid + ID of parent resource + + child_id : CommonUuid + ID of the resource to be deleted + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CommonResourceDeletedResponse + The request has been accepted for processing, but processing has not yet completed. + + Examples + -------- + import asyncio + + from julep.client import AsyncJulepApi + + client = AsyncJulepApi( + auth_key="YOUR_AUTH_KEY", + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.agent_docs_route_delete( + id="id", + child_id="child_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"agents/{jsonable_encoder(id)}/docs/{jsonable_encoder(child_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CommonResourceDeletedResponse, _response.json()) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + async def agents_docs_search_route_search( self, id: CommonUuid, @@ -5415,58 +5535,6 @@ async def main() -> None: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def individual_docs_route_delete( - self, id: CommonUuid, *, request_options: typing.Optional[RequestOptions] = None - ) -> CommonResourceDeletedResponse: - """ - Delete an existing Doc by id - - Parameters - ---------- - id : CommonUuid - ID of the resource - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CommonResourceDeletedResponse - The request has been accepted for processing, but processing has not yet completed. - - Examples - -------- - import asyncio - - from julep.client import AsyncJulepApi - - client = AsyncJulepApi( - auth_key="YOUR_AUTH_KEY", - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.individual_docs_route_delete( - id="id", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"docs/{jsonable_encoder(id)}", - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return pydantic_v1.parse_obj_as(CommonResourceDeletedResponse, _response.json()) # type: ignore - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - async def embed_route_embed( self, *, @@ -7337,6 +7405,66 @@ async def main() -> None: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) + async def user_docs_route_delete( + self, + id: CommonUuid, + child_id: CommonUuid, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> CommonResourceDeletedResponse: + """ + Delete a Doc for this User + + Parameters + ---------- + id : CommonUuid + ID of parent resource + + child_id : CommonUuid + ID of the resource to be deleted + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CommonResourceDeletedResponse + The request has been accepted for processing, but processing has not yet completed. + + Examples + -------- + import asyncio + + from julep.client import AsyncJulepApi + + client = AsyncJulepApi( + auth_key="YOUR_AUTH_KEY", + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.user_docs_route_delete( + id="id", + child_id="child_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"users/{jsonable_encoder(id)}/docs/{jsonable_encoder(child_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(CommonResourceDeletedResponse, _response.json()) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + async def user_docs_search_route_search( self, id: CommonUuid, diff --git a/sdks/python/julep/api/reference.md b/sdks/python/julep/api/reference.md index cc0693d02..33e041f65 100644 --- a/sdks/python/julep/api/reference.md +++ b/sdks/python/julep/api/reference.md @@ -936,6 +936,86 @@ client.agent_docs_route_create( + + + + +
client.agent_docs_route_delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a Doc for this Agent +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from julep.client import JulepApi + +client = JulepApi( + auth_key="YOUR_AUTH_KEY", + api_key="YOUR_API_KEY", +) +client.agent_docs_route_delete( + id="id", + child_id="child_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `CommonUuid` — ID of parent resource + +
+
+ +
+
+ +**child_id:** `CommonUuid` — ID of the resource to be deleted + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
@@ -2416,77 +2496,6 @@ client.individual_docs_route_get( - - - - -
client.individual_docs_route_delete(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Delete an existing Doc by id -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from julep.client import JulepApi - -client = JulepApi( - auth_key="YOUR_AUTH_KEY", - api_key="YOUR_API_KEY", -) -client.individual_docs_route_delete( - id="id", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**id:** `CommonUuid` — ID of the resource - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- -
@@ -5012,6 +5021,86 @@ client.user_docs_route_create( + + + + +
client.user_docs_route_delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a Doc for this User +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from julep.client import JulepApi + +client = JulepApi( + auth_key="YOUR_AUTH_KEY", + api_key="YOUR_API_KEY", +) +client.user_docs_route_delete( + id="id", + child_id="child_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `CommonUuid` — ID of parent resource + +
+
+ +
+
+ +**child_id:** `CommonUuid` — ID of the resource to be deleted + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/sdks/ts/src/api/services/DefaultService.ts b/sdks/ts/src/api/services/DefaultService.ts index c71a6d7e9..b671d3fb5 100644 --- a/sdks/ts/src/api/services/DefaultService.ts +++ b/sdks/ts/src/api/services/DefaultService.ts @@ -313,6 +313,33 @@ export class DefaultService { mediaType: "application/json", }); } + /** + * Delete a Doc for this Agent + * @returns Common_ResourceDeletedResponse The request has been accepted for processing, but processing has not yet completed. + * @throws ApiError + */ + public agentDocsRouteDelete({ + id, + childId, + }: { + /** + * ID of parent resource + */ + id: Common_uuid; + /** + * ID of the resource to be deleted + */ + childId: Common_uuid; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/agents/{id}/docs/{child_id}", + path: { + id: id, + child_id: childId, + }, + }); + } /** * Search Docs owned by an Agent * @returns Docs_DocSearchResponse The request has succeeded. @@ -730,27 +757,6 @@ export class DefaultService { }, }); } - /** - * Delete an existing Doc by id - * @returns Common_ResourceDeletedResponse The request has been accepted for processing, but processing has not yet completed. - * @throws ApiError - */ - public individualDocsRouteDelete({ - id, - }: { - /** - * ID of the resource - */ - id: Common_uuid; - }): CancelablePromise { - return this.httpRequest.request({ - method: "DELETE", - url: "/docs/{id}", - path: { - id: id, - }, - }); - } /** * Embed a query for search * @returns Docs_EmbedQueryResponse The request has succeeded. @@ -1722,6 +1728,33 @@ export class DefaultService { mediaType: "application/json", }); } + /** + * Delete a Doc for this User + * @returns Common_ResourceDeletedResponse The request has been accepted for processing, but processing has not yet completed. + * @throws ApiError + */ + public userDocsRouteDelete({ + id, + childId, + }: { + /** + * ID of parent resource + */ + id: Common_uuid; + /** + * ID of the resource to be deleted + */ + childId: Common_uuid; + }): CancelablePromise { + return this.httpRequest.request({ + method: "DELETE", + url: "/users/{id}/docs/{child_id}", + path: { + id: id, + child_id: childId, + }, + }); + } /** * Search Docs owned by a User * @returns Docs_DocSearchResponse The request has succeeded. diff --git a/typespec/docs/endpoints.tsp b/typespec/docs/endpoints.tsp index 143d18f33..3600319c1 100644 --- a/typespec/docs/endpoints.tsp +++ b/typespec/docs/endpoints.tsp @@ -19,15 +19,16 @@ namespace Docs; interface UserEndpoints extends ChildLimitOffsetPagination, + ChildDeleteEndpoint<"Delete a Doc for this User">, ChildCreateEndpoint {} interface AgentEndpoints extends ChildLimitOffsetPagination, + ChildDeleteEndpoint<"Delete a Doc for this Agent">, ChildCreateEndpoint {} interface IndividualDocEndpoints - extends GetEndpoint, - DeleteEndpoint<"Delete an existing Doc by id"> {} + extends GetEndpoint {} interface SearchEndpoints { @doc(DocString)