fix linting

This commit is contained in:
zrguo
2025-03-03 18:40:03 +08:00
parent 1611400854
commit ef2a5ad191
33 changed files with 320 additions and 1411 deletions

View File

@@ -14,6 +14,7 @@ TEXT_FILES_DIR = "/llm/mt"
if not os.path.exists(WORKING_DIR):
os.mkdir(WORKING_DIR)
async def initialize_rag():
# Initialize LightRAG
rag = LightRAG(
@@ -31,6 +32,7 @@ async def initialize_rag():
return rag
# Read all .txt files from the TEXT_FILES_DIR directory
texts = []
for filename in os.listdir(TEXT_FILES_DIR):
@@ -82,7 +84,8 @@ def main():
try:
print(
rag.query(
"What are the top themes in this story?", param=QueryParam(mode="global")
"What are the top themes in this story?",
param=QueryParam(mode="global"),
)
)
except Exception as e:
@@ -91,18 +94,17 @@ def main():
try:
print(
rag.query(
"What are the top themes in this story?", param=QueryParam(mode="hybrid")
"What are the top themes in this story?",
param=QueryParam(mode="hybrid"),
)
)
except Exception as e:
print(f"Error performing hybrid search: {e}")
# Function to clear VRAM resources
def clear_vram():
os.system("sudo nvidia-smi --gpu-reset")
# Regularly clear VRAM to prevent overflow
clear_vram_interval = 3600 # Clear once every hour
start_time = time.time()
@@ -114,5 +116,6 @@ def main():
start_time = current_time
time.sleep(60) # Check the time every minute
if __name__ == "__main__":
main()