hyunjunian commited on
Commit
7edad11
ยท
1 Parent(s): 22bfd17

update to instructor's version

Browse files
Files changed (2) hide show
  1. app.py +187 -58
  2. openai_gradio_20250314_dynamic 1.ipynb +228 -0
app.py CHANGED
@@ -1,64 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
-
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
-
9
-
10
- def respond(
11
- message,
12
- history: list[tuple[str, str]],
13
- system_message,
14
- max_tokens,
15
- temperature,
16
- top_p,
17
- ):
18
- messages = [{"role": "system", "content": system_message}]
19
-
20
- for val in history:
21
- if val[0]:
22
- messages.append({"role": "user", "content": val[0]})
23
- if val[1]:
24
- messages.append({"role": "assistant", "content": val[1]})
25
-
26
- messages.append({"role": "user", "content": message})
27
-
28
- response = ""
29
-
30
- for message in client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- stream=True,
34
- temperature=temperature,
35
- top_p=top_p,
36
- ):
37
- token = message.choices[0].delta.content
38
-
39
- response += token
40
- yield response
41
-
42
-
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
- demo = gr.ChatInterface(
47
- respond,
48
- additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
- gr.Slider(
53
- minimum=0.1,
54
- maximum=1.0,
55
- value=0.95,
56
- step=0.05,
57
- label="Top-p (nucleus sampling)",
58
- ),
59
  ],
60
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  if __name__ == "__main__":
64
  demo.launch()
 
1
+ # import gradio as gr
2
+ # from huggingface_hub import InferenceClient
3
+
4
+ # """
5
+ # For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
+ # """
7
+ # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
+
9
+
10
+ # def respond(
11
+ # message,
12
+ # history: list[tuple[str, str]],
13
+ # system_message,
14
+ # max_tokens,
15
+ # temperature,
16
+ # top_p,
17
+ # ):
18
+ # messages = [{"role": "system", "content": system_message}]
19
+
20
+ # for val in history:
21
+ # if val[0]:
22
+ # messages.append({"role": "user", "content": val[0]})
23
+ # if val[1]:
24
+ # messages.append({"role": "assistant", "content": val[1]})
25
+
26
+ # messages.append({"role": "user", "content": message})
27
+
28
+ # response = ""
29
+
30
+ # for message in client.chat_completion(
31
+ # messages,
32
+ # max_tokens=max_tokens,
33
+ # stream=True,
34
+ # temperature=temperature,
35
+ # top_p=top_p,
36
+ # ):
37
+ # token = message.choices[0].delta.content
38
+
39
+ # response += token
40
+ # yield response
41
+
42
+
43
+ # """
44
+ # For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
+ # """
46
+ # demo = gr.ChatInterface(
47
+ # respond,
48
+ # additional_inputs=[
49
+ # gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
+ # gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
+ # gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
+ # gr.Slider(
53
+ # minimum=0.1,
54
+ # maximum=1.0,
55
+ # value=0.95,
56
+ # step=0.05,
57
+ # label="Top-p (nucleus sampling)",
58
+ # ),
59
+ # ],
60
+ # )
61
+
62
+
63
+ # if __name__ == "__main__":
64
+ # demo.launch()
65
+
66
+
67
  import gradio as gr
