Fix the prompt cache window - use settings.PROMPT_CACHE_WINDOW_HOURS (#769)
This commit is contained in:
@@ -1423,7 +1423,7 @@ class AgentDB:
|
|||||||
async def get_task_generation_by_prompt_hash(
|
async def get_task_generation_by_prompt_hash(
|
||||||
self,
|
self,
|
||||||
user_prompt_hash: str,
|
user_prompt_hash: str,
|
||||||
query_window_hours: int = settings.PROMPT_ACTION_HISTORY_WINDOW,
|
query_window_hours: int = settings.PROMPT_CACHE_WINDOW_HOURS,
|
||||||
) -> TaskGeneration | None:
|
) -> TaskGeneration | None:
|
||||||
before_time = datetime.utcnow() - timedelta(hours=query_window_hours)
|
before_time = datetime.utcnow() - timedelta(hours=query_window_hours)
|
||||||
async with self.Session() as session:
|
async with self.Session() as session:
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ from skyvern.forge.sdk.workflow.models.yaml import WorkflowCreateYAMLRequest
|
|||||||
base_router = APIRouter()
|
base_router = APIRouter()
|
||||||
|
|
||||||
LOG = structlog.get_logger()
|
LOG = structlog.get_logger()
|
||||||
PROMPT_CACHE_WINDOW_HOURS = 24
|
|
||||||
|
|
||||||
|
|
||||||
@base_router.post("/webhook", tags=["server"])
|
@base_router.post("/webhook", tags=["server"])
|
||||||
@@ -775,7 +774,7 @@ async def generate_task(
|
|||||||
# check if there's a same user_prompt within the past x Hours
|
# check if there's a same user_prompt within the past x Hours
|
||||||
# in the future, we can use vector db to fetch similar prompts
|
# in the future, we can use vector db to fetch similar prompts
|
||||||
existing_task_generation = await app.DATABASE.get_task_generation_by_prompt_hash(
|
existing_task_generation = await app.DATABASE.get_task_generation_by_prompt_hash(
|
||||||
user_prompt_hash=user_prompt_hash, query_window_hours=PROMPT_CACHE_WINDOW_HOURS
|
user_prompt_hash=user_prompt_hash, query_window_hours=SettingsManager.get_settings().PROMPT_CACHE_WINDOW_HOURS
|
||||||
)
|
)
|
||||||
if existing_task_generation:
|
if existing_task_generation:
|
||||||
new_task_generation = await app.DATABASE.create_task_generation(
|
new_task_generation = await app.DATABASE.create_task_generation(
|
||||||
|
|||||||
Reference in New Issue
Block a user