@@ -2,16 +2,24 @@ package com.javaaidev.llmcodeexecutor.executor.python
22
33import com.javaaidev.llmcodeexecutor.core.*
44import java.nio.file.Files
5+ import java.time.Duration
6+
7+ data class PythonCodeExecutorConfig (
8+ val containerImage : String? = null ,
9+ )
510
611object PythonCodeExecutor {
712
8- fun execute (request : CodeExecutionRequest ): CodeExecutionResponse {
13+ fun execute (
14+ request : CodeExecutionRequest ,
15+ config : PythonCodeExecutorConfig ? = null
16+ ): CodeExecutionResponse {
917 val codeDir = Files .createTempDirectory(" code_executor" )
1018 val codeFile = " app.py"
1119 Files .writeString(codeDir.resolve(codeFile), request.code)
1220 val codeExecutor = LLMCodeExecutor (
1321 CodeExecutorConfig (
14- " python- executor" ,
22+ config?.containerImage ? : " ghcr.io/javaaidev/llm-code- executor-python:base-3.12 " ,
1523 listOf (" uv" , " run" , codeFile),
1624 listOf (" /app/.venv" ),
1725 listOf (
@@ -21,10 +29,18 @@ object PythonCodeExecutor {
2129 )
2230 ),
2331 " /app" ,
24- containerOutputDirectory = " /app" ,
32+ Duration .ofMinutes(3 ),
33+ " /app" ,
34+ )
35+ )
36+ return codeExecutor.execute(
37+ request.copy(
38+ outputFileCollectionConfig = request.outputFileCollectionConfig?.copy(
39+ includedFilePattern = request.outputFileCollectionConfig?.includedFilePattern
40+ ? : " !${codeFile} "
41+ )
2542 )
2643 )
27- return codeExecutor.execute(request)
2844 }
2945}
3046
0 commit comments