Skip to content

Commit

Permalink
update the api reference names
Browse files Browse the repository at this point in the history
  • Loading branch information
Alleria1809 committed Jul 2, 2024
1 parent 6a7c675 commit 2a545c9
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 17 deletions.
2 changes: 2 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ apidoc:
@python $(SOURCEDIR)/remove_string.py
@echo "Removing duplicated files"
@python $(SOURCEDIR)/remove_files.py
@echo "Renaming and updating file"
@python $(SOURCEDIR)/change_api_file_name.py



Expand Down
51 changes: 34 additions & 17 deletions docs/source/apis/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@ Core
The core section of the LightRAG API documentation provides detailed information about the foundational components of the LightRAG system. These components are essential for the basic operations and serve as the building blocks for higher-level functionalities.

.. autosummary::

core.component
core.base_data_class
core.default_prompt_template
core.model_client
core.component
core.data_components

.. core.data_components
core.db
core.default_prompt_template
core.embedder
core.functional

core.generator
core.memory
core.parameter
core.prompt_builder
core.retriever
core.string_parser
core.embedder
core.retriever
.. core.memory
core.prompt_builder
core.tokenizer
core.func_tool
core.tool_manager
core.types

core.parameter

Components
-----------
Expand All @@ -38,13 +40,28 @@ The components section of the LightRAG API documentation outlines the detailed s

.. autosummary::

components.agent
components.model_client
componnets.data_process
.. components.reasoning
components.retriever
components.output_parsers
components.agent.react

components.model_client.anthropic_client
components.model_client.cohere_client
components.model_client.google_client
components.model_client.groq_client
components.model_client.openai_client
components.model_client.transformers_client
components.model_client.utils

components.data_process.data_components
components.data_process.text_splitter

components.reasoning.chain_of_thought

components.retriever.bm25_retriever
components.retriever.faiss_retriever
components.retriever.llm_retriever
components.retriever.postgres_retriever
components.retriever.reranker_retriever

components.output_parsers.outputs


Evaluation
Expand Down
56 changes: 56 additions & 0 deletions docs/source/change_api_file_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import re

def update_file_content(directory):
module_name = directory.split("/")[-1]

for filename in os.listdir(directory):
if filename.endswith(".rst") and "index" not in filename:
filepath = os.path.join(directory, filename)
with open(filepath, "r+", encoding='utf-8') as file:
lines = file.readlines()
modified = False # To track if modifications have been made
for i in range(len(lines) - 1):
line = lines[i].strip()
next_line = lines[i + 1].strip()

# Check if the next line is a title underline
if next_line == "=" * len(next_line) and not modified:
# Check if the current line starts with the module_name
if line.startswith(module_name):
# Replace the full module path with only the last segment
new_title = line.split('.')[-1]
lines[i] = new_title + '\n' # Update the title line
modified = True # Mark that modification has been made
# No need to break since we are preserving the rest of the content

# Rewind and update the file only if modifications were made
if modified:
file.seek(0)
file.writelines(lines)
file.truncate() # Ensure the file is cut off at the new end if it's shorter
print(f"Updated {filepath}")

# def rename_files(directory):
# remove_prefix = directory.split("/")[-1] + "."
# for filename in os.listdir(directory):
# if filename.endswith(".rst") and remove_prefix in filename:
# new_filename = filename.replace(remove_prefix, '')
# os.rename(os.path.join(directory, filename), os.path.join(directory, new_filename))
# print(f"Renamed {filename} to {new_filename}")


if __name__ == "__main__":
# Specify the directory or directories you want to process
directories = [
"./source/apis/core",
"./source/apis/components",
"./source/apis/utils",
"./source/apis/eval",
"./source/apis/tracing",
"./source/apis/optim",
]
for diretory in directories:
update_file_content(diretory)
# rename_files(diretory)
# rename_and_update_files(dir)

0 comments on commit 2a545c9

Please sign in to comment.