WildOjisan commited on
Commit
09fa85f
Β·
1 Parent(s): 6960d63
Files changed (1) hide show
  1. routers/llm_router.py +25 -7
routers/llm_router.py CHANGED
@@ -5,6 +5,7 @@ import requests
5
  from fastapi import APIRouter, Form, File, UploadFile
6
  from utils.common import CommonResponse
7
  from utils.db import get_connection
 
8
 
9
  router = APIRouter(
10
  prefix="/llm",
@@ -12,8 +13,14 @@ router = APIRouter(
12
  )
13
 
14
  @router.post("/askllm")
15
- def test_home(userquery: str = Form("")):
 
16
  try:
 
 
 
 
 
17
  with get_connection() as conn:
18
  with conn.cursor() as cur:
19
  cur.execute("""
@@ -55,15 +62,26 @@ def test_home(userquery: str = Form("")):
55
  {
56
  "role": "system",
57
  "content": """
58
- 당신은 μΉœμ ˆν•œ νƒ€λ‘œ μƒλ‹΄μ‚¬μž…λ‹ˆλ‹€.
59
- λ°˜λ“œμ‹œ ν•œκ΅­μ–΄λ‘œ λ‹΅λ³€ν•˜μ„Έμš”.
60
- 닡변은 5λ¬Έμž₯ μ΄λ‚΄λ‘œ 짧게 ν•˜μ„Έμš”.
61
- λ³΅μž‘ν•œ μ„€λͺ…은 ν•˜μ§€ λ§ˆμ„Έμš”.
62
- """
 
 
 
63
  },
64
  {
65
  "role": "user",
66
- "content": userquery
 
 
 
 
 
 
 
 
67
  }
68
  ],
69
  "temperature": 0.8,
 
5
  from fastapi import APIRouter, Form, File, UploadFile
6
  from utils.common import CommonResponse
7
  from utils.db import get_connection
8
+ import json
9
 
10
  router = APIRouter(
11
  prefix="/llm",
 
13
  )
14
 
15
  @router.post("/askllm")
16
+ def test_home(userquery: str = Form("")
17
+ , selected_cards:str = Form("[]") ):
18
  try:
19
+ cards=json.loads(selected_cards)
20
+ card_text = "\n".join([
21
+ f"- {card['position']} μœ„μΉ˜: {card['name']} / {'μ—­λ°©ν–₯' if card['reversed'] else 'μ •λ°©ν–₯'}"
22
+ for card in cards
23
+ ])
24
  with get_connection() as conn:
25
  with conn.cursor() as cur:
26
  cur.execute("""
 
62
  {
63
  "role": "system",
64
  "content": """
65
+ 당신은 μΉœμ ˆν•œ νƒ€λ‘œ μƒλ‹΄μ‚¬μž…λ‹ˆλ‹€.
66
+ λ°˜λ“œμ‹œ ν•œκ΅­μ–΄λ‘œ λ‹΅λ³€ν•˜μ„Έμš”.
67
+ 닡변은 5λ¬Έμž₯ μ΄λ‚΄λ‘œ 짧게 ν•˜μ„Έμš”.
68
+ λ³΅μž‘ν•œ μ„€λͺ…은 ν•˜μ§€ λ§ˆμ„Έμš”.
69
+
70
+ μ‚¬μš©μžκ°€ μ„ νƒν•œ μΉ΄λ“œλŠ” κ³Όκ±°, ν˜„μž¬, 미래 μˆœμ„œμž…λ‹ˆλ‹€.
71
+ 각 μΉ΄λ“œμ˜ μ •λ°©ν–₯/μ—­λ°©ν–₯ 의미λ₯Ό λ°˜μ˜ν•΄μ„œ λ‹΅λ³€ν•˜μ„Έμš”.
72
+ """
73
  },
74
  {
75
  "role": "user",
76
+ "content": f"""
77
+ μ‚¬μš©μž 질문:
78
+ {userquery}
79
+
80
+ μ„ νƒλœ νƒ€λ‘œ μΉ΄λ“œ:
81
+ {card_text}
82
+
83
+ μœ„ 질문과 μ„ νƒλœ μΉ΄λ“œλ₯Ό λ°”νƒ•μœΌλ‘œ 짧게 νƒ€λ‘œ 상담을 ν•΄μ£Όμ„Έμš”.
84
+ """
85
  }
86
  ],
87
  "temperature": 0.8,