Skip to content

快速开始

欢迎使用 Astrsomn 框架!本章节将帮助您快速上手。

环境要求

  • JDK 17+
  • Maven 3.8+
  • MySQL 8.0+
  • Redis 7.0+(可选)

添加依赖

xml
<dependency>
    <groupId>com.astrsomn</groupId>
    <artifactId>astrsomn-runtime-starter</artifactId>
    <version>0.2.0-SNAPSHOT</version>
</dependency>

启用框架

java
@EnableAstroRuntime
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

配置模型

yaml
astrsomn:
  models:
    - provider: DEEPSEEK
      api-key: sk-xxx
      base-url: https://api.deepseek.com/v1
      models:
        - name: deepseek-chat
          max-tokens: 8192
          temperature: 0.7

创建智能体

java
@Astro(name = "my-agent")
public class MyAgent {
    
    @AstroModel(provider = "DEEPSEEK", model = "deepseek-chat")
    private AstroClient client;
    
    @AstroPrompt("你是一个智能助手,使用中文回答问题")
    public String chat(String message) {
        return client.chat(message);
    }
}

使用智能体

java
@Autowired
private AgentService agentService;

public String askAgent(String message) {
    return agentService.chat("my-agent", message);
}

下一步