Skip to content
Merged
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
15 changes: 15 additions & 0 deletions cookbook/en/deployment/agent_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ agentApp.run("localhost",10001);

------

```java
//Use launch parameters or environment variables
// required items
// 1、Specify attributes in environment variables or startup parameters[agent.app.handler.provider.class],It is an implementation of io.agentscope.runtime.app.AgentApp.AgentHandlerProvider,used for create an io.agentscope.runtime.adapters.AgentHandler instance.
// 2、Specify attributes in environment variables or startup parameters[agent.app.sandbox.service.provider.class],It is an implementation of io.agentscope.runtime.app.AgentApp.SandboxServiceProvider,used for create an io.agentscope.runtime.engine.services.sandbox.SandboxService instance.
String[] commandLine = new String[2];
commandLine[0] = "-f";
commandLine[1] = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(".env")).getPath();//The path can be arbitrarily specified
AgentApp agentApp = new AgentApp(commandLine);
agentApp.run();

```

------

## Configuring Cross-Origin Resource Sharing (CORS)

**Feature**
Expand Down
13 changes: 13 additions & 0 deletions cookbook/zh/deployment/agent_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ agentApp.run("localhost",10001);

------

```java
//使用启动参数或环境变量
// 必要项
// 1、在环境变量或启动参数中指定属性[agent.app.handler.provider.class],它是一个io.agentscope.runtime.app.AgentApp.AgentHandlerProvider的实现,用于实例化io.agentscope.runtime.adapters.AgentHandler
// 2、在环境变量或启动参数中指定属性[agent.app.sandbox.service.provider.class],它是一个io.agentscope.runtime.app.AgentApp.SandboxServiceProvider的实现,用于实例化io.agentscope.runtime.engine.services.sandbox.SandboxService
String[] commandLine = new String[2];
commandLine[0] = "-f";
commandLine[1] = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource(".env")).getPath();//The path can be arbitrarily specified
AgentApp agentApp = new AgentApp(commandLine);
agentApp.run();

```

## 配置跨域(CORS)

**功能**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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));
}
}
}
9 changes: 8 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 @@ -732,5 +740,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
Loading