fix(server): event capturing and necessary logic for smoke test.
This commit is contained in:
@@ -12,21 +12,37 @@ import com.correx.core.tools.contract.ToolExecutor
|
||||
import com.correx.core.tools.registry.ToolRegistry
|
||||
import com.correx.infrastructure.inference.DefaultProviderRegistry
|
||||
import com.correx.infrastructure.inference.FirstAvailableRoutingStrategy
|
||||
import com.correx.infrastructure.inference.commons.ModelDescriptor
|
||||
import com.correx.infrastructure.inference.commons.ModelManager
|
||||
import com.correx.infrastructure.inference.commons.ResidencyMode
|
||||
import com.correx.infrastructure.inference.llama.cpp.DefaultModelManager
|
||||
import com.correx.infrastructure.inference.llama.cpp.LlamaCppInferenceProvider
|
||||
import com.correx.infrastructure.persistence.SqliteEventStore
|
||||
import com.correx.infrastructure.tools.DefaultToolRegistry
|
||||
import com.correx.infrastructure.tools.DispatchingToolExecutor
|
||||
import com.correx.infrastructure.tools.SandboxedToolExecutor
|
||||
import com.correx.infrastructure.tools.ToolConfig
|
||||
import com.correx.infrastructure.tools.buildTools
|
||||
import com.correx.infrastructure.workflow.FileSystemPromptLoader
|
||||
import com.correx.infrastructure.workflow.PromptLoader
|
||||
import com.correx.infrastructure.workflow.TomlWorkflowLoader
|
||||
import com.correx.infrastructure.workflow.WorkflowLoader
|
||||
import com.correx.infrastructure.persistence.artifact.LiveArtifactRepository
|
||||
import com.correx.core.artifacts.repository.ArtifactRepository
|
||||
import com.correx.core.artifacts.DefaultArtifactReducer
|
||||
import io.ktor.client.HttpClient
|
||||
import java.nio.file.Path
|
||||
import java.sql.DriverManager
|
||||
|
||||
object InfrastructureModule {
|
||||
fun createEventStore(dbPath: String): EventStore =
|
||||
SqliteEventStore(DriverManager.getConnection("jdbc:sqlite:$dbPath"))
|
||||
private val defaultDbPath: String =
|
||||
"${System.getProperty("user.home")}/.config/correx/correx.db"
|
||||
|
||||
fun createEventStore(dbPath: String = defaultDbPath): EventStore {
|
||||
val dir = java.io.File(dbPath).parentFile
|
||||
if (!dir.exists()) dir.mkdirs()
|
||||
return SqliteEventStore(DriverManager.getConnection("jdbc:sqlite:$dbPath"))
|
||||
}
|
||||
|
||||
fun createModelManager(
|
||||
eventStore: EventStore,
|
||||
@@ -47,6 +63,31 @@ object InfrastructureModule {
|
||||
strategy: RoutingStrategy = FirstAvailableRoutingStrategy(),
|
||||
): InferenceRouter = DefaultInferenceRouter(registry, strategy)
|
||||
|
||||
fun createLlamaCppProvider(
|
||||
modelId: String,
|
||||
modelPath: String,
|
||||
baseUrl: String = "http://127.0.0.1:10000",
|
||||
residencyMode: ResidencyMode = ResidencyMode.PERSISTENT,
|
||||
): LlamaCppInferenceProvider = LlamaCppInferenceProvider(
|
||||
descriptor = ModelDescriptor(
|
||||
modelId = modelId,
|
||||
modelPath = modelPath,
|
||||
residencyMode = residencyMode,
|
||||
),
|
||||
baseUrl = baseUrl,
|
||||
)
|
||||
|
||||
fun createProviderRegistry(
|
||||
providers: List<InferenceProvider> = emptyList(),
|
||||
): DefaultProviderRegistry = DefaultProviderRegistry(providers)
|
||||
|
||||
fun createArtifactRepository(eventStore: EventStore): ArtifactRepository =
|
||||
LiveArtifactRepository(eventStore, DefaultArtifactReducer())
|
||||
|
||||
fun createWorkflowLoader(): WorkflowLoader = TomlWorkflowLoader()
|
||||
|
||||
fun createPromptLoader(): PromptLoader = FileSystemPromptLoader()
|
||||
|
||||
fun createToolExecutor(
|
||||
registry: ToolRegistry,
|
||||
approvalEngine: ApprovalEngine,
|
||||
|
||||
Reference in New Issue
Block a user