From 8431b5d24f24c240788b4609bfea76c1df57572b Mon Sep 17 00:00:00 2001 From: josc146 Date: Mon, 12 Jun 2023 13:41:51 +0800 Subject: [PATCH] log Generation Prompt --- backend-python/routes/state_cache.py | 2 +- backend-python/utils/log.py | 2 +- backend-python/utils/rwkv.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend-python/routes/state_cache.py b/backend-python/routes/state_cache.py index 28f72de..e7ce015 100644 --- a/backend-python/routes/state_cache.py +++ b/backend-python/routes/state_cache.py @@ -87,7 +87,7 @@ def longest_prefix_state(body: LongestPrefixStateBody, request: Request): v = dtrie[id] device = v["device"] prompt = trie[id] - quick_log(request, body, "Hit: " + prompt) + quick_log(request, body, "Hit:\n" + prompt) return { "prompt": prompt, "tokens": v["tokens"], diff --git a/backend-python/utils/log.py b/backend-python/utils/log.py index 498fbd8..2dee24f 100644 --- a/backend-python/utils/log.py +++ b/backend-python/utils/log.py @@ -22,7 +22,7 @@ def quick_log(request: Request, body: Any, response: str): if body else "" ) - + (f"Response:\n{response}\n" if response else "") + + (f"Data:\n{response}\n" if response else "") ) diff --git a/backend-python/utils/rwkv.py b/backend-python/utils/rwkv.py index 340608b..f1ebcc2 100644 --- a/backend-python/utils/rwkv.py +++ b/backend-python/utils/rwkv.py @@ -2,6 +2,7 @@ import os import pathlib import copy from typing import Dict, List +from utils.log import quick_log from fastapi import HTTPException from pydantic import BaseModel, Field from rwkv_pip.utils import PIPELINE @@ -101,6 +102,7 @@ The following is a coherent verbose detailed conversation between a girl named { return out def generate(self, prompt: str, stop: str = None): + quick_log(None, None, "Generation Prompt:\n" + prompt) cache = None delta_prompt = prompt try: