diff --git a/README.md b/README.md index 1d42bf7..eea74ad 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,4 @@ For webapps developed against a local deployment of this service, the `PYTHON_EN Start server: redis-server --dbfilename aragorn_cache.rdb --dir /home/joeyr/data/kg_summarizer ## Todo -- Add check for publications before feeding into LLM -- Add logging to server (talk to yaphet) diff --git a/kg_summarizer/server.py b/kg_summarizer/server.py index 17e4f64..78b49ec 100644 --- a/kg_summarizer/server.py +++ b/kg_summarizer/server.py @@ -39,7 +39,7 @@ class EdgeItem(BaseModel): parameters: Parameters -KG_SUM_VERSION = "0.0.8" +KG_SUM_VERSION = "0.0.9" # declare the application and populate some details app = FastAPI( @@ -95,17 +95,22 @@ async def summarize_edge_handler(item: EdgeItem): Summarize the following edge publication abstracts listed in the knowledge graph. Make sure the summary supports the statement '{spo_sentence}'. Only use information explicitly stated in the publication abstracts. I repeat, do not make up any information. """ - logger.info(f"GPT Prompt: {system_prompt}") - logger.info(f"GPT Mode: {item.parameters.llm.gpt_model}") - logger.info(f"GPT Temperature: {item.parameters.llm.temperature}") - logger.info(f"GPT Input: {edge}") - - summary = generate_response( - system_prompt, - str(edge), - item.parameters.llm.gpt_model, - item.parameters.llm.temperature, - ) + if edge["edge"]["publications"] or edge["edge"]["sentences"]: + logger.info(f"GPT Prompt: {system_prompt}") + logger.info(f"GPT Mode: {item.parameters.llm.gpt_model}") + logger.info(f"GPT Temperature: {item.parameters.llm.temperature}") + logger.info(f"GPT Input: {edge}") + summary = generate_response( + system_prompt, + str(edge), + item.parameters.llm.gpt_model, + item.parameters.llm.temperature, + ) + else: + logger.info( + "Edge contained no publications or sentences. Returning with standarized summary." + ) + summary = f"The edge '{spo_sentence}' contains no publications or supporting sentences for an LLM to summarize." - logger.info(f"GPT Summary: {summary}") + logger.info(f"Edge Summary: {summary}") return summary diff --git a/kg_summarizer/utils.py b/kg_summarizer/utils.py index 9327c43..ab70821 100644 --- a/kg_summarizer/utils.py +++ b/kg_summarizer/utils.py @@ -49,9 +49,9 @@ def init_logging( # if there was a file path passed in use it if log_file_path is not None: - # create a rotating file handler, 100mb max per file with a max number of 10 files + # create a rotating file handler, 50mb max per file with a max number of 2 files file_handler = RotatingFileHandler( - filename=log_file_path, maxBytes=1000000, backupCount=10 + filename=log_file_path, maxBytes=50000000, backupCount=2 ) # set the formatter diff --git a/setup.py b/setup.py index 431dc05..db215f5 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="kg-summarizer", - version="0.0.8", + version="0.0.9", author="Joey Richardson", author_email="richardson.joey.b@gmail.com", url="https://github.com/jrichardson97/kg-summarizer",