Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch/fix ingestion #1339

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api-reference/openapi.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions py/core/main/api/data/ingestion_router_openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ingest_chunks:
source: |
from r2r import R2RClient

client = R2RClient("http://localhost:7272")
client = R2RClient("http://localhost:7272")
# when using auth, do client.login(...)

result = client.ingest_chunks(
Expand All @@ -76,12 +76,13 @@ ingest_chunks:
"text": "Another chunk of text",
},
{
"text": "Yet another chunk of text",
"text": "Yet another chunk of text",
},
{
"text": "A chunk of text",
},
], )
],
)
- lang: Shell
source: |
curl -X POST "https://api.example.com/ingest_chunks" \
Expand All @@ -96,7 +97,7 @@ ingest_chunks:
"text": "Yet another chunk of text"
},
{
"text": "A chunk of text"
"text": "A chunk of text"
}
],
"document_id": "b4ac4dd6-5f27-596e-a55b-7cf242ca30aa",
Expand All @@ -106,4 +107,4 @@ ingest_chunks:
input_descriptions:
chunks: "A list of text chunks to ingest into the system."
document_id: "An optional document id to associate the chunks with. If not provided, a unique document id will be generated."
metadata: "Optional JSON metadata to associate with the ingested chunks."
metadata: "Optional JSON metadata to associate with the ingested chunks."
10 changes: 7 additions & 3 deletions py/core/main/api/retrieval_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,16 @@ async def stream_generator():
except Exception as e:
raise R2RException(str(e), 500)


@self.router.post("/completion")
@self.base_endpoint
async def completion(
messages: list[Message] = Body(..., description="The messages to complete"),
generation_config: GenerationConfig = Body(default_factory=GenerationConfig, description="The generation config"),
messages: list[Message] = Body(
..., description="The messages to complete"
),
generation_config: GenerationConfig = Body(
default_factory=GenerationConfig,
description="The generation config",
),
auth_user=Depends(self.service.providers.auth.auth_wrapper),
response_model=WrappedCompletionResponse,
):
Expand Down
6 changes: 1 addition & 5 deletions py/core/main/orchestration/simple/ingestion_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ async def update_files(input_data):
"metadata": updated_metadata,
"document_id": str(doc_id),
"version": new_version,
"ingestion_config": (
ingestion_config.model_dump_json()
if ingestion_config
else None
),
"ingestion_config": ingestion_config,
"size_in_bytes": file_size_in_bytes,
"is_update": True,
}
Expand Down
2 changes: 1 addition & 1 deletion py/core/main/services/retrieval_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def search(
)

return results.as_dict()

@telemetry_event("Completion")
async def completion(
self,
Expand Down
2 changes: 1 addition & 1 deletion py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "r2r"
readme = "README.md"
version = "3.2.3"
version = "3.2.4"

description = "SciPhi R2R"
authors = ["Owen Colegrove <[email protected]>"]
Expand Down
3 changes: 1 addition & 2 deletions py/sdk/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ async def search(
}
return await client._make_request("POST", "search", json=data)


@staticmethod
async def completion(
client,
Expand All @@ -64,7 +63,7 @@ async def completion(
"messages": [msg.model_dump() for msg in cast_messages],
"generation_config": generation_config,
}

return await client._make_request("POST", "completion", json=data)

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion py/shared/api/models/retrieval/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from shared.abstractions.llm import LLMChatCompletion
from shared.api.models.base import ResultsWrapper


class SearchResponse(BaseModel):
vector_search_results: list[VectorSearchResult] = Field(
...,
Expand Down Expand Up @@ -138,8 +139,9 @@ class Config:
]
}


WrappedCompletionResponse = ResultsWrapper[LLMChatCompletion]
# Create wrapped versions of the responses
WrappedSearchResponse = ResultsWrapper[SearchResponse]
WrappedRAGResponse = ResultsWrapper[RAGResponse]
WrappedRAGAgentResponse = ResultsWrapper[RAGAgentResponse]
WrappedRAGAgentResponse = ResultsWrapper[RAGAgentResponse]
Loading