-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
263 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import genai_core.parameters | ||
import genai_core.kendra | ||
from pydantic import BaseModel | ||
from aws_lambda_powertools import Logger, Tracer | ||
from aws_lambda_powertools.event_handler.api_gateway import Router | ||
|
||
tracer = Tracer() | ||
router = Router() | ||
logger = Logger() | ||
|
||
|
||
class KendraDataSynchRequest(BaseModel): | ||
workspaceId: str | ||
|
||
|
||
@router.get("/rag/engines/kendra/indexes") | ||
@tracer.capture_method | ||
def kendra_indexes(): | ||
indexes = genai_core.kendra.get_kendra_indexes() | ||
|
||
return {"ok": True, "data": indexes} | ||
|
||
|
||
@router.post("/rag/engines/kendra/data-sync") | ||
@tracer.capture_method | ||
def kendra_data_sync(): | ||
data: dict = router.current_event.json_body | ||
request = KendraDataSynchRequest(**data) | ||
|
||
genai_core.kendra.start_kendra_data_sync(workspace_id=request.workspaceId) | ||
|
||
return {"ok": True, "data": True} | ||
|
||
|
||
@router.get("/rag/engines/kendra/data-sync/<workspace_id>") | ||
@tracer.capture_method | ||
def kendra_is_syncing(workspace_id: str): | ||
result = genai_core.kendra.kendra_is_syncing(workspace_id=workspace_id) | ||
|
||
return {"ok": True, "data": result} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
lib/user-interface/react-app/src/common/api-client/kendra-client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ApiResult, KendraIndexItem } from "../types"; | ||
import { ApiClientBase } from "./api-client-base"; | ||
|
||
export class KendraClient extends ApiClientBase { | ||
async getKendraIndexes(): Promise<ApiResult<KendraIndexItem[]>> { | ||
try { | ||
const headers = await this.getHeaders(); | ||
const result = await fetch( | ||
this.getApiUrl("/rag/engines/kendra/indexes"), | ||
{ | ||
headers, | ||
} | ||
); | ||
|
||
return result.json(); | ||
} catch (error) { | ||
return this.error(error); | ||
} | ||
} | ||
|
||
async startKendraDataSync(workspaceId: string): Promise<ApiResult<void>> { | ||
try { | ||
const headers = await this.getHeaders(); | ||
const result = await fetch( | ||
this.getApiUrl("/rag/engines/kendra/data-sync"), | ||
{ | ||
headers, | ||
method: "POST", | ||
body: JSON.stringify({ workspaceId }), | ||
} | ||
); | ||
|
||
return result.json(); | ||
} catch (error) { | ||
return this.error(error); | ||
} | ||
} | ||
|
||
async kendraIsSyncing(workspaceId: string): Promise<ApiResult<boolean>> { | ||
try { | ||
const headers = await this.getHeaders(); | ||
const result = await fetch( | ||
this.getApiUrl(`/rag/engines/kendra/data-sync/${workspaceId}`), | ||
{ | ||
headers, | ||
method: "GET", | ||
} | ||
); | ||
|
||
return result.json(); | ||
} catch (error) { | ||
return this.error(error); | ||
} | ||
} | ||
} |
Oops, something went wrong.