From f710b558678eba41a676a6014a7e296b78d09370 Mon Sep 17 00:00:00 2001 From: jungsunbeen Date: Tue, 27 May 2025 18:58:58 +0900 Subject: [PATCH 01/16] =?UTF-8?q?refactor:=20Comments=20=EB=B0=8F=20Hashta?= =?UTF-8?q?gs=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20div=20=EC=A0=9C=EA=B1=B0?= =?UTF-8?q?=20=EB=B0=8F=20=EA=B5=AC=EC=A1=B0=20=EA=B0=84=EC=86=8C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/collection/Comments.tsx | 6 +++--- src/pages/collection/Hashtags.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/collection/Comments.tsx b/src/pages/collection/Comments.tsx index 4457a87..1de4d7f 100644 --- a/src/pages/collection/Comments.tsx +++ b/src/pages/collection/Comments.tsx @@ -1,9 +1,9 @@ const Comments = () => { return ( -
-

Comments

+ <> + <>Comments

일단 없는 걸로

-
+ ); }; export default Comments; diff --git a/src/pages/collection/Hashtags.tsx b/src/pages/collection/Hashtags.tsx index d2d79cf..e8e96d1 100644 --- a/src/pages/collection/Hashtags.tsx +++ b/src/pages/collection/Hashtags.tsx @@ -1,9 +1,9 @@ const Hashtags = () => { return ( -
-

Hashtags

+ <> + <>Hashtags

일단 없는 걸로

-
+ ); }; export default Hashtags; From 1a014df57b61a9ed09c5b78566dc76a2fabe15f8 Mon Sep 17 00:00:00 2001 From: jungsunbeen Date: Tue, 27 May 2025 22:48:50 +0900 Subject: [PATCH 02/16] =?UTF-8?q?feat:=20=5Fredirects=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/_redirects | 1 + 1 file changed, 1 insertion(+) create mode 100644 public/_redirects diff --git a/public/_redirects b/public/_redirects new file mode 100644 index 0000000..f824337 --- /dev/null +++ b/public/_redirects @@ -0,0 +1 @@ +/* /index.html 200 \ No newline at end of file From b360ba3cf1b900b64310d76c96242b87cccaf045 Mon Sep 17 00:00:00 2001 From: jungsunbeen Date: Thu, 29 May 2025 20:51:59 +0900 Subject: [PATCH 03/16] =?UTF-8?q?feat:=20OpenAI=20API=20=ED=86=B5=EC=8B=A0?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=9C=20sendMessageToGPT=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ package-lock.json | 18 ++++++++++++++++++ package.json | 1 + src/services/gpt/openai.ts | 27 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 src/services/gpt/openai.ts diff --git a/.gitignore b/.gitignore index a547bf3..3b0b403 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ dist-ssr *.njsproj *.sln *.sw? + +.env \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e7a3fb4..714014e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ }, "devDependencies": { "@eslint/js": "^9.25.0", + "@types/node": "^22.15.24", "@types/react": "^19.1.2", "@types/react-dom": "^19.1.2", "@types/react-router-dom": "^5.3.3", @@ -1269,6 +1270,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/node": { + "version": "22.15.24", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.24.tgz", + "integrity": "sha512-w9CZGm9RDjzTh/D+hFwlBJ3ziUaVw7oufKA3vOFSOZlzmW9AkZnfjPb+DLnrV6qtgL/LNmP0/2zBNCFHL3F0ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, "node_modules/@types/react": { "version": "19.1.5", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.5.tgz", @@ -3280,6 +3291,13 @@ "typescript": ">=4.8.4 <5.9.0" } }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 7c109d4..6b2d3a1 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "devDependencies": { "@eslint/js": "^9.25.0", + "@types/node": "^22.15.24", "@types/react": "^19.1.2", "@types/react-dom": "^19.1.2", "@types/react-router-dom": "^5.3.3", diff --git a/src/services/gpt/openai.ts b/src/services/gpt/openai.ts new file mode 100644 index 0000000..afc0ea7 --- /dev/null +++ b/src/services/gpt/openai.ts @@ -0,0 +1,27 @@ +import axios from 'axios'; + +const API_KEY = process.env.REACT_APP_OPENAI_API_KEY; +const API_URL = 'https://api.openai.com/v1/chat/completions'; + +export const sendMessageToGPT = async (message: string) => { + try { + const response = await axios.post( + API_URL, + { + model: 'gpt-3.5-turbo', + messages: [{ role: 'user', content: message }], + }, + { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${API_KEY}`, + }, + } + ); + + return response.data.choices[0].message.content; + } catch (error) { + console.error('GPT API 호출 오류:', error); + throw error; + } +}; From a255cc669167f5a4006f61d5a78362705b323fdc Mon Sep 17 00:00:00 2001 From: jungsunbeen Date: Thu, 29 May 2025 21:14:00 +0900 Subject: [PATCH 04/16] =?UTF-8?q?feat:=20Testpage=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20OpenAI=20?= =?UTF-8?q?API=EC=99=80=EC=9D=98=20=ED=86=B5=EC=8B=A0=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84=20(=EA=B7=BC=EB=8D=B0=20429=EB=9C=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 ++ src/pages/Testpage.tsx | 31 +++++++++++++++++++++++++++++++ src/services/gpt/openai.ts | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/pages/Testpage.tsx diff --git a/src/App.tsx b/src/App.tsx index 6c80a53..4915d9e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,6 +10,7 @@ import SettingPage from "./pages/chatting/SettingPage"; import ChatPage from "./pages/chatting/ChatPage"; import styled from "styled-components"; import WritingPage from "./pages/writing/WritingPage"; +import Testpage from "./pages/Testpage"; function App() { return ( @@ -26,6 +27,7 @@ function App() { } /> } /> + } /> diff --git a/src/pages/Testpage.tsx b/src/pages/Testpage.tsx new file mode 100644 index 0000000..3955b83 --- /dev/null +++ b/src/pages/Testpage.tsx @@ -0,0 +1,31 @@ +import { useState } from 'react'; +import { sendMessageToGPT } from '../services/gpt/openai'; + + +const Testpage = () => { + const [input, setInput] = useState(''); + const [response, setResponse] = useState(''); + + const handleSubmit = async () => { + const result = await sendMessageToGPT(input); + setResponse(result); + }; + + return ( +
+

GPT와 대화하기

+