AI 앱 개발을 할때 필요한 것?
ai model
serving server
database
optional) Monitoring, caching
Spring AI
LLM을 사용하는 애플리케이션 생성을 단순화하도록 설계된 프레임워크.
AI
컴퓨터로 인간의 지능을 구현하는 기술
모델
특정 패턴을 인식하거나 추가적인 인간의 개입 없이 특정 결정을 내리기 위해 일련의 데이터에서 훈련된 프로그램
(LLM : Large Language Model)
프롬프트
ai모델이 특정 출력을 생성하도록 유도하는 언어 기반 입력
토큰
AI모델이 작동하는 기본 구성 요소
한계
대화맥락의 제한
: AI는 상태를 가지고 있지 않으며, 모델이 처리할 수 있는 context에는 제한이있다.
신뢰성 문제- 환각
: ai모델이 부정확하거나 오해의 소지가 있는 결과를 생성하는 것을 의미
해결방안
메모리
: 대화 내용을 메모리에 보관하고 있다가 context에 포함 (비용 많이 발생, context에는 한계존재)
툴
: 모델로 하여금 사용자의 코드나 외부 서비스와 소통할 수 있도록 한다.
검색 증강생성(RAG)
: 추가적인 데이터를 제공해서 LLM 지식을 증강하는 기술
indexing (offline) 과정 ( Retrieval and generation - runtime) 과정
에이전트
: 주어진 목표를 달성하기 위해 주변 환경을 관찰하고, 도구를 활용하여 행동하는 애플리케이션
사람의 명시적인 지시없이도 스스로 판단하고 행동할 수 있다는 점이 강력한 특징
MCP(Model Context Protocol)
: Anthropic 에서 리드하고 있는 프로젝트
애플리케이션 LLM에 컨텍스트를 제공하는 방법을 표준화하는 개방형 프로토콜
"MCP는 ai 애플리케이션을 위한 USB-C 포트와 같다"
예시로 알아보는 ai engineering
spring.application.name=spring250328
spring.ai.openai.base-url=https://openrouter.ai
spring.ai.openai.chat.completions-path=/api/v1/chat/completions
spring.ai.openai.api-key=API-KEY
package com.nhnacademy.spring250328;
import lombok.AllArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
import java.time.LocalDateTime;
@RestController
@AllArgsConstructor
public class ChatController {
private ChatModel chatModel;
@GetMapping("/chat")
public String getChatResponse(@RequestParam String message) {
ChatClient chatClient = ChatClient.builder(chatModel).build();
ChatResponse chatResponse = chatClient.prompt()
.user(message)
.tools(new WeatherTools())
.tools(new DateTimeTools())
.call()
.chatResponse();
return chatResponse.getResult().getOutput().getText();
}
class DateTimeTools {
@Tool(description = "Use to get current timestamp")
public String getCurrentTimeStamp() {
return LocalDateTime.now().toString();
}
}
class WeatherTools {
WebClient webClient = WebClient.builder()
.baseUrl("https://api.openweathermap.org")
.codecs(configurer -> configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder()))
.build();
@Tool(description = "User the Weather API to run a Weather Query")
String getCurrentWeather(String city) {
System.out.println(city);
Mono<String> response = webClient.post()
.uri(String.format("/data/2.5/weather?q=%s&appid=%s",city, "API-KEY"))
.retrieve()
.bodyToMono(String.class);
return response.block();
}
}
}
OpenRouter
A unified interface for LLMs. Find the best models & prices for your prompts
openrouter.ai
https://home.openweathermap.org/
Members
Enter your email address and we will send you a link to reset your password.
home.openweathermap.org
'🚣활동 > NHN Academy' 카테고리의 다른 글
Spring IoC, DI (0) | 2025.03.31 |
---|---|
Connection Pool 최적화 (0) | 2025.03.25 |
[Servlet & JSP] (0) | 2025.03.15 |
HTTPS (HTTP over SSL/TLS) (0) | 2025.02.17 |
쿠키와 세션 (Cookie & Session) (0) | 2025.02.17 |