68
+ import requests
69
+ import re
70
+
71
+ # endpoint :
72
+ deployment_name = "fimtrus-gpt-4o-ncus"
73
+ endpoint = "https://fimtrus-openai-ncus.openai.azure.com/openai/deployments/{}/chat/completions".format(deployment_name)
74
+ api_key = "FP7k76c0BGmz4MVot1LVqdtqcmQaKBeerYdFyXzW4NXN0940rRfEJQQJ99BCACHrzpqXJ3w3AAABACOG8189"
75
+
76
+ ai_search_endpoint = "https://fimtrus-ai-search3.search.windows.net"
77
+ ai_search_key = "lw8TYxNHT14hpM5oJQhCL3iOxR4PR494dV4RLDaiwzAzSeBecA5i"
78
+ ai_search_index_name = "travel-index-microsoft2"
79
+ ai_search_semantic = "travel-semantic"
80
+
81
+
82
+ def request_gpt(prompt):
83
+ query_params = {
84
+ "api-version": "2025-02-01-preview"
85
+ }
86
+ headers = {
87
+ "Content-Type": "application/json",
88
+ "api-key": api_key
89
+ }
90
+
91
+ body = {
92
+ "data_sources": [
93
+ {
94
+ "type": "azure_search",
95
+ "parameters": {
96
+ "endpoint": ai_search_endpoint,
97
+ "index_name": ai_search_index_name,
98
+ "semantic_configuration": ai_search_semantic,
99
+ "query_type": "semantic",
100
+ "fields_mapping": {},
101
+ "in_scope": True,
102
+ "filter": None,
103
+ "strictness": 3,
104
+ "top_n_documents": 3,
105
+ "authentication": {
106
+ "type": "api_key",
107
+ "key": ai_search_key
108
+ },
109
+ "key": ai_search_key
110
+ }
111
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  ],
113
+ "messages": [
114
+ {
115
+ "role": "system",
116
+ "content": "์‚ฌ์šฉ์ž๊ฐ€ ์ •๋ณด๋ฅผ ์ฐพ๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” AI ๋„์šฐ๋ฏธ์ž…๋‹ˆ๋‹ค."
117
+ },
118
+ {
119
+ "role": "user",
120
+ "content": prompt
121
+ }
122
+ ],
123
+ "temperature": 0.7,
124
+ "top_p": 0.95,
125
+ "max_tokens": 800,
126
+ "stop": None,
127
+ "stream": False,
128
+ "frequency_penalty": 0,
129
+ "presence_penalty": 0
130
+ }
131
+
132
+ response = requests.post(endpoint, params=query_params, headers=headers, json=body)
133
+
134
+ if response.status_code == 200:
135
+ response_json = response.json()
136
+ message = response_json['choices'][0]['message']
137
+ content = message['content']
138
+
139
+ content = re.sub(r'\[doc(\d+)\]', r'[์ฐธ์กฐ \1]', content)
140
+
141
+ if message['context']:
142
+ citation_list = message['context']['citations']
143
+ else:
144
+ citation_list = list()
145
+ return content, citation_list
146
+ else:
147
+ return "", list()
148
 
149
+ with gr.Blocks() as demo:
150
+
151
+ citation_state = gr.State([])
152
+
153
+ def click_send(prompt, histories):
154
+ print(prompt)
155
+ content, citation_list = request_gpt(prompt=prompt)
156
+ message_list = [{"role": "user", "content": prompt}, {"role": "assistant", "content": content}]
157
+ histories.extend(message_list)
158
+
159
+ print(histories)
160
+ print(len(citation_list), citation_list)
161
+ return histories, citation_list, ""
162
+
163
+ def select_tab(citation):
164
+ print("tab!!!!!!")
165
+ return gr.Textbox(label="", value=citation, lines=10, max_lines=10, visible=True)
166
+
167
+ gr.Markdown("# ๋‚˜์˜ GPT ์›”๋“œ")
168
+
169
+ with gr.Row():
170
+ chatbot = gr.Chatbot(label="๋‚˜์˜ GPT", type="messages", scale=3)
171
+
172
+ with gr.Column(scale=1):
173
+ @gr.render(inputs=[citation_state])
174
+ def render_citations(citations):
175
+ print(citations)
176
+ for index in range(len(citations)):
177
+ content = citations[index]['content']
178
+ key = "์ฐธ์กฐ{}".format(index + 1)
179
+ if index == 0:
180
+ gr.Tab("", id=-1, visible=False)
181
+ with gr.Tab(key) as tab:
182
+ citation_textbox = gr.Textbox(label="", value=content, lines=10, max_lines=10, visible=False)
183
+ tab.select(fn=select_tab, inputs=[citation_textbox], outputs=[citation_textbox])
184
+
185
+ with gr.Row():
186
+ prompt_textbox = gr.Textbox(label="ํ”„๋กฌํ”„ํŠธ", placeholder="ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.", scale=6)
187
+ send_button = gr.Button("์ „์†ก", scale=1)
188
+
189
+ send_button.click(click_send, inputs=[prompt_textbox, chatbot], outputs=[chatbot, citation_state, prompt_textbox])
190
+ prompt_textbox.submit(click_send, inputs=[prompt_textbox, chatbot], outputs=[chatbot, citation_state, prompt_textbox])
191
 
192
  if __name__ == "__main__":
193
  demo.launch()
openai_gradio_20250314_dynamic 1.ipynb ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "* Running on local URL: http://127.0.0.1:7870\n",
13
+ "\n",
14
+ "To create a public link, set `share=True` in `launch()`.\n"
15
+ ]
16
+ },
17
+ {
18
+ "data": {
19
+ "text/html": [
20
+ "<div><iframe src=\"http://127.0.0.1:7870/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
21
+ ],
22
+ "text/plain": [
23
+ "<IPython.core.display.HTML object>"
24
+ ]
25
+ },
26
+ "metadata": {},
27
+ "output_type": "display_data"
28
+ },
29
+ {
30
+ "data": {
31
+ "text/plain": []
32
+ },
33
+ "execution_count": 11,
34
+ "metadata": {},
35
+ "output_type": "execute_result"
36
+ },
37
+ {
38
+ "name": "stdout",
39
+ "output_type": "stream",
40
+ "text": [
41
+ "[]\n",
42
+ "์„œ๋ฉด ๊ฐˆ๋งŒํ•œ๊ณณ\n",
43
+ "[{'role': 'user', 'content': '์„œ๋ฉด ๊ฐˆ๋งŒํ•œ๊ณณ'}, {'role': 'assistant', 'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด์—์„œ ๊ฐˆ๋งŒํ•œ ๊ณณ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:\\n\\n1. **์Šคํฌ์ธ ํŒŒํฌ**: ์ด๊ณณ์€ ๋‚จํ•ด๊ตฐ์˜ ๋Œ€ํ‘œ์ ์ธ ์ถ•๊ตฌ ํ›ˆ๋ จ์žฅ์œผ๋กœ, ๊ณ„์ ˆ์— ๊ด€๊ณ„์—†์ด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์‹œ์„ค์ž…๋‹ˆ๋‹ค. ์ „๊ตญ ๊ฐ์ง€์˜ ์ „์ง€ํ›ˆ๋ จ๊ฐ๋“ค์ด ๋งŽ์ด ์ฐพ๋Š” ๊ณณ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 1].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ์Šคํฌ์ธ ํŒŒํฌ๊ธธ 74\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-8661\\n\\n2. **์žฅํ•ญ๊ฑฐ๋ฆฌ**: ์ด๊ณณ์€ ์‚ฌ๊ณ„์ ˆ ๋‚ด๋‚ด ๊ฐ€์กฑ ๋‹จ์œ„ ๊ด€๊ด‘๊ฐ๋“ค์ด ์ฆ๊ธฐ๊ธฐ ์ข‹์€ ์žฅ์†Œ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 2].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋‚จ์„œ๋Œ€๋กœ1517๋ฒˆ๊ธธ 31\\n\\n3. **๋ง์šด์‚ฐ ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€**: 5์›”์— ์ฒ ์ญ‰์ด ๋งŒ๊ฐœํ•˜๋Š” ์ด๊ณณ์€ ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์ฐพ๋Š” ๋ช…์†Œ์ž…๋‹ˆ๋‹ค. ์ •์ƒ๊นŒ์ง€๋Š” ์•ฝ 1์‹œ๊ฐ„ 30๋ถ„ ์ •๋„ ์†Œ์š”๋ฉ๋‹ˆ๋‹ค [์ฐธ์กฐ 3].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋…ธ๊ตฌ๋ฆฌ ์‚ฐ 786m\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-3676'}]\n",
44
+ "3 [{'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ์Šคํฌ์ธ ํŒŒํฌ๊ธธ 74\\n2002๋…„ ์›”๋“œ์ปต์ด ์œ ์น˜๋˜๋ฉด์„œ ๋‚จํ•ด์˜ ์ถ•๊ตฌ์—ด๊ธฐ๊ฐ€ ๊ณ ์กฐ๋˜์—ˆ๋‹ค. ๋งŽ์€ ์ด๋“ค์˜ ์ˆ˜์š”์„ ์ถฉ์กฑํ•˜๊ธฐ ์œ„ํ•ด ์กฐ์„ฑ๋œ ๋‚จํ•ด์˜ ์ž”๋”” ๊ตฌ์žฅ์€ ๊ณ„์ ˆ์— ๊ด€๊ณ„์—†์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด ์ „๊ตญ๊ฐ์ง€์˜ ์ „์ง€ํ›ˆ๋ จ๊ฐ๋“ค์—๊ฒŒ ์‚ฌ๋ž‘๋ฐ›๊ณ  ์žˆ๋‹ค. ์‚ฐ์ฑ…๋กœ๊ฐ€ ์กฐ์„ฑ๋˜์–ด ์žˆ์–ด ์‚ฐ์ฑ…ํ•˜๊ธฐ๋„ ์•ˆ์„ฑ๋งž์ถค์ด๋‹ค.\\nY\\n34.8054935\\n127.8337739\\n์Šคํฌ์ธ ํŒŒํฌ\\n055-860-8661\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋‚จ์„œ๋Œ€๋กœ1517๋ฒˆ๊ธธ 31\\nN\\n34.8004847\\n127.8364069\\n์žฅํ•ญ๊ฑฐ๋ฆฌ\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋…ธ๊ตฌ๋ฆฌ ์‚ฐ98\\n786m, ๋‚จํ•ด ์ตœ๊ณ  ๋†’์ด๋ฅผ ์ž๋ž‘ํ•˜๋Š” ๋ง์šด์‚ฐ. 5์›”์—๋Š” ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€์˜ ๊ฝƒ๋“ค์ด ๋งŒ๊ฐœํ•ด ๊ฐ€์กฑ๋‹จ์œ„๋‚˜ ์นœ๋ชฉํšŒ ๋“ฑ์˜ ๋ชจ์ž„์—์„œ ๋งŽ์ด ์ฐพ์•„์˜ค๋ฉฐ, ์ •์ƒ๊นŒ์ง€๋Š” 1์‹œ๊ฐ„ 30๋ถ„์ •๋„ ์†Œ์š”๋œ๋‹ค. ๋‚จํ•ด์์—์„œ ๊ด€๊ด‘์•ˆ๋‚ดํŒ์„ ๋”ฐ๋ผ ๋‚จํ•ด๋Œ€๊ต ๋ฐฉํ–ฅ์œผ๋กœ 3๋ถ„ ์ •๋„ ๊ฐ€๋ฉด ๊ณ ํ˜„๋ฉด ์ด์–ด๋งˆ์„์ด ๋‚˜ํƒ€๋‚œ๋‹ค.\\nY\\n34.8569462\\n127.8514638\\n๋ง์šด์‚ฐ ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€\\n10\\n055-860-3676\\n๋ด„, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ๋ฒ„์Šค, ์šฐ์ •็”ท, ๋‚˜ํ™€๋กœ, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}]\n",
45
+ "[{'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ์Šคํฌ์ธ ํŒŒํฌ๊ธธ 74\\n2002๋…„ ์›”๋“œ์ปต์ด ์œ ์น˜๋˜๋ฉด์„œ ๋‚จํ•ด์˜ ์ถ•๊ตฌ์—ด๊ธฐ๊ฐ€ ๊ณ ์กฐ๋˜์—ˆ๋‹ค. ๋งŽ์€ ์ด๋“ค์˜ ์ˆ˜์š”์„ ์ถฉ์กฑํ•˜๊ธฐ ์œ„ํ•ด ์กฐ์„ฑ๋œ ๋‚จํ•ด์˜ ์ž”๋”” ๊ตฌ์žฅ์€ ๊ณ„์ ˆ์— ๊ด€๊ณ„์—†์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด ์ „๊ตญ๊ฐ์ง€์˜ ์ „์ง€ํ›ˆ๋ จ๊ฐ๋“ค์—๊ฒŒ ์‚ฌ๋ž‘๋ฐ›๊ณ  ์žˆ๋‹ค. ์‚ฐ์ฑ…๋กœ๊ฐ€ ์กฐ์„ฑ๋˜์–ด ์žˆ์–ด ์‚ฐ์ฑ…ํ•˜๊ธฐ๋„ ์•ˆ์„ฑ๋งž์ถค์ด๋‹ค.\\nY\\n34.8054935\\n127.8337739\\n์Šคํฌ์ธ ํŒŒํฌ\\n055-860-8661\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋‚จ์„œ๋Œ€๋กœ1517๋ฒˆ๊ธธ 31\\nN\\n34.8004847\\n127.8364069\\n์žฅํ•ญ๊ฑฐ๋ฆฌ\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋…ธ๊ตฌ๋ฆฌ ์‚ฐ98\\n786m, ๋‚จํ•ด ์ตœ๊ณ  ๋†’์ด๋ฅผ ์ž๋ž‘ํ•˜๋Š” ๋ง์šด์‚ฐ. 5์›”์—๋Š” ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€์˜ ๊ฝƒ๋“ค์ด ๋งŒ๊ฐœํ•ด ๊ฐ€์กฑ๋‹จ์œ„๋‚˜ ์นœ๋ชฉํšŒ ๋“ฑ์˜ ๋ชจ์ž„์—์„œ ๋งŽ์ด ์ฐพ์•„์˜ค๋ฉฐ, ์ •์ƒ๊นŒ์ง€๋Š” 1์‹œ๊ฐ„ 30๋ถ„์ •๋„ ์†Œ์š”๋œ๋‹ค. ๋‚จํ•ด์์—์„œ ๊ด€๊ด‘์•ˆ๋‚ดํŒ์„ ๋”ฐ๋ผ ๋‚จํ•ด๋Œ€๊ต ๋ฐฉํ–ฅ์œผ๋กœ 3๋ถ„ ์ •๋„ ๊ฐ€๋ฉด ๊ณ ํ˜„๋ฉด ์ด์–ด๋งˆ์„์ด ๋‚˜ํƒ€๋‚œ๋‹ค.\\nY\\n34.8569462\\n127.8514638\\n๋ง์šด์‚ฐ ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€\\n10\\n055-860-3676\\n๋ด„, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ๋ฒ„์Šค, ์šฐ์ •็”ท, ๋‚˜ํ™€๋กœ, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}]\n",
46
+ "๋‚จํ•ด์ ๊ฐˆ๋งŒํ•œ๊ณณ\n",
47
+ "[{'role': 'user', 'metadata': {'title': None}, 'content': '์„œ๋ฉด ๊ฐˆ๋งŒํ•œ๊ณณ', 'options': None}, {'role': 'assistant', 'metadata': {'title': None}, 'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด์—์„œ ๊ฐˆ๋งŒํ•œ ๊ณณ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:\\n\\n1. **์Šคํฌ์ธ ํŒŒํฌ**: ์ด๊ณณ์€ ๋‚จํ•ด๊ตฐ์˜ ๋Œ€ํ‘œ์ ์ธ ์ถ•๊ตฌ ํ›ˆ๋ จ์žฅ์œผ๋กœ, ๊ณ„์ ˆ์— ๊ด€๊ณ„์—†์ด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์‹œ์„ค์ž…๋‹ˆ๋‹ค. ์ „๊ตญ ๊ฐ์ง€์˜ ์ „์ง€ํ›ˆ๋ จ๊ฐ๋“ค์ด ๋งŽ์ด ์ฐพ๋Š” ๊ณณ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 1].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ์Šคํฌ์ธ ํŒŒํฌ๊ธธ 74\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-8661\\n\\n2. **์žฅํ•ญ๊ฑฐ๋ฆฌ**: ์ด๊ณณ์€ ์‚ฌ๊ณ„์ ˆ ๋‚ด๋‚ด ๊ฐ€์กฑ ๋‹จ์œ„ ๊ด€๊ด‘๊ฐ๋“ค์ด ์ฆ๊ธฐ๊ธฐ ์ข‹์€ ์žฅ์†Œ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 2].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋‚จ์„œ๋Œ€๋กœ1517๋ฒˆ๊ธธ 31\\n\\n3. **๋ง์šด์‚ฐ ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€**: 5์›”์— ์ฒ ์ญ‰์ด ๋งŒ๊ฐœํ•˜๋Š” ์ด๊ณณ์€ ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์ฐพ๋Š” ๋ช…์†Œ์ž…๋‹ˆ๋‹ค. ์ •์ƒ๊นŒ์ง€๋Š” ์•ฝ 1์‹œ๊ฐ„ 30๋ถ„ ์ •๋„ ์†Œ์š”๋ฉ๋‹ˆ๋‹ค [์ฐธ์กฐ 3].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋…ธ๊ตฌ๋ฆฌ ์‚ฐ 786m\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-3676', 'options': None}, {'role': 'user', 'content': '๋‚จํ•ด์ ๊ฐˆ๋งŒํ•œ๊ณณ'}, {'role': 'assistant', 'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด์์—์„œ ๊ฐˆ๋งŒํ•œ ๊ณณ์œผ๋กœ๋Š” ๋‹ค์Œ ์žฅ์†Œ๋“ค์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค:\\n\\n1. **๋‚จํ•ด๋ฌธํ™”์›**\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-864-6969\\n - ๊ด€๊ด‘์ง€๋กœ ์ถ”์ฒœ๋ฉ๋‹ˆ๋‹ค [์ฐธ์กฐ 1].\\n\\n2. **๋‚จํ•ด๋ฌธํ™”์„ผํ„ฐ**\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-8621\\n - ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ์—๋„ ์ ํ•ฉํ•˜๋ฉฐ ์ž๊ฐ€์šฉ, ๋ ŒํŠธ, ์นœ๊ตฌ, ๊ฐ€์กฑ, ์—ฐ์ธ๊ณผ ํ•จ๊ป˜ ๋ฐฉ๋ฌธํ•˜๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค [์ฐธ์กฐ 2].\\n\\n3. **๋ฒ•๋ฅœ์‚ฌ**\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ๋ง์šด๋กœ 10๋ฒˆ๊ธธ 45-1\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-864-3243\\n - ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ ๋ชจ๋‘ ๋ฐฉ๋ฌธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ž๊ฐ€์šฉ, ๋ ŒํŠธ, ์นœ๊ตฌ, ๊ฐ€์กฑ, ์—ฐ์ธ๊ณผ ํ•จ๊ป˜ํ•˜๊ธฐ ์ข‹์€ ์žฅ์†Œ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 3].'}]\n",
48
+ "3 [{'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\nY\\nhttp://www.ccnh.or.kr/html/main/main.php\\n34.8451138\\n127.8995432\\n๋‚จํ•ด๋ฌธํ™”์›\\n055-864-6969\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\nY\\n34.8451138\\n127.8995432\\n๋‚จํ•ด๋ฌธํ™”์„ผํ„ฐ\\n055-860-8621\\n๋ด„, ์—ฌ๋ฆ„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ๋ง์šด๋กœ10๋ฒˆ๊ธธ 45-1\\nY\\n34.8421872\\n127.89268\\n๋ฒ•ํฅ์‚ฌ\\n055-864-3243\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ\\n๊ด€๊ด‘์ง€\\n์ „ํ†ต์‚ฌ์ฐฐ ์ œ104ํ˜ธ', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}]\n",
49
+ "[{'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\nY\\nhttp://www.ccnh.or.kr/html/main/main.php\\n34.8451138\\n127.8995432\\n๋‚จํ•ด๋ฌธํ™”์›\\n055-864-6969\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\nY\\n34.8451138\\n127.8995432\\n๋‚จํ•ด๋ฌธํ™”์„ผํ„ฐ\\n055-860-8621\\n๋ด„, ์—ฌ๋ฆ„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ๋ง์šด๋กœ10๋ฒˆ๊ธธ 45-1\\nY\\n34.8421872\\n127.89268\\n๋ฒ•ํฅ์‚ฌ\\n055-864-3243\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ\\n๊ด€๊ด‘์ง€\\n์ „ํ†ต์‚ฌ์ฐฐ ์ œ104ํ˜ธ', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}]\n",
50
+ "tab!!!!!!\n",
51
+ "tab!!!!!!\n",
52
+ "tab!!!!!!\n",
53
+ "tab!!!!!!\n",
54
+ "tab!!!!!!\n",
55
+ "๋™๋ฉด ๊ฐˆ๋งŒํ•œ๊ณณ\n",
56
+ "[{'role': 'user', 'metadata': {'title': None}, 'content': '์„œ๋ฉด ๊ฐˆ๋งŒํ•œ๊ณณ', 'options': None}, {'role': 'assistant', 'metadata': {'title': None}, 'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด์—์„œ ๊ฐˆ๋งŒํ•œ ๊ณณ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:\\n\\n1. **์Šคํฌ์ธ ํŒŒํฌ**: ์ด๊ณณ์€ ๋‚จํ•ด๊ตฐ์˜ ๋Œ€ํ‘œ์ ์ธ ์ถ•๊ตฌ ํ›ˆ๋ จ์žฅ์œผ๋กœ, ๊ณ„์ ˆ์— ๊ด€๊ณ„์—†์ด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์‹œ์„ค์ž…๋‹ˆ๋‹ค. ์ „๊ตญ ๊ฐ์ง€์˜ ์ „์ง€ํ›ˆ๋ จ๊ฐ๋“ค์ด ๋งŽ์ด ์ฐพ๋Š” ๊ณณ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 1].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ์Šคํฌ์ธ ํŒŒํฌ๊ธธ 74\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-8661\\n\\n2. **์žฅํ•ญ๊ฑฐ๋ฆฌ**: ์ด๊ณณ์€ ์‚ฌ๊ณ„์ ˆ ๋‚ด๋‚ด ๊ฐ€์กฑ ๋‹จ์œ„ ๊ด€๊ด‘๊ฐ๋“ค์ด ์ฆ๊ธฐ๊ธฐ ์ข‹์€ ์žฅ์†Œ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 2].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋‚จ์„œ๋Œ€๋กœ1517๋ฒˆ๊ธธ 31\\n\\n3. **๋ง์šด์‚ฐ ์ฒ ์ญ‰๊ตฐ๋ฝ์ง€**: 5์›”์— ์ฒ ์ญ‰์ด ๋งŒ๊ฐœํ•˜๋Š” ์ด๊ณณ์€ ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด ์ฐพ๋Š” ๋ช…์†Œ์ž…๋‹ˆ๋‹ค. ์ •์ƒ๊นŒ์ง€๋Š” ์•ฝ 1์‹œ๊ฐ„ 30๋ถ„ ์ •๋„ ์†Œ์š”๋ฉ๋‹ˆ๋‹ค [์ฐธ์กฐ 3].\\n - ์œ„์น˜: ๊ฒฝ์ƒ๏ฟฝ๏ฟฝ๏ฟฝ๋„ ๋‚จํ•ด๊ตฐ ์„œ๋ฉด ๋…ธ๊ตฌ๋ฆฌ ์‚ฐ 786m\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-3676', 'options': None}, {'role': 'user', 'metadata': {'title': None}, 'content': '๋‚จํ•ด์ ๊ฐˆ๋งŒํ•œ๊ณณ', 'options': None}, {'role': 'assistant', 'metadata': {'title': None}, 'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด์์—์„œ ๊ฐˆ๋งŒํ•œ ๊ณณ์œผ๋กœ๋Š” ๋‹ค์Œ ์žฅ์†Œ๋“ค์„ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค:\\n\\n1. **๋‚จํ•ด๋ฌธํ™”์›**\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-864-6969\\n - ๊ด€๊ด‘์ง€๋กœ ์ถ”์ฒœ๋ฉ๋‹ˆ๋‹ค [์ฐธ์กฐ 1].\\n\\n2. **๋‚จํ•ด๋ฌธํ™”์„ผํ„ฐ**\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ์„ ์†Œ๋กœ 12\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-8621\\n - ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ์—๋„ ์ ํ•ฉํ•˜๋ฉฐ ์ž๊ฐ€์šฉ, ๋ ŒํŠธ, ์นœ๊ตฌ, ๊ฐ€์กฑ, ์—ฐ์ธ๊ณผ ํ•จ๊ป˜ ๋ฐฉ๋ฌธํ•˜๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค [์ฐธ์กฐ 2].\\n\\n3. **๋ฒ•๋ฅœ์‚ฌ**\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋‚จํ•ด์ ๋ง์šด๋กœ 10๋ฒˆ๊ธธ 45-1\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-864-3243\\n - ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ ๋ชจ๋‘ ๋ฐฉ๋ฌธํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ž๊ฐ€์šฉ, ๋ ŒํŠธ, ์นœ๊ตฌ, ๊ฐ€์กฑ, ์—ฐ์ธ๊ณผ ํ•จ๊ป˜ํ•˜๊ธฐ ์ข‹์€ ์žฅ์†Œ์ž…๋‹ˆ๋‹ค [์ฐธ์กฐ 3].', 'options': None}, {'role': 'user', 'content': '๋™๋ฉด ๊ฐˆ๋งŒํ•œ๊ณณ'}, {'role': 'assistant', 'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ๋™๋ฉด์—๋Š” ๋‹ค์–‘ํ•œ ๊ด€๊ด‘์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๋™๋ฉด๊ณผ ๊ฐ€๊นŒ์šด ๊ด€๊ด‘์ง€ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค:\\n\\n1. **์‚ผ๋™๋ฉด**: \\n - ๊ด€๊ด‘์ง€๋ช…: ์ฐฝ์„ ๊ต\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์‚ผ๋™๋ฉด\\n - ์ „ํ™”๋ฒˆํ˜ธ: 055-860-3311\\n - ๊ณ„์ ˆ๋ณ„๋กœ ๋ฐฉ๋ฌธ ๊ฐ€๋Šฅ: ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ\\n - ์ฃผ์š” ํ…Œ๋งˆ: ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ์šฐ์ •์—ฌํ–‰, ์—ฐ์ธ, ๋‚˜ํ™€๋กœ ์—ฌํ–‰\\n - [์ฐธ์กฐ 1]\\n\\n2. **๋‚จํ•ด๊ตฐ ์ด๋™๋ฉด**:\\n - ๊ด€๊ด‘์ง€๋ช…: ๋ฏธ๊ตญ๋งˆ์„\\n - ์ฃผ์†Œ: ๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์ด๋™๋ฉด ๋ฏธ๊ตญ๋งˆ์„๊ธธ\\n - ์ „ํ™”๋ฒˆํ˜ธ: 1588-3415\\n - ๊ณ„์ ˆ๋ณ„๋กœ ๋ฐฉ๋ฌธ ๊ฐ€๋Šฅ: ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ\\n - ์ฃผ์š” ํ…Œ๋งˆ: ๋งˆ์„์—ฌํ–‰, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ์—ฐ์ธ, ์šฐ์ •์—ฌํ–‰, ํ‚ค์ฆˆ, ๋‚˜ํ™€๋กœ ์—ฌํ–‰, ๋‹จ์ฒด\\n - [์ฐธ์กฐ 3]\\n\\n์ด ์ •๋ณด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์—ฌํ–‰ ๊ณ„ํš์„ ์„ธ์šฐ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.'}]\n",
57
+ "3 [{'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์‚ผ๋™๋ฉด\\nY\\n34.830993\\n128.0010063\\n์ฐฝ์„ ๊ต\\n055-860-3311\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ๋‚˜ํ™€๋กœ\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๋‚จํ•ด๊ตฐ ๋…ธ๋Ÿ‰๋กœ183๋ฒˆ๊ธธ 27\\nY\\n34.9419198\\n127.875899\\n๋‚จํ•ด์ถฉ๋ ฌ์‚ฌ์™€ ๋…ธ๋Ÿ‰ํšŒํƒ€์šด\\n055-860-3311\\n๊ด€๊ด‘๋ช…์†Œ, ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์ด๋™๋ฉด ๋ฏธ๊ตญ๋งˆ์„๊ธธ\\n๋ฏธ๊ตญํ˜• ์ „ํ†ต ๊ฑด์ถ•์–‘์‹์ธ ๊ณ ๊ธ‰ ๋ฏผ๋ฐ•ํ˜• ํŒฌ์…˜๊ณผ ์ „์›์ฃผ๊ฑฐ๊ฐ€ ๊ฒฐํ•ฉ๋œ ์ฃผํƒ์„ ๊ฑด๋ฆฝํ•˜์—ฌ ํŠน์ƒ‰ ์žˆ๋Š” ๊ด€๊ด‘์ธํ”„๋ผ๋ฅผ ๊ตฌ์ถ•ํ•˜๊ณ  ์žˆ๋‹ค.\\nY\\n34.7806685\\n127.9281169\\n๋ฏธ๊ตญ๋งˆ์„\\n1588-3415\\n๋งˆ์„์—ฌํ–‰, ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}]\n",
58
+ "[{'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์‚ผ๋™๋ฉด\\nY\\n34.830993\\n128.0010063\\n์ฐฝ์„ ๊ต\\n055-860-3311\\n๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ๋‚˜ํ™€๋กœ\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๋‚จํ•ด๊ตฐ ๋…ธ๋Ÿ‰๋กœ183๋ฒˆ๊ธธ 27\\nY\\n34.9419198\\n127.875899\\n๋‚จํ•ด์ถฉ๋ ฌ์‚ฌ์™€ ๋…ธ๋Ÿ‰ํšŒํƒ€์šด\\n055-860-3311\\n๊ด€๊ด‘๋ช…์†Œ, ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‚˜ํ™€๋กœ, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}, {'content': '๊ฒฝ์ƒ๋‚จ๋„ ๋‚จํ•ด๊ตฐ ์ด๋™๋ฉด ๋ฏธ๊ตญ๋งˆ์„๊ธธ\\n๋ฏธ๊ตญํ˜• ์ „ํ†ต ๊ฑด์ถ•์–‘์‹์ธ ๊ณ ๊ธ‰ ๋ฏผ๋ฐ•ํ˜• ํŒฌ์…˜๊ณผ ์ „์›์ฃผ๊ฑฐ๊ฐ€ ๊ฒฐํ•ฉ๋œ ์ฃผํƒ์„ ๊ฑด๋ฆฝํ•˜์—ฌ ํŠน์ƒ‰ ์žˆ๋Š” ๊ด€๊ด‘์ธํ”„๋ผ๋ฅผ ๊ตฌ์ถ•ํ•˜๊ณ  ์žˆ๋‹ค.\\nY\\n34.7806685\\n127.9281169\\n๋ฏธ๊ตญ๋งˆ์„\\n1588-3415\\n๋งˆ์„์—ฌํ–‰, ๋ด„, ์—ฌ๋ฆ„, ๊ฐ€์„, ๊ฒจ์šธ, ์ž๊ฐ€์šฉ/๋ ŒํŠธ, ์นœ๊ตฌ, ํ‚ค์ฆˆ, ์—ฐ์ธ, ์šฐ์ •๏ฆ, ์šฐ์ •็”ท, ํšจ๋„, ๋‹จ์ฒด\\n๊ด€๊ด‘์ง€', 'title': None, 'url': None, 'filepath': None, 'chunk_id': '0'}]\n",
59
+ "tab!!!!!!\n",
60
+ "tab!!!!!!\n",
61
+ "tab!!!!!!\n"
62
+ ]
63
+ }
64
+ ],
65
+ "source": [
66
+ "import gradio as gr\n",
67
+ "import requests\n",
68
+ "import re\n",
69
+ "\n",
70
+ "# endpoint : \n",
71
+ "deployment_name = \"fimtrus-gpt-4o-ncus\"\n",
72
+ "endpoint = \"https://fimtrus-openai-ncus.openai.azure.com/openai/deployments/{}/chat/completions\".format(deployment_name)\n",
73
+ "api_key = \"FP7k76c0BGmz4MVot1LVqdtqcmQaKBeerYdFyXzW4NXN0940rRfEJQQJ99BCACHrzpqXJ3w3AAABACOG8189\"\n",
74
+ "\n",
75
+ "ai_search_endpoint = \"https://fimtrus-ai-search3.search.windows.net\"\n",
76
+ "ai_search_key = \"lw8TYxNHT14hpM5oJQhCL3iOxR4PR494dV4RLDaiwzAzSeBecA5i\"\n",
77
+ "ai_search_index_name = \"travel-index-microsoft2\"\n",
78
+ "ai_search_semantic = \"travel-semantic\"\n",
79
+ "\n",
80
+ "\n",
81
+ "def request_gpt(prompt):\n",
82
+ " query_params = {\n",
83
+ " \"api-version\": \"2025-02-01-preview\"\n",
84
+ " }\n",
85
+ " headers = {\n",
86
+ " \"Content-Type\": \"application/json\",\n",
87
+ " \"api-key\": api_key\n",
88
+ " }\n",
89
+ " \n",
90
+ " body = {\n",
91
+ " \"data_sources\": [\n",
92
+ " {\n",
93
+ " \"type\": \"azure_search\",\n",
94
+ " \"parameters\": {\n",
95
+ " \"endpoint\": ai_search_endpoint,\n",
96
+ " \"index_name\": ai_search_index_name,\n",
97
+ " \"semantic_configuration\": ai_search_semantic,\n",
98
+ " \"query_type\": \"semantic\",\n",
99
+ " \"fields_mapping\": {},\n",
100
+ " \"in_scope\": True,\n",
101
+ " \"filter\": None,\n",
102
+ " \"strictness\": 3,\n",
103
+ " \"top_n_documents\": 3,\n",
104
+ " \"authentication\": {\n",
105
+ " \"type\": \"api_key\",\n",
106
+ " \"key\": ai_search_key\n",
107
+ " },\n",
108
+ " \"key\": ai_search_key\n",
109
+ " }\n",
110
+ " }\n",
111
+ " ],\n",
112
+ " \"messages\": [\n",
113
+ " {\n",
114
+ " \"role\": \"system\",\n",
115
+ " \"content\": \"์‚ฌ์šฉ์ž๊ฐ€ ์ •๋ณด๋ฅผ ์ฐพ๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” AI ๋„์šฐ๋ฏธ์ž…๋‹ˆ๋‹ค.\"\n",
116
+ " },\n",
117
+ " {\n",
118
+ " \"role\": \"user\",\n",
119
+ " \"content\": prompt\n",
120
+ " }\n",
121
+ " ],\n",
122
+ " \"temperature\": 0.7,\n",
123
+ " \"top_p\": 0.95,\n",
124
+ " \"max_tokens\": 800,\n",
125
+ " \"stop\": None,\n",
126
+ " \"stream\": False,\n",
127
+ " \"frequency_penalty\": 0,\n",
128
+ " \"presence_penalty\": 0\n",
129
+ " }\n",
130
+ "\n",
131
+ " response = requests.post(endpoint, params=query_params, headers=headers, json=body)\n",
132
+ " \n",
133
+ " if response.status_code == 200:\n",
134
+ " response_json = response.json()\n",
135
+ " message = response_json['choices'][0]['message']\n",
136
+ " content = message['content']\n",
137
+ " \n",
138
+ " content = re.sub(r'\\[doc(\\d+)\\]', r'[์ฐธ์กฐ \\1]', content)\n",
139
+ " \n",
140
+ " if message['context']:\n",
141
+ " citation_list = message['context']['citations']\n",
142
+ " else:\n",
143
+ " citation_list = list()\n",
144
+ " return content, citation_list\n",
145
+ " else:\n",
146
+ " return \"\", list()\n",
147
+ "\n",
148
+ "#############################################################################\n",
149
+ "\n",
150
+ "\n",
151
+ "with gr.Blocks() as demo:\n",
152
+ " \n",
153
+ " citation_state = gr.State([])\n",
154
+ " \n",
155
+ " def click_send(prompt, histories):\n",
156
+ " print(prompt)\n",
157
+ " content, citation_list = request_gpt(prompt=prompt)\n",
158
+ " message_list = [{\"role\": \"user\", \"content\": prompt}, {\"role\": \"assistant\", \"content\": content}]\n",
159
+ " histories.extend(message_list)\n",
160
+ " \n",
161
+ " print(histories)\n",
162
+ " print(len(citation_list), citation_list)\n",
163
+ " return histories, citation_list, \"\"\n",
164
+ " \n",
165
+ " def select_tab(citation):\n",
166
+ " print(\"tab!!!!!!\")\n",
167
+ " return gr.Textbox(label=\"\", value=citation, lines=10, max_lines=10, visible=True)\n",
168
+ " \n",
169
+ " gr.Markdown(\"# ๋‚˜์˜ GPT ์›”๋“œ\")\n",
170
+ " \n",
171
+ " with gr.Row():\n",
172
+ " chatbot = gr.Chatbot(label=\"๋‚˜์˜ GPT\", type=\"messages\", scale=3)\n",
173
+ " \n",
174
+ " with gr.Column(scale=1): \n",
175
+ " @gr.render(inputs=[citation_state])\n",
176
+ " def render_citations(citations):\n",
177
+ " print(citations)\n",
178
+ " for index in range(len(citations)):\n",
179
+ " content = citations[index]['content']\n",
180
+ " key = \"์ฐธ์กฐ{}\".format(index + 1)\n",
181
+ " if index == 0:\n",
182
+ " gr.Tab(\"\", id=-1, visible=False)\n",
183
+ " with gr.Tab(key) as tab:\n",
184
+ " citation_textbox = gr.Textbox(label=\"\", value=content, lines=10, max_lines=10, visible=False)\n",
185
+ " tab.select(fn=select_tab, inputs=[citation_textbox], outputs=[citation_textbox])\n",
186
+ " \n",
187
+ " with gr.Row():\n",
188
+ " prompt_textbox = gr.Textbox(label=\"ํ”„๋กฌํ”„ํŠธ\", placeholder=\"ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.\", scale=6)\n",
189
+ " send_button = gr.Button(\"์ „์†ก\", scale=1)\n",
190
+ " \n",
191
+ " send_button.click(click_send, inputs=[prompt_textbox, chatbot], outputs=[chatbot, citation_state, prompt_textbox])\n",
192
+ " prompt_textbox.submit(click_send, inputs=[prompt_textbox, chatbot], outputs=[chatbot, citation_state, prompt_textbox])\n",
193
+ " \n",
194
+ " \n",
195
+ "demo.launch()\n",
196
+ "\n"
197
+ ]
198
+ },
199
+ {
200
+ "cell_type": "code",
201
+ "execution_count": null,
202
+ "metadata": {},
203
+ "outputs": [],
204
+ "source": []
205
+ }
206
+ ],
207
+ "metadata": {
208
+ "kernelspec": {
209
+ "display_name": "openai",
210
+ "language": "python",
211
+ "name": "python3"
212
+ },
213
+ "language_info": {
214
+ "codemirror_mode": {
215
+ "name": "ipython",
216
+ "version": 3
217
+ },
218
+ "file_extension": ".py",
219
+ "mimetype": "text/x-python",
220
+ "name": "python",
221
+ "nbconvert_exporter": "python",
222
+ "pygments_lexer": "ipython3",
223
+ "version": "3.11.9"
224
+ }
225
+ },
226
+ "nbformat": 4,
227
+ "nbformat_minor": 2
228
+ }