Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.agentscope;

import java.util.Objects;
import java.util.Properties;

import io.agentscope.runtime.adapters.AgentHandler;
import io.agentscope.runtime.app.AgentApp;
import io.agentscope.runtime.engine.services.sandbox.SandboxService;
import io.agentscope.runtime.sandbox.manager.SandboxManager;
import io.agentscope.runtime.sandbox.manager.client.config.BaseClientConfig;
import io.agentscope.runtime.sandbox.manager.client.config.KubernetesClientConfig;
import io.agentscope.runtime.sandbox.manager.model.ManagerConfig;

public class AgentScopeDeployWithCommandLineExample {

public static void main(String[] args) {
String[] commandLine = new String[2];
commandLine[0] = "-f";
commandLine[1] = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(".env")).getPath();
AgentApp app = new AgentApp(commandLine);
app.run();
}

public static class MyAgentHandlerProvider implements AgentApp.AgentHandlerProvider{

@Override
public AgentHandler get(Properties properties, AgentApp.ServiceComponentManager serviceComponentManager) {
MyAgentScopeAgentHandler handler = new MyAgentScopeAgentHandler();
handler.setStateService(serviceComponentManager.getStateService());
handler.setSandboxService(serviceComponentManager.getSandboxService());
handler.setMemoryService(serviceComponentManager.getMemoryService());
handler.setSessionHistoryService(serviceComponentManager.getSessionHistoryService());
return handler;
}
}

public static class MySandboxServiceProvider implements AgentApp.SandboxServiceProvider {
@Override
public SandboxService get(Properties properties) {
BaseClientConfig clientConfig = KubernetesClientConfig.builder().build();
ManagerConfig managerConfig = ManagerConfig.builder()
.containerDeployment(clientConfig)
.build();
return new SandboxService(
new SandboxManager(managerConfig));
}
}
}
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
<testcontainers.version>1.21.3</testcontainers.version>

<central.publishing.maven.version>0.7.0</central.publishing.maven.version>

<!-- other dependency-->
<picocli.version>4.7.7</picocli.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -313,6 +316,11 @@
<version>${spring-boot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -644,6 +652,14 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>

<reporting>
Expand Down Expand Up @@ -732,5 +748,4 @@
</build>
</profile>
</profiles>

</project>
4 changes: 4 additions & 0 deletions web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
</dependency>

<dependency>
<groupId>org.apache.rocketmq</groupId>
Expand Down
Loading