Skip to content

Commit

Permalink
fixes in sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
NolanTrem committed Aug 16, 2024
1 parent e274ae1 commit 9965e12
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 43 deletions.
2 changes: 0 additions & 2 deletions r2r/base/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from .management.responses import (
AnalyticsResponse,
AppSettingsResponse,
DeleteResponse,
DocumentChunkResponse,
DocumentOverviewResponse,
GroupOverviewResponse,
Expand Down Expand Up @@ -61,7 +60,6 @@
"AppSettingsResponse",
"ScoreCompletionResponse",
"UserOverviewResponse",
"DeleteResponse",
"DocumentOverviewResponse",
"DocumentChunkResponse",
"KnowledgeGraphResponse",
Expand Down
25 changes: 15 additions & 10 deletions r2r/main/api/client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@ async def register(client, email: str, password: str) -> UserResponse:
data = {"email": email, "password": password}
return await client._make_request("POST", "register", json=data)

async def verify_email(client, verification_code: str) -> dict:
async def verify_email(self, client, verification_code: str) -> dict:
return await client._make_request(
"POST",
"verify_email",
json={"verification_code": verification_code},
)

async def login(client, email: str, password: str) -> dict[str, Token]:
async def login(
self, client, email: str, password: str
) -> dict[str, Token]:
data = {"username": email, "password": password}
response = await client._make_request("POST", "login", data=data)
client.access_token = response["results"]["access_token"]["token"]
client._refresh_token = response["results"]["refresh_token"]["token"]
return response["results"]

async def user(client) -> UserResponse:
async def user(self, client) -> UserResponse:
return await client._make_request("GET", "user")

async def refresh_access_token(client) -> dict[str, Token]:
async def refresh_access_token(self, client) -> dict[str, Token]:
data = {"refresh_token": client._refresh_token}
response = await client._make_request(
"POST", "refresh_access_token", json=data
Expand All @@ -38,35 +40,38 @@ async def refresh_access_token(client) -> dict[str, Token]:
return response["results"]

async def change_password(
client, current_password: str, new_password: str
self, client, current_password: str, new_password: str
) -> dict:
data = {
"current_password": current_password,
"new_password": new_password,
}
return await client._make_request("POST", "change_password", json=data)

async def request_password_reset(client, email: str) -> dict:
async def request_password_reset(self, client, email: str) -> dict:
return await client._make_request(
"POST", "request_password_reset", json={"email": email}
)

async def confirm_password_reset(
client, reset_token: str, new_password: str
self, client, reset_token: str, new_password: str
) -> dict:
data = {"reset_token": reset_token, "new_password": new_password}
return await client._make_request("POST", "reset_password", json=data)

async def logout(client) -> dict:
async def logout(self, client) -> dict:
response = await client._make_request("POST", "logout")
client.access_token = None
client._refresh_token = None
return response

async def get_user_profile(client, user_id: uuid.UUID) -> UserResponse:
async def get_user_profile(
self, client, user_id: uuid.UUID
) -> UserResponse:
return await client._make_request("GET", f"user/{user_id}")

async def update_user(
self,
client,
email: Optional[str] = None,
name: Optional[str] = None,
Expand All @@ -83,7 +88,7 @@ async def update_user(
return await client._make_request("PUT", "user", json=data)

async def delete_user(
client, user_id: uuid.UUID, password: Optional[str] = None
self, client, user_id: uuid.UUID, password: Optional[str] = None
) -> dict:
data = {"user_id": str(user_id), "password": password}
response = await client._make_request("DELETE", "user", json=data)
Expand Down
30 changes: 0 additions & 30 deletions r2r/main/api/client/ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,36 +163,6 @@ async def update_files(
"POST", "update_files", data=data, files=files
)

@staticmethod
async def get_document_info(client, document_id: str) -> dict:
"""
Retrieve information about a specific document.
Args:
document_id (str): The ID of the document to retrieve information for.
Returns:
dict: Document information including metadata, status, and version.
"""
return await client._make_request(
"GET", f"document_info/{document_id}"
)

@staticmethod
async def delete_document(client, document_id: str) -> dict:
"""
Delete a specific document from the system.
Args:
document_id (str): The ID of the document to delete.
Returns:
dict: Confirmation of document deletion.
"""
return await client._make_request(
"DELETE", f"delete_document/{document_id}"
)

@staticmethod
async def list_documents(
client,
Expand Down
5 changes: 4 additions & 1 deletion r2r/main/api/client/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ async def update_prompt(
client,
name: str,
template: Optional[str] = None,
input_types: Optional[dict[str, str]] = {},
input_types: Optional[dict[str, str]] = None,
) -> dict:
if input_types is None:
input_types = {}

data = {
"name": name,
"template": template,
Expand Down

0 comments on commit 9965e12

Please sign in to comment.