File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
pyodide-runtime-agent/src Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ function createSystemPrompt(
136136 currentCellId ?: string ,
137137 filepaths ?: string [ ] ,
138138 vectorStoreEnabled : boolean = false ,
139+ userSystemPrompt : string = "" ,
139140) : string {
140141 let prompt = `You are an AI assistant in a collaborative notebook environment.
141142
@@ -150,6 +151,10 @@ After executing code cells you should review the code and make changes to improv
150151
151152` ;
152153
154+ if ( userSystemPrompt ) {
155+ prompt += `\n\n${ userSystemPrompt } \n` ;
156+ }
157+
153158 const vectorStoreExtras =
154159 `IMPORTANT: If you have access to vector store tools (query_documents, find_mounted_file,
155160list_indexed_files),
@@ -529,6 +534,7 @@ export async function executeAI(
529534 sessionId : string ,
530535 notebookTools : NotebookTool [ ] = [ ] ,
531536 maxIterations : number = 10 ,
537+ userSystemPrompt : string = "" ,
532538) : Promise < { success : boolean ; error ?: string } > {
533539 const {
534540 cell,
@@ -587,6 +593,7 @@ export async function executeAI(
587593 cell . id ,
588594 extractedFilePaths ,
589595 isVectorStoreIndexingEnabled ( ) ,
596+ userSystemPrompt ,
590597 ) ,
591598 prompt ,
592599 ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222 isTextBasedMimeType ,
2323 KNOWN_MIME_TYPES ,
2424 type KnownMimeType ,
25+ tables ,
2526} from "@runt/schema" ;
2627import {
2728 getBootstrapPackages as _getBootstrapPackages ,
@@ -551,13 +552,26 @@ export class PyodideRuntimeAgent extends RuntimeAgent {
551552
552553 try {
553554 const maxIterations = this . config . aiMaxIterations ;
555+
556+ let userSystemPrompt = this . store . query (
557+ tables . notebookMetadata
558+ . select ( )
559+ . where ( { key : "user_system_prompt" } )
560+ . first ( { fallback : ( ) => "" } ) ,
561+ ) ;
562+
563+ if ( typeof userSystemPrompt !== "string" ) {
564+ userSystemPrompt = userSystemPrompt . value ;
565+ }
566+
554567 return await executeAI (
555568 aiContext ,
556569 notebookContext ,
557570 this . store ,
558571 this . config . sessionId ,
559572 notebookTools ,
560573 maxIterations ,
574+ userSystemPrompt ,
561575 ) ;
562576 } finally {
563577 this . currentAIExecution = null ;
You can’t perform that action at this time.
0 commit comments