1
- from dotenv import load_dotenv
2
1
import os
3
2
4
- from datahub_cls .metadata_fetcher import (
5
- DatahubMetadataFetcher ,
6
- get_all_tables_info ,
7
- )
8
-
9
3
from utils import save_persona_json , pretty_print_persona
10
4
from persona_class import PersonaList
11
5
12
-
6
+ from llm_utils . tools import _get_table_info
13
7
from langchain_openai .chat_models import ChatOpenAI
14
8
from langchain_core .prompts import ChatPromptTemplate
15
9
from argparse import ArgumentParser
16
10
17
- load_dotenv ()
18
-
19
-
20
- def drop_empty_tables (tables_df ):
21
- drop_empty_tables = tables_df [
22
- tables_df ["table_description" ].apply (lambda x : x != "" )
23
- ]
24
- return drop_empty_tables [["table_name" , "table_description" ]]
25
-
26
11
27
- def get_table_des_string (tables_df ):
12
+ def get_table_des_string (tables_desc ):
28
13
return_string = "table name : table description\n ---\n "
29
- for _ , row in tables_df . iterrows ():
30
- return_string += f"{ row [ ' table_name' ] } : { row [ 'table_description' ] } \n ---\n "
14
+ for table_name , table_desc in tables_desc . items ():
15
+ return_string += f"{ table_name } : { table_desc } \n ---\n "
31
16
return return_string
32
17
33
18
34
- def generate_persona (tables_df ):
35
- tables_df = drop_empty_tables (tables_df )
36
- description_string = get_table_des_string (tables_df )
19
+ def generate_persona (tables_desc ):
20
+ description_string = get_table_des_string (tables_desc )
37
21
38
22
llm = ChatOpenAI (model = "gpt-4o-mini" , temperature = 0 )
39
23
system_prompt = """주어진 Tabel description들을 참고하여 Text2SQL 서비스로 질문을 할만한 패르소나를 생성하세요"""
@@ -50,9 +34,8 @@ def generate_persona(tables_df):
50
34
51
35
def main (output_path ):
52
36
# 데이터허브 서버 연결
53
- fetcher = DatahubMetadataFetcher (gms_server = os .getenv ("DATAHUB_SERVER" ))
54
- tables_df = get_all_tables_info (fetcher )
55
- personas = generate_persona (tables_df )
37
+ tables_desc = _get_table_info ()
38
+ personas = generate_persona (tables_desc )
56
39
57
40
for persona in personas .personas :
58
41
print (pretty_print_persona (persona ))
0 commit comments