|
10 | 10 |
|
11 | 11 | from datetime import datetime, timedelta |
12 | 12 | import time |
13 | | -import base64 |
14 | 13 | import pyodbc |
15 | 14 | import struct |
16 | 15 |
|
@@ -121,9 +120,6 @@ def chunk_data(text): |
121 | 120 |
|
122 | 121 | search_client = SearchClient(search_endpoint, index_name, search_credential) |
123 | 122 |
|
124 | | -# # delete all the documents in the index |
125 | | -# search_client.delete_documents(search_client.search("*")) |
126 | | - |
127 | 123 | index_client = SearchIndexClient(endpoint=search_endpoint, credential=search_credential) |
128 | 124 |
|
129 | 125 | # Delete the search index |
@@ -401,10 +397,6 @@ def prepare_search_doc(content, document_id): |
401 | 397 | cursor.execute(f"INSERT INTO processed_data (ConversationId, EndTime, StartTime, Content, summary, satisfied, sentiment, topic, key_phrases, complaint) VALUES (?,?,?,?,?,?,?,?,?,?)", (conversation_id, end_timestamp, start_timestamp, content, summary, satisfied, sentiment, topic, key_phrases, complaint)) |
402 | 398 | conn.commit() |
403 | 399 |
|
404 | | - # keyPhrases = key_phrases.split(',') |
405 | | - # for keyPhrase in keyPhrases: |
406 | | - # cursor.execute(f"INSERT INTO processed_data_key_phrases (ConversationId, key_phrase, sentiment) VALUES (?,?,?)", (conversation_id, keyPhrase, sentiment)) |
407 | | - |
408 | 400 | document_id = conversation_id |
409 | 401 |
|
410 | 402 | result = prepare_search_doc(content, document_id) |
@@ -471,16 +463,6 @@ def call_gpt4(topics_str1, client): |
471 | 463 | Return the topics and their labels in JSON format.Always add 'topics' node and 'label', 'description' attributes in json. |
472 | 464 | Do not return anything else. |
473 | 465 | """ |
474 | | - # Phi-3 model client |
475 | | - # response = client.complete( |
476 | | - # messages=[ |
477 | | - # # SystemMessage(content=prompt), |
478 | | - # UserMessage(content=topic_prompt), |
479 | | - # ], |
480 | | - # max_tokens = 1000, |
481 | | - # temperature = 0, |
482 | | - # top_p = 1 |
483 | | - # ) |
484 | 466 |
|
485 | 467 | # GPT-4o model client |
486 | 468 | response = client.chat.completions.create( |
@@ -588,17 +570,6 @@ def get_mined_topic_mapping(input_text, list_of_topics): |
588 | 570 | from a list of topics - {list_of_topics}. |
589 | 571 | ALWAYS only return a topic from list - {list_of_topics}. Do not add any other text.''' |
590 | 572 |
|
591 | | - # Phi-3 model client |
592 | | - # response = client.complete( |
593 | | - # messages=[ |
594 | | - # # SystemMessage(content=prompt), |
595 | | - # UserMessage(content=prompt), |
596 | | - # ], |
597 | | - # max_tokens = 500, |
598 | | - # temperature = 0, |
599 | | - # top_p = 1 |
600 | | - # ) |
601 | | - |
602 | 573 | # GPT-4o model client |
603 | 574 | response = client.chat.completions.create( |
604 | 575 | model=deployment, |
@@ -669,28 +640,8 @@ def get_mined_topic_mapping(input_text, list_of_topics): |
669 | 640 | # Bulk insert using executemany() |
670 | 641 | cursor.executemany(insert_sql, data_list) |
671 | 642 |
|
672 | | -# column_names = [i[0] for i in cursor.description] |
673 | | -# df = pd.DataFrame(rows, columns=column_names) |
674 | | -# for idx, row in df.iterrows(): |
675 | | -# cursor.execute(f"INSERT INTO km_processed_data (ConversationId, StartTime, EndTime, Content, summary, satisfied, sentiment, keyphrases, complaint, topic) VALUES (?,?,?,?,?,?,?,?,?,?)", (row['ConversationId'], row['StartTime'], row['EndTime'], row['Content'], row['summary'], row['satisfied'], row['sentiment'], row['keyphrases'], row['complaint'], row['topic'])) |
676 | 643 | conn.commit() |
677 | 644 |
|
678 | | -# update keyphrase table after the data update |
679 | | -# cursor.execute('DROP TABLE IF EXISTS processed_data_key_phrases') |
680 | | -# conn.commit() |
681 | | -# print("Dropped processed_data_key_phrases table") |
682 | | - |
683 | | -# create_processed_data_sql = """CREATE TABLE processed_data_key_phrases ( |
684 | | -# ConversationId varchar(255), |
685 | | -# key_phrase varchar(500), |
686 | | -# sentiment varchar(255), |
687 | | -# topic varchar(255), |
688 | | -# StartTime varchar(255), |
689 | | -# );""" |
690 | | -# cursor.execute(create_processed_data_sql) |
691 | | -# conn.commit() |
692 | | -# print('created processed_data_key_phrases table') |
693 | | - |
694 | 645 | sql_stmt = '''select ConversationId, key_phrases, sentiment, mined_topic as topic, StartTime from processed_data''' |
695 | 646 | cursor.execute(sql_stmt) |
696 | 647 | rows = [tuple(row) for row in cursor.fetchall()] |
|
0 commit comments