diff --git a/client-report/src/components/app.jsx b/client-report/src/components/app.jsx index f83dd5e9c..42d97f226 100644 --- a/client-report/src/components/app.jsx +++ b/client-report/src/components/app.jsx @@ -85,6 +85,11 @@ const App = (props) => { ? window.location.search.split("model=")[1]?.split("&")[0] : "openai" ); + const [searchParamsCache, setSearchParamCache] = useState( + window.location.search.includes("noCache=") + ? window.location.search.split("noCache=")[1]?.split("&")[0] + : "false" + ); let corMatRetries; @@ -101,6 +106,7 @@ const App = (props) => { const urlParams = new URLSearchParams(queryString); if (urlParams.get("section")) setSearchParamsSection(urlParams.get("section")); if (urlParams.get("model")) setSearchParamModel(urlParams.get("model")); + if (urlParams.get("noCache")) setSearchParamCache(urlParams.get("noCache")); }, [window.location?.pathname, window.location?.search]); useEffect(() => { @@ -173,7 +179,7 @@ const App = (props) => { const response = await fetch( `${urlPrefix}api/v3/reportNarrative?report_id=${report_id}${ searchParamsSection ? `§ion=${searchParamsSection}` : `` - }${searchParamsModel ? `&model=${searchParamsModel}` : ``}`, + }${searchParamsModel ? `&model=${searchParamsModel}` : ``}${searchParamsCache ? `&noCache=${searchParamsCache}` : ``}`, { credentials: "include", method: "get", diff --git a/server/src/routes/reportNarrative.ts b/server/src/routes/reportNarrative.ts index 068299483..c7cbcf0bd 100644 --- a/server/src/routes/reportNarrative.ts +++ b/server/src/routes/reportNarrative.ts @@ -652,8 +652,9 @@ export async function handle_GET_topics( "polis-comments-and-group-demographics", json ); + res.write(`POLIS-PING: calling topic timeout`); setTimeout(async () => { - console.log("CALLING TOPIC"); + res.write(`POLIS-PING: calling topic`); const resp = await getModelResponse( model, system_lore, @@ -708,7 +709,8 @@ export async function handle_GET_reportNarrative( if (process.env.AWS_REGION && process.env.AWS_REGION?.trim().length > 0) { storage = new DynamoStorageService( process.env.AWS_REGION, - "report_narrative_store" + "report_narrative_store", + req.query.noCache === "true", ); } const modelParam = req.query.model || "openai"; diff --git a/server/src/utils/storage.ts b/server/src/utils/storage.ts index f1e921370..cdba0446f 100644 --- a/server/src/utils/storage.ts +++ b/server/src/utils/storage.ts @@ -9,11 +9,13 @@ import { export default class DynamoStorageService { private client: DynamoDBClient; private tableName: string; + private cacheDisabled: boolean; - constructor(region: string, tableName: string) { + constructor(region: string, tableName: string, disableCache?: boolean) { const dynamoClient = new DynamoDBClient({ region }); this.client = dynamoClient; this.tableName = tableName; + this.cacheDisabled = disableCache || false; } async putItem(item: Record | undefined) { @@ -42,6 +44,10 @@ export default class DynamoStorageService { }; const command = new QueryCommand(params); + + if (this.cacheDisabled) { + return [] + } try { const data = await this.client.send(command);