Skip to content

Commit

Permalink
Update community model (#1524)
Browse files Browse the repository at this point in the history
* Feature/tweak actions (#1507)

* up

* tweak actions

* Sync JS SDK, Harmonize Python SDK KG Methods (#1511)

* Feature/move logging (#1492)

* move logging provider out

* move logging provider to own directory, remove singleton

* cleanup

* fix refactoring tweak (#1496)

* Fix JSON serialization and Prompt ID Bugs for Prompts (#1491)

* Bug in get prompts

* Add tests

* Prevent verbose logging on standup

* Remove kg as required key in config, await get_all_prompts

* Remove reference to fragment id

* comment out ingestion

* complete logging port (#1499)

* Feature/dev rebased (#1500)

* Feature/move logging (#1493)

* move logging provider out

* move logging provider to own directory, remove singleton

* cleanup

* Update js package (#1498)

* fix refactoring tweak (#1496)

* Fix JSON serialization and Prompt ID Bugs for Prompts (#1491)

* Bug in get prompts

* Add tests

* Prevent verbose logging on standup

* Remove kg as required key in config, await get_all_prompts

* Remove reference to fragment id

* comment out ingestion

* complete logging port (#1499)

---------

Co-authored-by: Nolan Tremelling <[email protected]>

* Fix handling for R2R exceptions (#1501)

* fix doc test (#1502)

* Harmonize python SDK KG methods for optional params, add missing JS methods

---------

Co-authored-by: emrgnt-cmplxty <[email protected]>
Co-authored-by: emrgnt-cmplxty <[email protected]>

* Clean up pagination and offset around KG (#1519)

* Move to R2R light for integration testing (#1521)

* Update community model

---------

Co-authored-by: emrgnt-cmplxty <[email protected]>
Co-authored-by: emrgnt-cmplxty <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 1010c74 commit 794c408
Show file tree
Hide file tree
Showing 11 changed files with 694 additions and 320 deletions.
46 changes: 21 additions & 25 deletions .github/workflows/r2r-js-sdk-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,45 @@ jobs:
test:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./js/sdk
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TELEMETRY_ENABLED: 'false'
R2R_POSTGRES_HOST: localhost
R2R_POSTGRES_DBNAME: postgres
R2R_POSTGRES_PORT: '5432'
R2R_POSTGRES_PASSWORD: postgres
R2R_POSTGRES_USER: postgres
R2R_PROJECT_NAME: r2r_default

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
- name: Set up Python and install dependencies
uses: ./.github/actions/setup-python-light
with:
python-version: "3.x"
os: ubuntu-latest

- name: Install R2R
run: |
python -m pip install --upgrade pip
pip install r2r
- name: Setup and start PostgreSQL
uses: ./.github/actions/setup-postgres-ext
with:
os: ubuntu-latest

- name: Start R2R server
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
r2r serve --docker
sleep 60
- name: Start R2R Light server
uses: ./.github/actions/start-r2r-light

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "20.x"

- name: Install dependencies
- name: Install JS SDK dependencies
working-directory: ./js/sdk
run: npm ci

- name: Check if R2R server is running
run: |
curl http://localhost:7272/v2/health || echo "Server not responding"
- name: Display R2R server logs if server not responding
if: failure()
run: docker logs r2r-r2r-1

- name: Run integration tests
working-directory: ./js/sdk
run: npm run test

- name: Display R2R server logs if tests fail
if: failure()
run: docker logs r2r-r2r-1
17 changes: 15 additions & 2 deletions js/sdk/__tests__/r2rClientIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ let newCollectionId: string;
* - updateFiles
* - ingestChunks
* - updateChunks
* X createVectorIndex
* X listVectorIndices
* X deleteVectorIndex
* Management:
* - serverStats
* X updatePrompt
* X addPrompt
* X getPrompt
* X getAllPrompts
* X deletePrompt
* - analytics
* - logs
* - appSettings
Expand All @@ -45,7 +52,6 @@ let newCollectionId: string;
* X downloadFile
* - documentsOverview
* - documentChunks
* X inspectKnowledgeGraph
* X collectionsOverview
* - createCollection
* - getCollection
Expand All @@ -70,8 +76,15 @@ let newCollectionId: string;
* X getPreviousBranch
* X branchAtMessage
* - deleteConversation
* Restructure:
* Knowledge Graphs:
* X createGraph
* X enrichGraph
* X getEntities
* X getTriples
* X getCommunities
* X getTunedPrompt
* X deduplicateEntities
* X deleteGraphForCollection
* Retrieval:
* - search
* - rag
Expand Down
29 changes: 18 additions & 11 deletions js/sdk/__tests__/r2rClientIntegrationUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ const baseUrl = "http://localhost:7272";
* - updateFiles
* X ingestChunks
* X updateChunks
* X createVectorIndex
* X listVectorIndices
* X deleteVectorIndex
* Management:
* - serverStats
* X updatePrompt
* X addPrompt
* X getPrompt
* X getAllPrompts
* X deletePrompt
* X analytics
* X logs
* - appSettings
Expand All @@ -41,7 +48,6 @@ const baseUrl = "http://localhost:7272";
* X downloadFile
* - documentsOverview
* - documentChunks
* X inspectKnowledgeGraph
* X collectionsOverview
* X createCollection
* X getCollection
Expand All @@ -66,8 +72,15 @@ const baseUrl = "http://localhost:7272";
* X getPreviousBranch
* X branchAtMessage
* X deleteConversation
* Restructure:
* Knowledge Graphs:
* X createGraph
* X enrichGraph
* X getEntities
* X getTriples
* X getCommunities
* X getTunedPrompt
* X deduplicateEntities
* X deleteGraphForCollection
* Retrieval:
* - search
* X rag
Expand Down Expand Up @@ -169,21 +182,15 @@ describe("r2rClient Integration Tests", () => {
});

test("Only an authorized user can call server stats", async () => {
await expect(client.serverStats()).rejects.toThrow(
"Status 403: Only an authorized user can call the `server_stats` endpoint.",
);
await expect(client.serverStats()).rejects.toThrow(/Status 403/);
});

test("Only a superuser can call app settings", async () => {
await expect(client.appSettings()).rejects.toThrow(
"Status 403: Only a superuser can call the `app_settings` endpoint.",
);
await expect(client.appSettings()).rejects.toThrow(/Status 403/);
});

test("Only a superuser can call users overview", async () => {
await expect(client.usersOverview()).rejects.toThrow(
"Status 403: Only a superuser can call the `users_overview` endpoint.",
);
await expect(client.usersOverview()).rejects.toThrow(/Status 403/);
});

test("Document chunks", async () => {
Expand Down
35 changes: 35 additions & 0 deletions js/sdk/src/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface GenerationConfig {
tools?: Array<Record<string, any>>;
add_generation_kwargs?: Record<string, any>;
api_base?: string;
response_format?: string;
}

export interface HybridSearchSettings {
Expand Down Expand Up @@ -67,6 +68,40 @@ export interface KGSearchSettings {
local_search_limits?: Record<string, number>;
}

export enum KGRunType {
ESTIMATE = "estimate",
RUN = "run",
}

export interface KGCreationSettings {
kg_triples_extraction_prompt?: string;
kg_entity_description_prompt?: string;
force_kg_creation?: boolean;
entity_types?: string[];
relation_types?: string[];
extractions_merge_count?: number;
max_knowledge_triples?: number;
max_description_input_length?: number;
generation_config?: GenerationConfig;
}

export interface KGEnrichmentSettings {
force_kg_enrichment?: boolean;
community_reports_prompt?: string;
max_summary_input_length?: number;
generation_config?: GenerationConfig;
leiden_params?: Record<string, any>;
}

export interface KGEntityDeduplicationSettings {
kg_entity_deduplication_type?: KGEntityDeduplicationType;
}

export enum KGEntityDeduplicationType {
BY_NAME = "by_name",
BY_DESCRIPTION = "by_description",
}

export interface KGLocalSearchResult {
query: string;
entities: Record<string, any>;
Expand Down
Loading

0 comments on commit 794c408

Please sign in to comment.