Skip to content

Commit

Permalink
Updated logger with standard response
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichardson97 committed Feb 27, 2024
1 parent dfce63e commit c676dca
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

31 changes: 18 additions & 13 deletions kg_summarizer/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions kg_summarizer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="kg-summarizer",
version="0.0.8",
version="0.0.9",
author="Joey Richardson",
author_email="[email protected]",
url="https://github.com/jrichardson97/kg-summarizer",
Expand Down

0 comments on commit c676dca

Please sign in to comment.