Skip to content

Commit

Permalink
(#80) ๐Ÿป INAE: ์ฑ—๋ด‡ ํด๋กœ๋ฐ” ๊ธฐ๋Šฅ๊ณผ ์‹œ๊ฐ„์ˆœ ๋ Œ๋”๋ง ๊ตฌํ˜„ ๋ฐ ๋จธ์ง€
Browse files Browse the repository at this point in the history
(#79) ๐Ÿš€ feat: ์ฑ—๋ด‡ ํด๋กœ๋ฐ” ๊ธฐ๋Šฅ ๊ตฌํ˜„ ๋ฐ ์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ๋””ํ…Œ์ผ ์ˆ˜์ •
Merge pull request #80 from KUSITMS-30th-TEAM-A/feat/#79-chatbotClova
  • Loading branch information
inaemon authored Nov 28, 2024
2 parents b27867d + 9792c45 commit c23868f
Show file tree
Hide file tree
Showing 16 changed files with 375 additions and 207 deletions.
35 changes: 32 additions & 3 deletions src/api/ChatbotApiHandler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

import { getGuide } from "./ChatbotApiService";
import { GuideGetParamsType } from "./ChatbotApiType";
import { postClova, getGuide } from "./ChatbotApiService";
import { ClovaPostRequestType, GuideGetParamsType } from "./ChatbotApiType";

import { getStadiumChatApiData } from "@/src/constants/ChatbotData";


export const handleGetGuideAnswer = async ({stadiumName, categoryName, orderNumber}: GuideGetParamsType) => {
try {
const stadiumApiData = getStadiumChatApiData(stadiumName);
Expand All @@ -17,7 +18,7 @@ export const handleGetGuideAnswer = async ({stadiumName, categoryName, orderNumb
}
);

console.log("์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ๋ฐ์ดํ„ฐ ๋ฐ›์•˜๋‹น >> ", response);
//console.log("์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ๋ฐ์ดํ„ฐ ๋ฐ›์•˜๋‹น >> ", response);

// ํŒŒ์‹ฑ
const data = response.payload;
Expand All @@ -35,4 +36,32 @@ export const handleGetGuideAnswer = async ({stadiumName, categoryName, orderNumb
} catch (error) {
console.error('์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error);
}
};


export const handleGetClovaAnswer = async ({message}: ClovaPostRequestType) => {
try {

// API ์š”์ฒญ
const response = await postClova(
{
message: message,
}
);

console.log("์ฑ—๋ด‡ ํด๋กœ๋ฐ” ๋ฐ์ดํ„ฐ ๋ฐ›์•˜๋‹น >> ", response);

// ํŒŒ์‹ฑ
const data = response.payload;
const parsedData = {
answer: data.answer, // ํด๋กœ๋ฐ” ๋‹ต๋ณ€
};

//console.log(parsedData);

return parsedData;

} catch (error) {
console.error('์ฑ—๋ด‡ ํด๋กœ๋ฐ” ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:', error);
}
};
2 changes: 1 addition & 1 deletion src/api/ChatbotApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { clovaURL, ClovaPostParamsType, ClovaPostRequestType,
/** ๋ฐฑ์—”๋“œ์™€ API ์—ฐ๋™ */
// ์ถ”๊ฐ€: POST ์š”์ฒญ ๋ฐ ์‘๋‹ต๋ฐ›๊ธฐ
export const postClova = async (
{ }: ClovaPostParamsType,
//{ }: ClovaPostParamsType,
{message}: ClovaPostRequestType) => {

try {
Expand Down
Binary file added src/assets/gif/chatbot_loading_baseball_pink.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/svg/chatbot_imagemodal_close_button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/components/dialogs/ImageModal.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React, { useState } from "react";
import Image from "next/image";
import closeButtonIcon from "@/src/assets/svg/chatbot_imagemodal_close_button.svg";

const ImageModal = ({ imageSrc, onClose }: { imageSrc: string, onClose: () => void }) => {
return (
<div className="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50">
<div className="relative bg-white p-4 rounded-lg">
<Image
src={imageSrc}
alt="Enlarged"
alt="ํ™•๋Œ€ ์ด๋ฏธ์ง€"
className="max-w-full max-h-full" />
<button
onClick={onClose}
className="absolute top-0 right-0 w-5 h-5 text-xl mr-3 text-grayscale-50 p-2 rounded-full">
X
className="absolute top-0 right-0 text-grayscale-50 p-2 rounded-full">
<Image src={closeButtonIcon} alt="๋‹ซ๊ธฐ ๋ฒ„ํŠผ" width={24} height={24}/>
</button>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/components/dialogs/ImgUrlModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { useState } from "react";
import Image from "next/image";
import closeButtonIcon from "@/src/assets/svg/chatbot_imagemodal_close_button.svg";

const ImgUrlModal = ({ imageUrl, onClose }: { imageUrl: string, onClose: () => void }) => {
return (
Expand All @@ -7,12 +9,12 @@ const ImgUrlModal = ({ imageUrl, onClose }: { imageUrl: string, onClose: () => v
{/* imageUrl์ด ์™ธ๋ถ€ url(https://) ์ด๋ฉด Image ์ปดํฌ๋„ŒํŠธ๋กœ ๋„์šฐ๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ด์„œ img tag๋กœ ์ถœ๋ ฅ */}
<img
src={imageUrl}
alt="Enlarged"
alt="ํ™•๋Œ€ ์ด๋ฏธ์ง€"
className="max-w-full max-h-full" />
<button
onClick={onClose}
className="absolute top-0 right-0 w-5 h-5 text-xl mr-3 text-grayscale-50 p-2 rounded-full">
X
className="absolute top-0 right-0 text-grayscale-50 p-2 rounded-full">
<Image src={closeButtonIcon} alt="๋‹ซ๊ธฐ ๋ฒ„ํŠผ" width={24} height={24}/>
</button>
</div>
</div>
Expand Down
11 changes: 1 addition & 10 deletions src/constants/ChatbotData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,4 @@ export const getStadiumChatApiData = (frontendStadiumValue: string): string => {

// backendParameters์—์„œ ๋งค์นญ๋˜๋Š” ๊ฐ’ ๋ฐ˜ํ™˜
return backendParameters[index];
};

export interface GuideResponseData {
answer: string; // ๋ฐฑ์—”๋“œ๋กœ๋ถ€ํ„ฐ ๋ฐ›์€ ์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ๋‹ต๋ณ€ ๋ฐ์ดํ„ฐ
imgUrl: string; // ๋ฐฑ์—”๋“œ๋กœ๋ถ€ํ„ฐ ๋ฐ›์€ ์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ
categoryNumber: number; // ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ํฐ ์นดํ…Œ๊ณ ๋ฆฌ
categoryName: string; // ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ํฐ ์นดํ…Œ๊ณ ๋ฆฌ๋ช…
subcategoryNumber: number; // ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ์„ธ๋ถ€ ์นดํ…Œ๊ณ ๋ฆฌ
subCategoryName: string; // ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ์„ธ๋ถ€ ์นดํ…Œ๊ณ ๋ฆฌ๋ช…
}
};
Loading

0 comments on commit c23868f

Please sign in to comment.