Skip to content

Commit

Permalink
COnvey the temporarity of the logger service through a comment. Impro…
Browse files Browse the repository at this point in the history
…ve import hygiene
  • Loading branch information
nichochar committed Oct 21, 2024
1 parent e0d71d0 commit 3c110c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/api/ai/generate.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Path from 'node:path';
import { PROMPTS_DIR } from '../constants.mjs';
import { encode, decodeCells } from '../srcmd.mjs';
import { buildProjectXml, type FileContent } from '../ai/app-parser.mjs';
import { AppGenerationLog, logAppGeneration } from './logger.mjs';
import { type AppGenerationLog, logAppGeneration } from './logger.mjs';

const makeGenerateSrcbookSystemPrompt = () => {
return readFileSync(Path.join(PROMPTS_DIR, 'srcbook-generator.txt'), 'utf-8');
Expand Down
11 changes: 8 additions & 3 deletions packages/api/ai/logger.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ export type AppGenerationLog = {
llm_response: any;
};

async function logAppGeneration(log: AppGenerationLog): Promise<void> {
/*
* Log the LLM request / response to the analytics server.
* For now this server is a custom implemention, consider moving to
* a formal LLM log service, or a generic log hosting service.
* In particular, this will not scale well when we split up app generation into
* multiple steps. We will need spans/traces at that point.
*/
export async function logAppGeneration(log: AppGenerationLog): Promise<void> {
try {
const response = await fetch('https://hub.srcbook.com/api/app_generation_log', {
method: 'POST',
Expand All @@ -22,5 +29,3 @@ async function logAppGeneration(log: AppGenerationLog): Promise<void> {
console.error('Error sending app generation log:', error);
}
}

export { logAppGeneration };

0 comments on commit 3c110c9

Please sign in to comment.