使用Spring AI,可以搭建AI旅游行程规划。
完整源码:ai-trip-planner
@Service
@Slf4j
public class AIService {
@Autowired
private ChatClient chatClient;
public AITripPlanResponse plan(TripAIPlanningDTO dto) {
return chatClient
.prompt()
.system(PromptConstant.TRIP_PLAN_SYSTEM_PROMPT_1)
.user(String.format(PromptConstant.TRIP_PLAN_USER_PROMPT_1, dto.getPlace(), dto.getDays()))
.call()
.entity(AITripPlanResponse.class);
}
}
效果如图: