diff --git a/js/sdk/r2r-js-0.3.0.tgz b/js/sdk/r2r-js-0.3.0.tgz new file mode 100644 index 000000000..8327690dc Binary files /dev/null and b/js/sdk/r2r-js-0.3.0.tgz differ diff --git a/js/sdk/src/r2rClient.ts b/js/sdk/src/r2rClient.ts index 0bdc1c546..fb5c9e5d5 100644 --- a/js/sdk/src/r2rClient.ts +++ b/js/sdk/src/r2rClient.ts @@ -1156,7 +1156,7 @@ export class r2rClient { rag_generation_config?: GenerationConfig | Record, task_prompt_override?: string, include_title_if_available?: boolean, - ): Promise { + ): Promise> { this._ensureAuthenticated(); const json_data: Record = { @@ -1180,38 +1180,19 @@ export class r2rClient { } // TODO: can we remove this and pull this into rag? - @featureGenerator("streamingRag") - private async *streamRag( + @feature("streamingRag") + private async streamRag( rag_data: Record, - ): AsyncGenerator { + ): Promise> { this._ensureAuthenticated(); - const response = await this._makeRequest("POST", "rag", { + return this._makeRequest>("POST", "rag", { data: rag_data, headers: { "Content-Type": "application/json", }, responseType: "stream", }); - - if (!response.body) { - throw new Error("Response body is null"); - } - - const reader = response.body.getReader(); - const decoder = new TextDecoder(); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) { - break; - } - yield decoder.decode(value); - } - } finally { - reader.releaseLock(); - } } /** @@ -1232,7 +1213,7 @@ export class r2rClient { rag_generation_config?: GenerationConfig | Record, task_prompt_override?: string, include_title_if_available?: boolean, - ): Promise { + ): Promise> { this._ensureAuthenticated(); const json_data: Record = { @@ -1256,38 +1237,19 @@ export class r2rClient { } // TODO: can we remove this and pull this into agent? - @featureGenerator("streamingAgent") - private async *streamAgent( + @feature("streamingAgent") + private async streamAgent( agent_data: Record, - ): AsyncGenerator { + ): Promise> { this._ensureAuthenticated(); - const response = await this._makeRequest("POST", "agent", { + return this._makeRequest>("POST", "agent", { data: agent_data, headers: { "Content-Type": "application/json", }, responseType: "stream", }); - - if (!response.body) { - throw new Error("Response body is null"); - } - - const reader = response.body.getReader(); - const decoder = new TextDecoder(); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) { - break; - } - yield decoder.decode(value); - } - } finally { - reader.releaseLock(); - } } } diff --git a/py/core/main/engine.py b/py/core/main/engine.py index c9ae9c361..0a8dfc383 100644 --- a/py/core/main/engine.py +++ b/py/core/main/engine.py @@ -81,10 +81,6 @@ def __init__( async def aingest_documents(self, *args, **kwargs): return await self.ingestion_service.ingest_documents(*args, **kwargs) - @syncable - async def aupdate_documents(self, *args, **kwargs): - return await self.ingestion_service.update_documents(*args, **kwargs) - @syncable async def aingest_files(self, *args, **kwargs): return await self.ingestion_service.ingest_files(*args, **kwargs) @@ -109,10 +105,6 @@ async def arag(self, *args, **kwargs): async def arag_agent(self, *args, **kwargs): return await self.retrieval_service.agent(*args, **kwargs) - @syncable - async def aevaluate(self, *args, **kwargs): - return await self.retrieval_service.evaluate(*args, **kwargs) - @syncable async def aupdate_prompt(self, *args, **kwargs): return await self.management_service.update_prompt(*args, **kwargs) diff --git a/py/core/main/services/ingestion_service.py b/py/core/main/services/ingestion_service.py index ba1f5724c..f73adde6e 100644 --- a/py/core/main/services/ingestion_service.py +++ b/py/core/main/services/ingestion_service.py @@ -321,7 +321,7 @@ async def ingest_documents( logger.error("All provided documents already exist.") raise R2RException( status_code=409, - message="All provided documents already exist. Use the `update_documents` endpoint instead to update these documents.", + message="All provided documents already exist. Use the `update_files` endpoint instead to update these documents.", ) # Insert pending document info diff --git a/py/core/main/services/management_service.py b/py/core/main/services/management_service.py index af4108bf5..2e9239436 100644 --- a/py/core/main/services/management_service.py +++ b/py/core/main/services/management_service.py @@ -321,6 +321,18 @@ async def document_chunks( document_id, offset=offset, limit=limit ) + @telemetry_event("UpdatePrompt") + async def update_prompt( + self, + name: str, + template: Optional[str] = None, + input_types: Optional[dict[str, str]] = None, + ): + if input_types is None: + input_types = {} + self.providers.prompt.update_prompt(name, template, input_types) + return {"message": f"Prompt '{name}' updated successfully."} + @telemetry_event("UsersOverview") async def users_overview( self, diff --git a/py/core/providers/database/vecs/collection.py b/py/core/providers/database/vecs/collection.py index d3215168f..e1f09f18a 100644 --- a/py/core/providers/database/vecs/collection.py +++ b/py/core/providers/database/vecs/collection.py @@ -800,11 +800,8 @@ def parse_condition(key, value): else: # Handle JSON-based filters json_col = self.table.c.metadata - if not key.startswith("metadata."): - raise FilterError( - "metadata key must start with 'metadata.'" - ) - key = key.split("metadata.")[1] + if key.startswith("metadata."): + key.split("metadata.")[1] if isinstance(value, dict): if len(value) > 1: raise FilterError("only one operator permitted") diff --git a/py/core/providers/prompts/defaults/rag_agent.yaml b/py/core/providers/prompts/defaults/rag_agent.yaml index fe9caa250..a180b285b 100644 --- a/py/core/providers/prompts/defaults/rag_agent.yaml +++ b/py/core/providers/prompts/defaults/rag_agent.yaml @@ -6,7 +6,7 @@ rag_agent: When asked a question, perform a search to find relevant information and provide a response. - The response should contain line-item attributions to relevent search results, and be as informative if possible. + The response should contain line-item attributions to relevant search results, and be as informative if possible. If no relevant results are found, then state that no results were found. diff --git a/py/tests/regression/expected_outputs/test_document_management.json b/py/tests/regression/expected_outputs/test_document_management.json index 39c49fd88..74175a24f 100644 --- a/py/tests/regression/expected_outputs/test_document_management.json +++ b/py/tests/regression/expected_outputs/test_document_management.json @@ -203,7 +203,7 @@ } }, "reingest_sample_file": { - "results": "All provided documents already exist. Use the `update_documents` endpoint instead to update these documents." + "results": "All provided documents already exist. Use the `update_files` endpoint instead to update these documents." }, "documents_overview": { "results": [