Skip to content

Commit 6a59c03

Browse files
committed
mixed context, entities, community reports
1 parent ecb3b74 commit 6a59c03

19 files changed

Lines changed: 375 additions & 53 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shinkai-libs/shinkai-graphrag/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ edition = "2021"
77
anyhow = "1.0.86"
88
async-trait = "0.1.74"
99
futures = "0.3.30"
10-
polars = { version = "0.41.3", features = ["dtype-struct", "lazy", "parquet"] }
10+
polars = { version = "0.41.3", features = ["dtype-struct", "is_in", "lazy", "parquet"] }
1111
polars-lazy = "0.41.3"
1212
rand = "0.8.5"
1313
serde = { version = "1.0.188", features = ["derive"] }
1414
serde_json = "1.0.117"
1515
tokio = { version = "1.36", features = ["full"] }
16+
uuid = { version = "1.6.1", features = ["v4"] }
1617

1718
[dev-dependencies]
1819
async-openai = "0.23.4"

shinkai-libs/shinkai-graphrag/src/context_builder/community_context.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,23 @@ use rand::prelude::SliceRandom;
1313

1414
use crate::models::{CommunityReport, Entity};
1515

16-
use super::context_builder::GlobalSearchContextBuilderParams;
16+
#[derive(Debug, Clone)]
17+
pub struct CommunityContextBuilderParams {
18+
pub use_community_summary: bool,
19+
pub column_delimiter: String,
20+
pub shuffle_data: bool,
21+
pub include_community_rank: bool,
22+
pub min_community_rank: u32,
23+
pub community_rank_name: String,
24+
pub include_community_weight: bool,
25+
pub community_weight_name: String,
26+
pub normalize_community_weight: bool,
27+
pub max_tokens: usize,
28+
pub context_name: String,
29+
// conversation_history: Option<ConversationHistory>,
30+
// conversation_history_user_turns_only: bool,
31+
// conversation_history_max_turns: Option<i32>,
32+
}
1733

1834
pub struct GlobalCommunityContext {
1935
community_reports: Vec<CommunityReport>,
@@ -34,11 +50,11 @@ impl GlobalCommunityContext {
3450
}
3551
}
3652

37-
pub async fn build_context(
53+
pub fn build_context(
3854
&self,
39-
context_builder_params: GlobalSearchContextBuilderParams,
55+
context_builder_params: CommunityContextBuilderParams,
4056
) -> anyhow::Result<(Vec<String>, HashMap<String, DataFrame>)> {
41-
let GlobalSearchContextBuilderParams {
57+
let CommunityContextBuilderParams {
4258
use_community_summary,
4359
column_delimiter,
4460
shuffle_data,
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
#[derive(Debug, Clone)]
2-
pub struct GlobalSearchContextBuilderParams {
3-
pub use_community_summary: bool,
4-
pub column_delimiter: String,
5-
pub shuffle_data: bool,
6-
pub include_community_rank: bool,
7-
pub min_community_rank: u32,
8-
pub community_rank_name: String,
9-
pub include_community_weight: bool,
10-
pub community_weight_name: String,
11-
pub normalize_community_weight: bool,
12-
pub max_tokens: usize,
13-
pub context_name: String,
14-
//conversation_history: Option<ConversationHistory>,
15-
// conversation_history_user_turns_only: bool,
16-
// conversation_history_max_turns: Option<i32>,
17-
}
18-
191
pub struct ConversationHistory {}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
pub mod community_context;
22
pub mod context_builder;
3-
pub mod indexer_entities;
4-
pub mod indexer_reports;

shinkai-libs/shinkai-graphrag/src/context_builder/indexer_entities.rs renamed to shinkai-libs/shinkai-graphrag/src/indexer_adapters/indexer_entities.rs

File renamed without changes.

shinkai-libs/shinkai-graphrag/src/context_builder/indexer_reports.rs renamed to shinkai-libs/shinkai-graphrag/src/indexer_adapters/indexer_reports.rs

File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod indexer_entities;
2+
pub mod indexer_reports;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
pub mod context_builder;
2+
pub mod indexer_adapters;
23
pub mod llm;
34
pub mod models;
5+
pub mod retrieval;
46
pub mod search;
57
pub mod vector_stores;

shinkai-libs/shinkai-graphrag/src/llm/llm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub trait BaseLLM {
4747
#[async_trait]
4848
pub trait BaseTextEmbedding {
4949
async fn aembed(&self, text: &str) -> Vec<f64>;
50+
fn embed(&self, text: &str) -> Vec<f64>;
5051
}
5152

5253
pub enum GlobalSearchPhase {

0 commit comments

Comments
 (0)