imbajin commented on code in PR #110: URL: https://github.com/apache/incubator-hugegraph-ai/pull/110#discussion_r1844923792
########## hugegraph-llm/src/hugegraph_llm/demo/rag_demo/admin_block.py: ########## @@ -0,0 +1,152 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import asyncio +import os + +import gradio as gr +from gradio import Request + +from hugegraph_llm.utils.log import log + + +async def log_stream(log_path: str): + """ + Stream the content of a log file like `tail -f`. + """ + try: + with open(log_path, 'r') as file: + while True: + line = file.readline() + if line: + yield line + else: + await asyncio.sleep(0.1) # Non-blocking sleep + except FileNotFoundError: + raise Exception(f"Log file not found: {log_path}") + except Exception as e: + raise Exception(f"An error occurred while reading the log: {str(e)}") + + +# Functions to read each log file +def read_llm_server_log(): + try: + with open("logs/llm-server.log", "r") as f: + return f.read() Review Comment: ```suggestion # TODO: avoid read the whole file (read latest N lines instead) return f.read() ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
