Standard AI๋ ๊ฐ์ธ ์์ฐ๊ด๋ฆฌ์ ์ฒญ๋
์ ์ฑ
์๋น์ค๋ฅผ ์ํ AI ๋ฐฑ์๋์
๋๋ค.
FastAPI ๊ธฐ๋ฐ์ผ๋ก ๊ธ์ต์ํ ์ถ์ฒ, ํฌ์ ์ถ์ฒ, ์ ์ฉ๋ฑ๊ธ ๋ถ์, ์์ฐ๊ด๋ฆฌ ์ฑ๋ด, ์ฑํ
ํค์๋ ์ถ์ถ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
- ๊ธ์ต์ํ ์ถ์ฒ RAG
- ํฌ์ ์ํ ์ถ์ฒ
- ์ ์ฉ๋ฑ๊ธ ๊ณ์ฐ ๋ฐ ๊ด๋ฆฌ ํ ์ ๊ณต
- ๊ฐ์ธ ์์ฐ๊ด๋ฆฌ ๋ฐ ์ฒญ๋ ์ ์ฑ ์ฑ๋ด
- ์ฑํ ๊ธฐ๋ก ์ ์ฅ ๋ฐ ์กฐํ
- ์ฑํ ๊ธฐ๋ฐ ํค์๋ ์ถ์ถ
- FastAPI ๊ธฐ๋ฐ REST API ์ ๊ณต
- Docker ๊ธฐ๋ฐ ๋ฐฐํฌ ์ง์
- Python 3.11
- FastAPI
- Uvicorn
- OpenAI API
- LangChain
- FAISS
- MongoDB
- PyMongo
- KeyBERT
- SentenceTransformers
- Pydantic
- Docker
standard_ai/
โโโ app/
โ โโโ main.py # FastAPI ์๋ฒ ์ง์
์
โ โโโ schemas.py # ์์ฒญ ๋ฐ์ดํฐ ์คํค๋ง
โ โโโ chatbot/
โ โ โโโ chatbot_prompt.py # ์์ฐ๊ด๋ฆฌ/์ฒญ๋
์ ์ฑ
์ฑ๋ด ํ๋กฌํํธ
โ โ โโโ chatbot_keyword.py # ์ฑํ
๊ธฐ๋ฐ ํค์๋ ์ถ์ถ
โ โโโ credRate/
โ โ โโโ credRate_prompt.py # ์ ์ฉ๋ฑ๊ธ ๋ถ์ ํ๋กฌํํธ
โ โ โโโ credRate_cal.py # ์ ์ฉ๋ฑ๊ธ ๊ณ์ฐ ๋ก์ง
โ โโโ invRecom/
โ โ โโโ invest_recommend.py # ํฌ์ ์ถ์ฒ ๋ก์ง
โ โ โโโ invRecom_rag.py # ํฌ์ ์ถ์ฒ RAG ๊ตฌ์ฑ
โ โโโ prodRecom/
โ โโโ prodrecom_rag.py # ๊ธ์ต์ํ ์ถ์ฒ RAG ๊ตฌ์ฑ
โ โโโ prodrecom_fewshot.py # ๊ธ์ต์ํ ์ถ์ฒ Few-shot ํ๋กฌํํธ
โ โโโ prodrecom_utils.py # JSON ํ์ฑ ์ ํธ
โโโ rag/
โ โโโ ์ํ์ํ_์ค๋ช
.txt # RAG ๊ฒ์์ฉ ๊ธ์ต์ํ ๋ฌธ์
โโโ requirements.txt
โโโ dockerfile
โโโ README.mdgit clone https://github.com/2025-Standard/standard_ai.git
cd standard_aipython -m venv .venvLinux / macOS:
source .venv/bin/activateWindows PowerShell:
.venv\Scripts\Activate.ps1pip install -r requirements.txtDockerfile ๊ธฐ์ค์ผ๋ก ์ถ๊ฐ ์ค์น๋๋ ์ฃผ์ ํจํค์ง๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
pip install langchain==0.3.23
pip install langchain_openai==0.3.14
pip install langchain_community==0.3.23
pip install langchain_core==0.3.23
pip install faiss-cpu
pip install tf-keras
pip install keybertํ๋ก์ ํธ ๋ฃจํธ์ .env ํ์ผ์ ์์ฑํ๊ณ ์๋ ๊ฐ์ ์ค์ ํฉ๋๋ค.
OPENAI_API_KEY=your_openai_api_key
MONGO_DB_URL=your_mongodb_connection_url| ์ด๋ฆ | ์ค๋ช |
|---|---|
| OPENAI_API_KEY | OpenAI API ํธ์ถ์ ์ฌ์ฉํ๋ ํค |
| MONGO_DB_URL | ์ฑํ ๊ธฐ๋ก ๋ฐ ํค์๋ ์ ์ฅ์ ์ฌ์ฉํ๋ MongoDB ์ฐ๊ฒฐ URL |
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload์๋ฒ ์คํ ํ API ๋ฌธ์๋ ์๋ ๊ฒฝ๋ก์์ ํ์ธํ ์ ์์ต๋๋ค.
http://localhost:8000/api/docs
http://localhost:8000/api/redoc
์ด ํ๋ก์ ํธ๋ Docker ์คํ์ ์ง์ํฉ๋๋ค.
docker build -f dockerfile -t standard-ai .docker run -p 8000:8000 \
-e OPENAI_API_KEY=your_openai_api_key \
-e MONGO_DB_URL=your_mongodb_connection_url \
standard-ai์ฌ์ฉ์์ ๊ฐ์ ๊ธฐ๊ฐ, ์ ํธ ์ํ, ์ง์ญ ์ ๋ณด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ธ์ต์ํ์ ์ถ์ฒํฉ๋๋ค.
POST /api/prodRecom{
"value": 1000000,
"period": "1๋
",
"bank": "KB๊ตญ๋ฏผ์ํ",
"country": "๊ฒฝ๋ถ"
}| ํ๋ | ํ์ | ์ค๋ช |
|---|---|---|
| value | integer | ์์น ๋๋ ํฌ์ ๊ธ์ก |
| period | string | ๊ฐ์ ๊ธฐ๊ฐ |
| bank | string | ์ ํธ ์ํ |
| country | string | ์ง์ญ |
{
"product_name_1": "์ถ์ฒ ์ํ๋ช
",
"interest_rate_1": "๊ธ๋ฆฌ",
"product_reason_1": "์ถ์ฒ ์ด์ ",
"init_term_1": "๊ฐ์
์กฐ๊ฑด",
"period_1": "๊ฐ์
๊ธฐ๊ฐ",
"product_link_1": "์ํ ๋งํฌ"
}์์ต๋ฅ , ํฌ์ ๊ธฐ๊ฐ, ์๊ธ๋ณด์ฅ ์ฌ๋ถ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์๊ธ, ์ ๊ธ, ํ๋, ์ฃผ์ ์ํ์ ์ถ์ฒํฉ๋๋ค.
POST /api/invRecom{
"interestRate": 3.5,
"startDate": "2025-01-01",
"endDate": "2025-12-31",
"principalGuarantee": "Y"
}| ํ๋ | ํ์ | ์ค๋ช |
|---|---|---|
| interestRate | float | ๋ชฉํ ์์ต๋ฅ |
| startDate | date | ํฌ์ ์์์ผ |
| endDate | date | ํฌ์ ์ข ๋ฃ์ผ |
| principalGuarantee | string | ์๊ธ๋ณด์ฅ ์ฌ๋ถ |
[
{
"deposit_reason": "์๊ธ ์ถ์ฒ ์ด์ ",
"deposit_keyword": "์๊ธ ๊ด๋ จ ํค์๋",
"deposit_link": "์๊ธ ์ํ ๋งํฌ",
"savings_reason": "์ ๊ธ ์ถ์ฒ ์ด์ ",
"savings_keyword": "์ ๊ธ ๊ด๋ จ ํค์๋",
"savings_link": "์ ๊ธ ์ํ ๋งํฌ",
"fund_reason": "ํ๋ ์ถ์ฒ ์ด์ ",
"fund_keyword": "ํ๋ ๊ด๋ จ ํค์๋",
"fund_link": "ํ๋ ์ํ ๋งํฌ",
"stock_reason": "์ฃผ์ ์ถ์ฒ ์ด์ ",
"stock_keyword": "์ฃผ์ ๊ด๋ จ ํค์๋",
"stock_link": "์ฃผ์ ๊ด๋ จ ๋งํฌ"
}
]์ฌ์ฉ์์ ๊ฒฐ์ ์ด๋ ฅ, ๋ถ์ฑ์์ค, ์ ์ฉ์ด๋ ฅ, ์ ์ฉ๊ฑฐ๋๋น๋, ์ ๊ท์ ์ฉ๊ฑฐ๋, ์ ์ฉ ์ฌ์ฉ๋ฅ ์ ๊ธฐ๋ฐ์ผ๋ก ์ ์ฉ๋ฑ๊ธ์ ๋ถ์ํฉ๋๋ค.
POST /api/getGrade{
"PH": "12",
"PH_1": 100,
"DL": 300,
"CHL": 2,
"CAF": 5,
"NCA": 1,
"CUR": 30.5
}| ํ๋ | ํ์ | ์ค๋ช |
|---|---|---|
| PH | string | ๊ฒฐ์ ์ด๋ ฅ ๊ธฐ๊ฐ |
| PH_1 | integer | ๊ฒฐ์ ๊ธ์ก |
| DL | integer | ๋ถ์ฑ ์์ค |
| CHL | integer | ์ ์ฉ์ด๋ ฅ |
| CAF | integer | ์ ์ฉ๊ฑฐ๋๋น๋ |
| NCA | integer | ์ ๊ท์ ์ฉ๊ฑฐ๋ |
| CUR | float | ์ ์ฉ ์ฌ์ฉ๋ฅ |
[
{
"result": "์ฌ์ฉ์๋์ ์ ์ฉ๋ฑ๊ธ์ 1๋ฑ๊ธ์
๋๋ค.",
"tip_1": "์ ์ฉ ๊ด๋ฆฌ๋ฅผ ์ํ ํ",
"tip_2": "์ถ๊ฐ ์ ์ฉ ๊ด๋ฆฌ ํ"
}
]MongoDB์ ์ ์ฅ๋ ์ฑํ ๊ธฐ๋ก์ ๋ถ๋ฌ์ต๋๋ค.
GET /api/chat[
{
"role": "user",
"content": "์ฌ์ฉ์ ์ง๋ฌธ"
},
{
"role": "assistant",
"content": "AI ๋ต๋ณ"
}
]๊ฐ์ธ ์์ฐ๊ด๋ฆฌ์ ์ฒญ๋ ์ ์ฑ ๊ด๋ จ ์ง๋ฌธ์ ๋ต๋ณํฉ๋๋ค.
POST /api/ask{
"question": "์ฒญ๋
๋์ฝ๊ณ์ข ๊ฐ์
์กฐ๊ฑด ์๋ ค์ค"
}{
"response": "AI ์ฑ๋ด ๋ต๋ณ"
}์ ์ฅ๋ ์ฑํ ๊ธฐ๋ก์ ๊ธฐ๋ฐ์ผ๋ก ๊ด์ฌ ํค์๋๋ฅผ ์ถ์ถํฉ๋๋ค.
GET /api/key[
"์ผ์๋ฆฌ",
"์ฃผ๊ฑฐ",
"๊ต์ก"
]ํ์ฌ ํ์ฉ๋ Origin์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
http://localhost:5173
https://standard-front-jmhs.vercel.app
ํ๋ก ํธ์๋ ์ฃผ์๊ฐ ๋ณ๊ฒฝ๋๋ฉด app/main.py์ CORS ์ค์ ์ ์์ ํด์ผ ํฉ๋๋ค.
๊ธ์ต์ํ ์ถ์ฒ ๊ธฐ๋ฅ์ rag/์ํ์ํ_์ค๋ช
.txt ํ์ผ์ ์ฝ์ด ๋ฌธ์๋ฅผ ๋ถํ ํ๊ณ , OpenAI Embeddings์ FAISS๋ฅผ ์ฌ์ฉํด ๊ฒ์ ๊ธฐ๋ฐ ์ถ์ฒ์ ์ํํฉ๋๋ค.
๊ธฐ๋ณธ ํ๋ฆ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๊ธ์ต์ํ ์ค๋ช
๋ฌธ์ ๋ก๋
โ ํ
์คํธ ์ฒญํฌ ๋ถํ
โ OpenAI Embeddings ์์ฑ
โ FAISS Vector Store ์์ฑ
โ RetrievalQA๋ก ๊ด๋ จ ์ํ ๊ฒ์
โ GPT ๋ชจ๋ธ๋ก ์ถ์ฒ ๊ฒฐ๊ณผ ์์ฑ
OPENAI_API_KEY๊ฐ ์์ผ๋ฉด ์ฑ๋ด, ์ถ์ฒ, ์ ์ฉ๋ฑ๊ธ ๋ถ์ ๊ธฐ๋ฅ์ด ์ ์ ๋์ํ์ง ์์ต๋๋ค.MONGO_DB_URL์ด ์์ผ๋ฉด ์ฑํ ๊ธฐ๋ก ์ ์ฅ ๋ฐ ์กฐํ ๊ธฐ๋ฅ์ด ์ ์ ๋์ํ์ง ์์ต๋๋ค.rag/์ํ์ํ_์ค๋ช .txtํ์ผ์ด ์์ผ๋ฉด RAG ๊ธฐ๋ฐ ์ํ ์ถ์ฒ ๊ธฐ๋ฅ์ด ๋์ํ์ง ์์ต๋๋ค.__pycache__ํ์ผ์ Git์ ํฌํจํ์ง ์๋ ๊ฒ์ด ์ข์ต๋๋ค.- ๊ธ์ต์ํ, ํฌ์, ์ ์ฉ๋ฑ๊ธ ๊ด๋ จ ๋ต๋ณ์ ์ฐธ๊ณ ์ฉ์ด๋ฉฐ ์ค์ ๊ธ์ต ์์ฌ๊ฒฐ์ ์ ๊ณต์ ๊ธฐ๊ด ๋๋ ์ ๋ฌธ๊ฐ ํ์ธ์ด ํ์ํฉ๋๋ค.
| ์์ญ | ์ค๋ช |
|---|---|
app/main.py |
FastAPI ์๋ํฌ์ธํธ ์ ์ |
prodRecom |
๊ธ์ต์ํ ์ถ์ฒ |
invRecom |
ํฌ์ ์ถ์ฒ |
credRate |
์ ์ฉ๋ฑ๊ธ ๋ถ์ |
chatbot |
์์ฐ๊ด๋ฆฌ/์ฒญ๋ ์ ์ฑ ์ฑ๋ด ๋ฐ ํค์๋ ์ถ์ถ |
rag |
์ถ์ฒ์ ์ฌ์ฉํ ๊ธ์ต์ํ ๋ฌธ์ |
๋ณ๋ ๋ผ์ด์ ์ค๊ฐ ๋ช ์๋์ด ์์ง ์์ต๋๋ค.