Skip to content

Commit b6b2e69

Browse files
committed
Linting
1 parent 791917e commit b6b2e69

File tree

10 files changed

+35
-33
lines changed

10 files changed

+35
-33
lines changed

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ VOLUME /data /logs
5353
EXPOSE 7474 7473 7687
5454

5555
ENTRYPOINT ["tini", "-g", "--", "/startup/docker-entrypoint.sh"]
56-
CMD ["neo4j"]
56+
CMD ["neo4j"]

‎README.md‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ rag = LightRAG(
196196
### Using Neo4J for Storage
197197

198198
* For production level scenarios you will most likely want to leverage an enterprise solution
199-
* for KG storage. Running Neo4J in Docker is recommended for seamless local testing.
199+
* for KG storage. Running Neo4J in Docker is recommended for seamless local testing.
200200
* See: https://hub.docker.com/_/neo4j
201201

202202

@@ -209,7 +209,7 @@ When you launch the project be sure to override the default KG: NetworkS
209209
by specifying kg="Neo4JStorage".
210210

211211
# Note: Default settings use NetworkX
212-
#Initialize LightRAG with Neo4J implementation.
212+
#Initialize LightRAG with Neo4J implementation.
213213
WORKING_DIR = "./local_neo4jWorkDir"
214214

215215
rag = LightRAG(
@@ -503,8 +503,8 @@ pip install fastapi uvicorn pydantic
503503
export RAG_DIR="your_index_directory" # Optional: Defaults to "index_default"
504504
export OPENAI_BASE_URL="Your OpenAI API base URL" # Optional: Defaults to "https://api.openai.com/v1"
505505
export OPENAI_API_KEY="Your OpenAI API key" # Required
506-
export LLM_MODEL="Your LLM model" # Optional: Defaults to "gpt-4o-mini"
507-
export EMBEDDING_MODEL="Your embedding model" # Optional: Defaults to "text-embedding-3-large"
506+
export LLM_MODEL="Your LLM model" # Optional: Defaults to "gpt-4o-mini"
507+
export EMBEDDING_MODEL="Your embedding model" # Optional: Defaults to "text-embedding-3-large"
508508
```
509509

510510
3. Run the API server:
@@ -923,4 +923,3 @@ primaryClass={cs.IR}
923923
}
924924
```
925925
**Thank you for your interest in our work!**
926-

‎examples/lightrag_api_openai_compatible_demo.py‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434

3535
async def llm_model_func(
36-
prompt, system_prompt=None, history_messages=[], **kwargs
36+
prompt, system_prompt=None, history_messages=[], **kwargs
3737
) -> str:
3838
return await openai_complete_if_cache(
3939
LLM_MODEL,
@@ -66,9 +66,11 @@ async def get_embedding_dim():
6666
rag = LightRAG(
6767
working_dir=WORKING_DIR,
6868
llm_model_func=llm_model_func,
69-
embedding_func=EmbeddingFunc(embedding_dim=asyncio.run(get_embedding_dim()),
70-
max_token_size=EMBEDDING_MAX_TOKEN_SIZE,
71-
func=embedding_func),
69+
embedding_func=EmbeddingFunc(
70+
embedding_dim=asyncio.run(get_embedding_dim()),
71+
max_token_size=EMBEDDING_MAX_TOKEN_SIZE,
72+
func=embedding_func,
73+
),
7274
)
7375

7476

@@ -99,8 +101,13 @@ async def query_endpoint(request: QueryRequest):
99101
try:
100102
loop = asyncio.get_event_loop()
101103
result = await loop.run_in_executor(
102-
None, lambda: rag.query(request.query,
103-
param=QueryParam(mode=request.mode, only_need_context=request.only_need_context))
104+
None,
105+
lambda: rag.query(
106+
request.query,
107+
param=QueryParam(
108+
mode=request.mode, only_need_context=request.only_need_context
109+
),
110+
),
104111
)
105112
return Response(status="success", data=result)
106113
except Exception as e:

‎lightrag/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .lightrag import LightRAG as LightRAG, QueryParam as QueryParam
22

3-
__version__ = "0.0.8"
3+
__version__ = "0.0.9"
44
__author__ = "Zirui Guo"
55
__url__ = "https://github.com/HKUDS/LightRAG"

‎lightrag/kg/__init__.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
# print ("init package vars here. ......")
2-
3-

‎lightrag/kg/neo4j_impl.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ async def get_edge(
146146
entity_name_label_target = target_node_id.strip('"')
147147
"""
148148
Find all edges between nodes of two given labels
149-
149+
150150
Args:
151151
source_node_label (str): Label of the source nodes
152152
target_node_label (str): Label of the target nodes
153-
153+
154154
Returns:
155155
list: List of all relationships/edges found
156156
"""

‎lightrag/lightrag.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def always_get_an_event_loop() -> asyncio.AbstractEventLoop:
6161
return loop
6262

6363

64-
6564
@dataclass
6665
class LightRAG:
6766
working_dir: str = field(

‎lightrag/operate.py‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -560,19 +560,19 @@ async def _find_most_related_text_unit_from_entities(
560560
if not this_edges:
561561
continue
562562
all_one_hop_nodes.update([e[1] for e in this_edges])
563-
563+
564564
all_one_hop_nodes = list(all_one_hop_nodes)
565565
all_one_hop_nodes_data = await asyncio.gather(
566566
*[knowledge_graph_inst.get_node(e) for e in all_one_hop_nodes]
567567
)
568-
568+
569569
# Add null check for node data
570570
all_one_hop_text_units_lookup = {
571571
k: set(split_string_by_multi_markers(v["source_id"], [GRAPH_FIELD_SEP]))
572572
for k, v in zip(all_one_hop_nodes, all_one_hop_nodes_data)
573573
if v is not None and "source_id" in v # Add source_id check
574574
}
575-
575+
576576
all_text_units_lookup = {}
577577
for index, (this_text_units, this_edges) in enumerate(zip(text_units, edges)):
578578
for c_id in this_text_units:
@@ -586,37 +586,36 @@ async def _find_most_related_text_unit_from_entities(
586586
and c_id in all_one_hop_text_units_lookup[e[1]]
587587
):
588588
relation_counts += 1
589-
589+
590590
chunk_data = await text_chunks_db.get_by_id(c_id)
591591
if chunk_data is not None and "content" in chunk_data: # Add content check
592592
all_text_units_lookup[c_id] = {
593593
"data": chunk_data,
594594
"order": index,
595595
"relation_counts": relation_counts,
596596
}
597-
597+
598598
# Filter out None values and ensure data has content
599599
all_text_units = [
600-
{"id": k, **v}
601-
for k, v in all_text_units_lookup.items()
600+
{"id": k, **v}
601+
for k, v in all_text_units_lookup.items()
602602
if v is not None and v.get("data") is not None and "content" in v["data"]
603603
]
604-
604+
605605
if not all_text_units:
606606
logger.warning("No valid text units found")
607607
return []
608-
608+
609609
all_text_units = sorted(
610-
all_text_units,
611-
key=lambda x: (x["order"], -x["relation_counts"])
610+
all_text_units, key=lambda x: (x["order"], -x["relation_counts"])
612611
)
613-
612+
614613
all_text_units = truncate_list_by_token_size(
615614
all_text_units,
616615
key=lambda x: x["data"]["content"],
617616
max_token_size=query_param.max_token_for_text_unit,
618617
)
619-
618+
620619
all_text_units = [t["data"] for t in all_text_units]
621620
return all_text_units
622621

‎test.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from lightrag import LightRAG, QueryParam
3-
from lightrag.llm import gpt_4o_mini_complete, gpt_4o_complete
3+
from lightrag.llm import gpt_4o_mini_complete
44
#########
55
# Uncomment the below two lines if running in a jupyter notebook to handle the async nature of rag.insert()
66
# import nest_asyncio

‎test_neo4j.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from lightrag import LightRAG, QueryParam
3-
from lightrag.llm import gpt_4o_mini_complete, gpt_4o_complete
3+
from lightrag.llm import gpt_4o_mini_complete
44

55

66
#########

0 commit comments

Comments
 (0)