Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat :: ai
Browse files Browse the repository at this point in the history
  • Loading branch information
osoohynn committed Aug 26, 2024
1 parent d2a3a73 commit 972981b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
3 changes: 2 additions & 1 deletion crescendo-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ configurations {

repositories {
mavenCentral()
maven {url 'https://repo.spring.io/snapshot'} //스냅샷 저장소 추가
}

dependencies {
Expand Down Expand Up @@ -57,7 +58,7 @@ dependencies {
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// spring AI
// implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter:1.0.0-SNAPSHOT'
implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter:1.0.0-SNAPSHOT'

// 소켓 통신
// implementation 'org.springframework.boot:spring-boot-starter-websocket'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.crescendoserver.domain.ai.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/ai")
@RestController
@RequiredArgsConstructor
public class AiController {
private final OpenAiChatModel openAiChatModel;

@GetMapping("/chat")
public String chat(@RequestParam String message) {
return openAiChatModel.call(String.valueOf(message));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers(HttpMethod.POST, "/auth/signup", "/auth/login", "/auth/reissue").anonymous()
.requestMatchers(HttpMethod.GET, "/auth/me").authenticated()
.requestMatchers(HttpMethod.GET, "/swagger-ui/**", "/v3/api-docs/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/chat").permitAll()
.requestMatchers(HttpMethod.GET, "/ai/chat").permitAll()
.requestMatchers(HttpMethod.POST, "/ws/chat").permitAll()
.requestMatchers(HttpMethod.GET, "/ws/chat").permitAll()
.requestMatchers(HttpMethod.POST, "/chat").permitAll()
Expand Down
16 changes: 8 additions & 8 deletions crescendo-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ spring:
# dialect: org.hibernate.dialect.PostgreSQLDialect
show-sql: true
hibernate:
ddl-auto: update
ddl-auto: create

#ai:
# openai:
# api-key: ${CHATGPT_API_KEY}
# chat:
# options:
# model: gpt-3.5-turbo
ai:
openai:
api-key: ${CHATGPT_API_KEY}
chat:
options:
model: gpt-3.5-turbo


redis:
Expand All @@ -28,7 +28,7 @@ redis:
password: 3333

jwt:
secret-key: c2lsdmVybmluZS10ZWNoLXNwcmluZy1ib290LWp3dC10dXRvcmlhbC1zZWNyZXQtc2lsdmVybmluZS10ZWNoLXNwcmluZy1ib290LWp3dC10dXRvcmlhbC1zZWNyZXQK
secret-key: ${SECRET_KEY}
access-token-expiration: 300000 # 5m
refresh-token-expiration: 86400000 # 24h

Expand Down

0 comments on commit 972981b

Please sign in to comment.