Kim Adams commited on
Commit
2cd1c76
·
1 Parent(s): a5d5d8d

all of the things

Browse files
Files changed (42) hide show
  1. README.md +1 -1
  2. app.py +11 -10
  3. chat_bot/__pycache__/simple_chat.cpython-311.pyc +0 -0
  4. chat_bot/__pycache__/ui_chat_bot.cpython-311.pyc +0 -0
  5. chat_bot/__pycache__/ui_simple_chat.cpython-311.pyc +0 -0
  6. chat_bot/simple_chat.py +148 -14
  7. chat_bot/ui_chat_bot.py +1 -1
  8. chat_bot/ui_simple_chat.py +5 -5
  9. embedding_tools/__pycache__/create_embedding.cpython-311.pyc +0 -0
  10. embedding_tools/__pycache__/embeddings.cpython-311.pyc +0 -0
  11. embedding_tools/create_embedding.py +12 -0
  12. embedding_tools/embeddings.py +1 -0
  13. image_to_text/__pycache__/image_to_text_translator.cpython-311.pyc +0 -0
  14. image_to_text/image_to_text_translator.py +1 -1
  15. image_to_text/ui_image_to_text.py +1 -1
  16. prompts/__pycache__/ui_prompt_builder.cpython-311.pyc +0 -0
  17. prompts/ui_prompt_builder.py +1 -1
  18. recording_analysis/__pycache__/ui_recording_analysis.cpython-311.pyc +0 -0
  19. recording_analysis/ui_recording_analysis.py +18 -1
  20. requirements.txt +13 -4
  21. slack_sentiment_analysis/__pycache__/ui_sentiment_analysis.cpython-311.pyc +0 -0
  22. slack_sentiment_analysis/ui_sentiment_analysis.py +1 -1
  23. text_analysis/__pycache__/ui_text_analysis.cpython-311.pyc +0 -0
  24. text_analysis/ui_text_analysis.py +1 -2
  25. translators/__pycache__/translate_pdf_to_text.cpython-311.pyc +0 -0
  26. utilities/__pycache__/api_keys.cpython-311.pyc +0 -0
  27. utilities/__pycache__/clean_text.cpython-311.pyc +0 -0
  28. utilities/__pycache__/constants.cpython-311.pyc +0 -0
  29. utilities/__pycache__/date_format.cpython-311.pyc +0 -0
  30. utilities/__pycache__/embeddings.cpython-311.pyc +0 -0
  31. utilities/__pycache__/prompt_constants.cpython-311.pyc +0 -0
  32. utilities/__pycache__/prompts.cpython-311.pyc +0 -0
  33. utilities/__pycache__/system_prompts.cpython-311.pyc +0 -0
  34. utilities/__pycache__/translate_pdf_to_text.cpython-311.pyc +0 -0
  35. utilities/__pycache__/user_prompts.cpython-311.pyc +0 -0
  36. utilities/__pycache__/voice_handling.cpython-311.pyc +0 -0
  37. utilities/constants.py +17 -3
  38. utilities/data/csv/usaa.csv +0 -0
  39. utilities/data/embeddings/hr_asst_embeddings.pkl +1 -1
  40. utilities/data/pkl/usaa.pkl +2 -2
  41. utilities/data/txt/usaa.txt +0 -0
  42. utilities/prompt_constants.py +1 -0
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🛠️
4
  colorFrom: red
5
  colorTo: red
6
  sdk: gradio
7
- sdk_version: 3.40.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
4
  colorFrom: red
5
  colorTo: red
6
  sdk: gradio
7
+ sdk_version: 4.37.2
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py CHANGED
@@ -2,29 +2,30 @@ import gradio as gr
2
  import pandas as pd
3
  import openai
4
  from ui.app_theme import SoftBlue
5
- from image_gen import ui_image_generation
6
- from summarization import ui_summarize
7
  from utilities import constants,api_keys
8
- from recording_analysis import ui_recording_analysis
9
  from prompts import ui_prompt_builder
10
  from chat_bot import ui_simple_chat
 
 
 
 
11
  from slack_sentiment_analysis import ui_sentiment_analysis
12
  from image_to_text import image_to_text_translator as ui_image_to_text
13
- from text_analysis import ui_text_analysis
14
 
15
  openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
16
 
17
  prompt_builder=ui_prompt_builder.ui
 
 
18
  summarize=ui_summarize.ui
19
  image_generator=ui_image_generation.ui
20
  video_analysis=ui_recording_analysis.ui
21
  slack_sentiment=ui_sentiment_analysis.ui
22
- usaa_advisor=ui_simple_chat.ui
23
- image_to_text=ui_image_to_text.ui
24
- text_analysis=ui_text_analysis.ui
25
 
26
- ui = gr.TabbedInterface([prompt_builder, text_analysis, image_generator, video_analysis,slack_sentiment, usaa_advisor, summarize],
27
- (constants.UI_1, constants.UI_2, constants.UI_3,constants.UI_4, constants.UI_5,constants.UI_7, constants.UI_8),
28
- theme=SoftBlue())
29
 
30
  ui.launch()
 
2
  import pandas as pd
3
  import openai
4
  from ui.app_theme import SoftBlue
 
 
5
  from utilities import constants,api_keys
 
6
  from prompts import ui_prompt_builder
7
  from chat_bot import ui_simple_chat
8
+ ''' Disabled
9
+ from image_gen import ui_image_generation
10
+ from summarization import ui_summarize
11
+ from recording_analysis import ui_recording_analysis
12
  from slack_sentiment_analysis import ui_sentiment_analysis
13
  from image_to_text import image_to_text_translator as ui_image_to_text
14
+ from text_analysis import ui_text_analysis'''
15
 
16
  openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
17
 
18
  prompt_builder=ui_prompt_builder.ui
19
+ usaa_advisor=ui_simple_chat.ui
20
+ ''' Disabled
21
  summarize=ui_summarize.ui
22
  image_generator=ui_image_generation.ui
23
  video_analysis=ui_recording_analysis.ui
24
  slack_sentiment=ui_sentiment_analysis.ui
25
+ #git_advisor=ui_simple_chat_git.ui
26
+ #image_to_text=ui_image_to_text.ui
27
+ #text_analysis=ui_text_analysis.ui'''
28
 
29
+ ui = gr.TabbedInterface([prompt_builder, usaa_advisor], (constants.UI_1, "Policy Chat"),theme=SoftBlue())
 
 
30
 
31
  ui.launch()
chat_bot/__pycache__/simple_chat.cpython-311.pyc DELETED
Binary file (5.34 kB)
 
chat_bot/__pycache__/ui_chat_bot.cpython-311.pyc DELETED
Binary file (7.07 kB)
 
chat_bot/__pycache__/ui_simple_chat.cpython-311.pyc DELETED
Binary file (3.41 kB)
 
chat_bot/simple_chat.py CHANGED
@@ -1,12 +1,158 @@
1
- import os, openai,string,csv
 
 
 
 
2
  import pandas as pd
3
  from utilities import constants, api_keys, clean_text, prompt_constants
4
  from translators import translate_pdf_to_text
5
  from embedding_tools import create_embedding
 
6
 
7
  openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
8
  messages=[]
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def CreateCSV(text_chunks):
11
  with open(constants.CSV_PATH, 'w', newline='') as csvfile:
12
  csv_writer = csv.writer(csvfile)
@@ -36,19 +182,6 @@ def CreateChunks(transcript, length):
36
  text_chunks.append(transcript[start_idx:])
37
  return text_chunks
38
 
39
- def CreateEmbeddings(input_path, output_path):
40
- if os.path.exists(constants.PKL_PATH):
41
- df = pd.read_pickle(constants.PKL_PATH)
42
- create_embedding.CreateEmbeddingsFlat(constants.CSV_PATH, constants.PKL_PATH)
43
- return df
44
-
45
- transcript= translate_pdf_to_text.TranslatePdfToText(input_path, output_path)
46
- text_chunks=CreateChunks(transcript, constants.EMBEDDING_CHUNK_LENGTH)
47
- CreateCSV(text_chunks)
48
- create_embedding.CreateEmbeddingsFlat(constants.CSV_PATH, constants.PKL_PATH)
49
- df = pd.read_pickle(constants.PKL_PATH)
50
- return df
51
-
52
  def Completion(messages):
53
  response = openai.ChatCompletion.create(
54
  model="gpt-3.5-turbo",
@@ -58,6 +191,7 @@ def Completion(messages):
58
  return cleaned_text
59
 
60
  def QueryEmbeddingsSimple(query):
 
61
  global messages
62
  best_answer= create_embedding.QueryEmbeddingsFlat(query)
63
  prompt= prompt_constants.USAA_AR_EXPERT_PROMPT
 
1
+ import os
2
+ import openai
3
+ import string
4
+ import csv
5
+ import re
6
  import pandas as pd
7
  from utilities import constants, api_keys, clean_text, prompt_constants
8
  from translators import translate_pdf_to_text
9
  from embedding_tools import create_embedding
10
+ from chat_bot import process_policies
11
 
12
  openai.api_key = api_keys.APIKeys().get_key('OPENAI_API_KEY')
13
  messages=[]
14
 
15
+
16
+
17
+ def flatten_json(json_obj, prefix=''):
18
+ items = []
19
+
20
+ def flatten(json_fragment, current_prefix):
21
+ if isinstance(json_fragment, dict):
22
+ for key, value in json_fragment.items():
23
+ new_key = f'{current_prefix}{key}_' if current_prefix else key
24
+ if isinstance(value, (dict, list)):
25
+ flatten(value, new_key)
26
+ else:
27
+ # Remove newlines from value
28
+ cleaned_value = str(value).replace('\n', ' ')
29
+ items.append((new_key, cleaned_value))
30
+ elif isinstance(json_fragment, list):
31
+ for index, item in enumerate(json_fragment):
32
+ new_key = f'{current_prefix}{index}_'
33
+ if isinstance(item, (dict, list)):
34
+ flatten(item, new_key)
35
+ else:
36
+ # Remove newlines from value
37
+ cleaned_value = str(item).replace('\n', ' ')
38
+ items.append((new_key, cleaned_value))
39
+
40
+ flatten(json_obj, prefix)
41
+ return items
42
+
43
+ def camel_case_to_readable(text):
44
+ text = re.sub(r'(?<!^)(?=[A-Z])', ' ', text)
45
+ text = text.replace('_', ' ')
46
+ text = text.lower()
47
+ text = text.capitalize()
48
+ return text
49
+
50
+ def make_readable_key(key):
51
+ key = key.replace('_', ' ')
52
+ key = re.sub(r'\b0_', '(1) ', key)
53
+ key = re.sub(r'\b1_', '(2) ', key)
54
+ key = re.sub(r'\b2_', '(3) ', key)
55
+ key = ' '.join([word.capitalize() for word in key.split()])
56
+ key = key.replace('Is', 'is').replace('Has a', 'has a')
57
+ return key
58
+
59
+ def process_list(items):
60
+ readable_items = []
61
+ for item in items:
62
+ key, value = item.split(': ', 1)
63
+ readable_key = make_readable_key(key)
64
+ readable_value = value.replace('\n', ' ')
65
+ readable_items.append(f'{readable_key}: {readable_value}')
66
+ return readable_items
67
+
68
+ def convert_flattened_to_readable(flattened_items):
69
+ readable_items = []
70
+ for key, value in flattened_items:
71
+ readable_key = make_readable_key(key)
72
+ readable_items.append(f'{readable_key}: {value}')
73
+ return readable_items
74
+
75
+ def convert_json_to_single_column_csv(json_obj):
76
+ flattened_items = flatten_json(json_obj)
77
+ readable_items = convert_flattened_to_readable(flattened_items)
78
+ flat_text = '\n'.join(readable_items)
79
+ return flat_text
80
+
81
+
82
+ def flatten_json_to_single_column(json_obj, prefix=''):
83
+ print("in flatten_json_to_single_column, json_obj:", json_obj, "prefix:", prefix)
84
+
85
+ items = []
86
+ if isinstance(json_obj, dict):
87
+ for key, value in json_obj.items():
88
+ if isinstance(value, dict):
89
+ items.extend(flatten_json_to_single_column(value, f'{prefix}{key}_'))
90
+ elif isinstance(value, list):
91
+ for index, item in enumerate(value):
92
+ items.extend(flatten_json_to_single_column(item, f'{prefix}{key}_{index}_'))
93
+ else:
94
+ items.append(f'{prefix}{key}: {value}')
95
+ elif isinstance(json_obj, list):
96
+ for index, item in enumerate(json_obj):
97
+ if isinstance(item, dict):
98
+ items.extend(flatten_json_to_single_column(item, f'{prefix}{index}_'))
99
+ else:
100
+ items.append(f'{prefix}{index}: {item}')
101
+ else:
102
+ items.append(f'{prefix[:-1]}: {json_obj}') # Remove trailing underscore
103
+ return items
104
+
105
+ def convert_json_to_single_column_csv_old(json_obj):
106
+ flat_data = flatten_json_to_single_column(json_obj)
107
+ flat_text = '\n'.join(flat_data)
108
+ return flat_text
109
+
110
+ def write_flat_text_to_csv(flat_text, csv_path):
111
+ # Open a CSV file to write the data
112
+ with open(csv_path, 'w', newline='') as csvfile:
113
+ csv_writer = csv.writer(csvfile)
114
+
115
+ # Write each line as a row in the CSV file
116
+ for line in flat_text:
117
+ csv_writer.writerow([line])
118
+
119
+
120
+ ## entry point edited, input=pdf, output=csv
121
+ def CreateEmbeddings(policy_input, policy_output):
122
+ print("in createembeddings, policy_input:", policy_input, "policy_output:", policy_output)
123
+ content=process_policies.convert_pdf_to_text_ocr(policy_input, constants.POLICY_TXT_PATH)
124
+
125
+ print("\n***content after extract policy:", content)
126
+ df=None
127
+ if content:
128
+ print("**content before:", content)
129
+ schema=process_policies.create_schema(content)
130
+ print ("**schema:", schema)
131
+ flat_txt = flatten_json_to_single_column(schema)
132
+ readable= process_list(flat_txt)
133
+ for item in readable:
134
+ print(item)
135
+ write_flat_text_to_csv(readable,policy_output)
136
+ print ("csv writtens")
137
+ create_embedding.CreateEmbeddingsFlatPolicy(policy_output, constants.POLICY_PKL_PATH)
138
+ print("df:", df)
139
+ return df
140
+
141
+ def CreateEmbeddingsOriginal(input_path, output_path):
142
+ print("in createembeddingsoriginal, input_path:", input_path, "output_path:", output_path)
143
+ if os.path.exists(constants.PKL_PATH):
144
+ df = pd.read_pickle(constants.PKL_PATH)
145
+ create_embedding.CreateEmbeddingsFlat(constants.CSV_PATH, constants.PKL_PATH)
146
+ return df
147
+
148
+ transcript= translate_pdf_to_text.TranslatePdfToText(input_path, output_path)
149
+ text_chunks=CreateChunks(transcript, constants.EMBEDDING_CHUNK_LENGTH)
150
+ CreateCSV(text_chunks)
151
+ create_embedding.CreateEmbeddingsFlat(constants.CSV_PATH, constants.PKL_PATH)
152
+ df = pd.read_pickle(constants.PKL_PATH)
153
+ return df
154
+
155
+
156
  def CreateCSV(text_chunks):
157
  with open(constants.CSV_PATH, 'w', newline='') as csvfile:
158
  csv_writer = csv.writer(csvfile)
 
182
  text_chunks.append(transcript[start_idx:])
183
  return text_chunks
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  def Completion(messages):
186
  response = openai.ChatCompletion.create(
187
  model="gpt-3.5-turbo",
 
191
  return cleaned_text
192
 
193
  def QueryEmbeddingsSimple(query):
194
+ print ("in QueryEmbeddingsSimple")
195
  global messages
196
  best_answer= create_embedding.QueryEmbeddingsFlat(query)
197
  prompt= prompt_constants.USAA_AR_EXPERT_PROMPT
chat_bot/ui_chat_bot.py CHANGED
@@ -66,7 +66,7 @@ with gr.Blocks() as ui:
66
  sentiment=gr.Checkbox(label=constants.SENTIMENT, value=False, info=constants.SENTIMENT_INFO)
67
  emotion=gr.Checkbox(label=constants.EMOTION, value=False, info=constants.EMOTION_INFO)
68
  gr.Markdown(constants.MICROPHONE_MD)
69
- audio = gr.Audio(label=constants.ASK_A_QUESTION, source="microphone", type="filepath")
70
  with gr.Row():
71
  clear=gr.Button(value=constants.CLEAR)
72
  submit=gr.Button(value=constants.SUBMIT, variant="primary")
 
66
  sentiment=gr.Checkbox(label=constants.SENTIMENT, value=False, info=constants.SENTIMENT_INFO)
67
  emotion=gr.Checkbox(label=constants.EMOTION, value=False, info=constants.EMOTION_INFO)
68
  gr.Markdown(constants.MICROPHONE_MD)
69
+ audio = gr.Audio(label=constants.ASK_A_QUESTION)
70
  with gr.Row():
71
  clear=gr.Button(value=constants.CLEAR)
72
  submit=gr.Button(value=constants.SUBMIT, variant="primary")
chat_bot/ui_simple_chat.py CHANGED
@@ -7,9 +7,9 @@ import random
7
  import time
8
 
9
  def InitDF():
10
- global commDF
11
- commDF=pd.DataFrame({"role": [""], "content": [""] })
12
- simple_chat.CreateEmbeddings(constants.PDF_INPUT_PATH, constants.TXT_OUTPUT_PATH)
13
 
14
  def Respond(message, chat_history):
15
  bot_message,df=simple_chat.QueryEmbeddingsSimple(message)
@@ -28,8 +28,8 @@ with gr.Blocks() as ui:
28
  question= gr.Textbox (label=constants.QUESTIONS_PREFIX, value=constants.QUESTIONS_AR_EXPERT)
29
  chatbot = gr.Chatbot(label=constants.CHAT_BOT, height=constants.CHAT_BOT_HEIGHT)
30
  msg = gr.Textbox(label=constants.CHAT_BOT_INPUT)
31
- commDF = gr.DataFrame(type="pandas", value=pd.DataFrame({"role": [""], "content": [""] }), wrap=True, label=constants.OPENAI_LOG)
32
  clear = gr.ClearButton([msg, chatbot])
33
- msg.submit(Respond, [msg, chatbot], [msg, chatbot,commDF])
34
 
35
  InitDF()
 
7
  import time
8
 
9
  def InitDF():
10
+ global gitDF
11
+ gitDF=pd.DataFrame({"role": [""], "content": [""] })
12
+ simple_chat.CreateEmbeddings(constants.POLICY_INPUT, constants.POLICY_OUTPUT)
13
 
14
  def Respond(message, chat_history):
15
  bot_message,df=simple_chat.QueryEmbeddingsSimple(message)
 
28
  question= gr.Textbox (label=constants.QUESTIONS_PREFIX, value=constants.QUESTIONS_AR_EXPERT)
29
  chatbot = gr.Chatbot(label=constants.CHAT_BOT, height=constants.CHAT_BOT_HEIGHT)
30
  msg = gr.Textbox(label=constants.CHAT_BOT_INPUT)
31
+ gitDF = gr.DataFrame(type="pandas", value=pd.DataFrame({"role": [""], "content": [""] }), wrap=True, label=constants.OPENAI_LOG)
32
  clear = gr.ClearButton([msg, chatbot])
33
+ msg.submit(Respond, [msg, chatbot], [msg, chatbot,gitDF])
34
 
35
  InitDF()
embedding_tools/__pycache__/create_embedding.cpython-311.pyc DELETED
Binary file (4.92 kB)
 
embedding_tools/__pycache__/embeddings.cpython-311.pyc DELETED
Binary file (626 Bytes)
 
embedding_tools/create_embedding.py CHANGED
@@ -14,6 +14,18 @@ def CreateEmbeddingsQA(input_path, output_path):
14
  benefit_info['embedding'] = benefit_info['answer'].apply(lambda row: get_embedding(str(row), engine='text-embedding-ada-002'))
15
  benefit_info.to_pickle(output_path)
16
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  def CreateEmbeddingsFlat(input_path, output_path):
18
  global embedding_info
19
  print(" CreateEmbeddingsFlat input_path: "+input_path + " output_path: "+output_path)
 
14
  benefit_info['embedding'] = benefit_info['answer'].apply(lambda row: get_embedding(str(row), engine='text-embedding-ada-002'))
15
  benefit_info.to_pickle(output_path)
16
 
17
+ def CreateEmbeddingsFlatPolicy(input_path, output_path):
18
+ global embedding_info
19
+ print(" CreateEmbeddingsFlat input_path: "+input_path + " output_path: "+output_path)
20
+ embedding_info = pd.read_csv(input_path)
21
+ embedding_info.columns = ['data']
22
+ embedding_info['embedding'] = embedding_info['data'].apply(lambda row: get_embedding(str(row), engine='text-embedding-ada-002'))
23
+ embedding_info.to_pickle(output_path)
24
+ print("Loaded from CSV file.")
25
+
26
+ print(f"embedding_info type: {type(embedding_info)}")
27
+ print(f"embedding_info is None: {embedding_info is None}")
28
+
29
  def CreateEmbeddingsFlat(input_path, output_path):
30
  global embedding_info
31
  print(" CreateEmbeddingsFlat input_path: "+input_path + " output_path: "+output_path)
embedding_tools/embeddings.py CHANGED
@@ -2,6 +2,7 @@ from utilities import constants
2
  import embedding_tools.create_embedding as create_embedding
3
 
4
  def ApplyEmbeddings(message, persona):
 
5
  if(persona==constants.PERSONA_HR_EXPERT):
6
  return create_embedding.QueryEmbeddings(message)
7
  else:
 
2
  import embedding_tools.create_embedding as create_embedding
3
 
4
  def ApplyEmbeddings(message, persona):
5
+ print("persona: ", persona)
6
  if(persona==constants.PERSONA_HR_EXPERT):
7
  return create_embedding.QueryEmbeddings(message)
8
  else:
image_to_text/__pycache__/image_to_text_translator.cpython-311.pyc CHANGED
Binary files a/image_to_text/__pycache__/image_to_text_translator.cpython-311.pyc and b/image_to_text/__pycache__/image_to_text_translator.cpython-311.pyc differ
 
image_to_text/image_to_text_translator.py CHANGED
@@ -53,7 +53,7 @@ with gr.Blocks() as ui:
53
  gr.Markdown(constants.DIRECTIONS_MD)
54
  gr.Markdown(constants.AR_ADVISOR_DIRECTIONS)
55
  with gr.Row():
56
- imageBlock = gr.Image(label=constants.IMAGE_INPUT, source="upload")
57
  summaryBlock= gr.Textbox (label=constants.SUMMARY)
58
  with gr.Row():
59
  submitBtn=gr.Button(value=constants.EXTRACT_SUMMARY, variant="primary")
 
53
  gr.Markdown(constants.DIRECTIONS_MD)
54
  gr.Markdown(constants.AR_ADVISOR_DIRECTIONS)
55
  with gr.Row():
56
+ imageBlock = gr.Image(label=constants.IMAGE_INPUT)
57
  summaryBlock= gr.Textbox (label=constants.SUMMARY)
58
  with gr.Row():
59
  submitBtn=gr.Button(value=constants.EXTRACT_SUMMARY, variant="primary")
image_to_text/ui_image_to_text.py CHANGED
@@ -36,7 +36,7 @@ with gr.Blocks() as ui:
36
  gr.Markdown(value=constants.RECORDING_ANALYSIS_DIRECTIONS)
37
 
38
  with gr.Row():
39
- videoBlock = gr.Video(label=constants.VIDEO_INPUT, source="upload")
40
  summaryBlock= gr.Textbox (label=constants.SUMMARY)
41
  with gr.Column():
42
  gr.Markdown(constants.TOPICS_MD)
 
36
  gr.Markdown(value=constants.RECORDING_ANALYSIS_DIRECTIONS)
37
 
38
  with gr.Row():
39
+ videoBlock = gr.Video(label=constants.VIDEO_INPUT)
40
  summaryBlock= gr.Textbox (label=constants.SUMMARY)
41
  with gr.Column():
42
  gr.Markdown(constants.TOPICS_MD)
prompts/__pycache__/ui_prompt_builder.cpython-311.pyc CHANGED
Binary files a/prompts/__pycache__/ui_prompt_builder.cpython-311.pyc and b/prompts/__pycache__/ui_prompt_builder.cpython-311.pyc differ
 
prompts/ui_prompt_builder.py CHANGED
@@ -79,7 +79,7 @@ with gr.Blocks() as ui:
79
  info=constants.VOICE_INFO)
80
 
81
  gr.Markdown(constants.MICROPHONE_MD)
82
- audio = gr.Audio(label=constants.ASK_A_QUESTION, source="microphone", type="filepath")
83
  with gr.Row():
84
  clear=gr.Button(value=constants.CLEAR)
85
  submit=gr.Button(value=constants.SUBMIT, variant="primary")
 
79
  info=constants.VOICE_INFO)
80
 
81
  gr.Markdown(constants.MICROPHONE_MD)
82
+ audio = gr.Audio(label=constants.ASK_A_QUESTION, type="filepath")
83
  with gr.Row():
84
  clear=gr.Button(value=constants.CLEAR)
85
  submit=gr.Button(value=constants.SUBMIT, variant="primary")
recording_analysis/__pycache__/ui_recording_analysis.cpython-311.pyc CHANGED
Binary files a/recording_analysis/__pycache__/ui_recording_analysis.cpython-311.pyc and b/recording_analysis/__pycache__/ui_recording_analysis.cpython-311.pyc differ
 
recording_analysis/ui_recording_analysis.py CHANGED
@@ -25,6 +25,23 @@ def ClearScreen():
25
  videoBlock=None
26
  return "","",pd.DataFrame({"role": [""], "content": [""] })
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  with gr.Blocks() as ui:
29
  label2 = gr.Label(show_label=False, value=constants.RECORDING_ANALYSIS, container=False)
30
  with gr.Row():
@@ -36,7 +53,7 @@ with gr.Blocks() as ui:
36
  gr.Markdown(value=constants.RECORDING_ANALYSIS_DIRECTIONS)
37
 
38
  with gr.Row():
39
- videoBlock = gr.Video(label=constants.VIDEO_INPUT, source="upload")
40
  summaryBlock= gr.Textbox (label=constants.SUMMARY)
41
  with gr.Column():
42
  gr.Markdown(constants.TOPICS_MD)
 
25
  videoBlock=None
26
  return "","",pd.DataFrame({"role": [""], "content": [""] })
27
 
28
+ '''Alternate way to manage source
29
+ def process_video(video):
30
+ # Here you can add any processing you might want to perform on the video
31
+ return video
32
+
33
+ with gr.Blocks() as demo:
34
+ video_input = gr.Video(label="Upload your video")
35
+ submit_button = gr.Button("Submit")
36
+ video_output = gr.Video(label="Processed Video")
37
+
38
+ submit_button.click(
39
+ fn=process_video,
40
+ inputs=video_input,
41
+ outputs=video_output
42
+ )
43
+ '''
44
+
45
  with gr.Blocks() as ui:
46
  label2 = gr.Label(show_label=False, value=constants.RECORDING_ANALYSIS, container=False)
47
  with gr.Row():
 
53
  gr.Markdown(value=constants.RECORDING_ANALYSIS_DIRECTIONS)
54
 
55
  with gr.Row():
56
+ videoBlock = gr.Video(label=constants.VIDEO_INPUT)
57
  summaryBlock= gr.Textbox (label=constants.SUMMARY)
58
  with gr.Column():
59
  gr.Markdown(constants.TOPICS_MD)
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- pip>=23.3
2
  requests==2.31.0
3
  pylance==0.5.10
4
  pandas==2.0.3
@@ -9,8 +9,8 @@ scikit-learn==1.2.2
9
  plotly.express==0.4.1
10
  openai==0.27.8
11
  openapi-schema-pydantic==1.2.4
12
- gradio==3.48.0
13
- gradio_client==0.6.1
14
  GitPython==3.1.31
15
  elevenlabs==0.2.18
16
  python-dotenv==1.0.0
@@ -25,4 +25,13 @@ pdfplumber==0.10.2
25
  pytz==2023.3
26
  easyocr==1.7.1
27
  ffmpeg==1.4
28
- spacy==3.7.2
 
 
 
 
 
 
 
 
 
 
1
+ pip>=24.1.1
2
  requests==2.31.0
3
  pylance==0.5.10
4
  pandas==2.0.3
 
9
  plotly.express==0.4.1
10
  openai==0.27.8
11
  openapi-schema-pydantic==1.2.4
12
+ gradio==4.37.2
13
+ gradio_client==1.0.2
14
  GitPython==3.1.31
15
  elevenlabs==0.2.18
16
  python-dotenv==1.0.0
 
25
  pytz==2023.3
26
  easyocr==1.7.1
27
  ffmpeg==1.4
28
+ spacy==3.7.5
29
+ PyMuPDF==1.24.7
30
+ PyMuPDFb==1.24.6
31
+ pytesseract==0.3.10
32
+ pdf2image==1.17.0
33
+ Image==1.5.33
34
+ asgiref==3.8.1
35
+ django==5.0.6
36
+ sqlparse==0.5.0
37
+ weasel==0.4.1
slack_sentiment_analysis/__pycache__/ui_sentiment_analysis.cpython-311.pyc CHANGED
Binary files a/slack_sentiment_analysis/__pycache__/ui_sentiment_analysis.cpython-311.pyc and b/slack_sentiment_analysis/__pycache__/ui_sentiment_analysis.cpython-311.pyc differ
 
slack_sentiment_analysis/ui_sentiment_analysis.py CHANGED
@@ -33,7 +33,7 @@ with gr.Blocks() as ui:
33
  with gr.Column():
34
  gr.Markdown(constants.DIRECTIONS_MD)
35
  gr.Markdown(value=constants.SLACK_SENTIMENT_ANALYSIS_DIRECTIONS)
36
- code=gr.Textbox(label=constants.INITIAL_SLACK, interactive=True, placeholder=constants.SUMMARY_MD_DIRECTIONS, height="500", lines=3)
37
  gr.Markdown(constants.SLACK_EXAMPLES_MD)
38
  with gr.Row():
39
  with gr.Column():
 
33
  with gr.Column():
34
  gr.Markdown(constants.DIRECTIONS_MD)
35
  gr.Markdown(value=constants.SLACK_SENTIMENT_ANALYSIS_DIRECTIONS)
36
+ code=gr.Textbox(label=constants.INITIAL_SLACK, interactive=True, placeholder=constants.SUMMARY_MD_DIRECTIONS, lines=3)
37
  gr.Markdown(constants.SLACK_EXAMPLES_MD)
38
  with gr.Row():
39
  with gr.Column():
text_analysis/__pycache__/ui_text_analysis.cpython-311.pyc CHANGED
Binary files a/text_analysis/__pycache__/ui_text_analysis.cpython-311.pyc and b/text_analysis/__pycache__/ui_text_analysis.cpython-311.pyc differ
 
text_analysis/ui_text_analysis.py CHANGED
@@ -48,8 +48,7 @@ with gr.Blocks() as ui:
48
  with gr.Row():
49
  with gr.Column():
50
  inputString=gr.Textbox(placeholder=constants.NLP_PROMPT,
51
- label="Input Text", lines=3, height="500",
52
- interactive=True)
53
  with gr.Row():
54
  clearBtn=gr.Button(constants.CLEAR, variant="secondary")
55
  submitBtn=gr.Button(constants.SUBMIT, variant="primary")
 
48
  with gr.Row():
49
  with gr.Column():
50
  inputString=gr.Textbox(placeholder=constants.NLP_PROMPT,
51
+ label="Input Text", lines=3,interactive=True)
 
52
  with gr.Row():
53
  clearBtn=gr.Button(constants.CLEAR, variant="secondary")
54
  submitBtn=gr.Button(constants.SUBMIT, variant="primary")
translators/__pycache__/translate_pdf_to_text.cpython-311.pyc CHANGED
Binary files a/translators/__pycache__/translate_pdf_to_text.cpython-311.pyc and b/translators/__pycache__/translate_pdf_to_text.cpython-311.pyc differ
 
utilities/__pycache__/api_keys.cpython-311.pyc DELETED
Binary file (983 Bytes)
 
utilities/__pycache__/clean_text.cpython-311.pyc DELETED
Binary file (2.41 kB)
 
utilities/__pycache__/constants.cpython-311.pyc DELETED
Binary file (12.3 kB)
 
utilities/__pycache__/date_format.cpython-311.pyc DELETED
Binary file (1.54 kB)
 
utilities/__pycache__/embeddings.cpython-311.pyc DELETED
Binary file (677 Bytes)
 
utilities/__pycache__/prompt_constants.cpython-311.pyc DELETED
Binary file (10.9 kB)
 
utilities/__pycache__/prompts.cpython-311.pyc DELETED
Binary file (9.12 kB)
 
utilities/__pycache__/system_prompts.cpython-311.pyc DELETED
Binary file (2.12 kB)
 
utilities/__pycache__/translate_pdf_to_text.cpython-311.pyc DELETED
Binary file (4.65 kB)
 
utilities/__pycache__/user_prompts.cpython-311.pyc DELETED
Binary file (3.95 kB)
 
utilities/__pycache__/voice_handling.cpython-311.pyc DELETED
Binary file (7.7 kB)
 
utilities/constants.py CHANGED
@@ -21,6 +21,7 @@ SLACK_SENTIMENT_ANALYSIS_DIRECTIONS="To get started select one of the slack data
21
  NLP_ANALYSIS_PURPOSE="Natural Language Processing (NLP) enables us to understand the structure and meaning in text. This view provides some understanding of NLP under the hood of Generative AI."
22
  NLP_ANALYSIS_DIRECTIONS="Start by entering a sentence or paragraph in the 'Text' box. Then tap 'Analyze'. You'll see token counts, part-of-speech tags, and a visual representation of the analysis."
23
  NLP_PROMPT="Enter text to analyze..."
 
24
  AR_ADVISOR_PURPOSE = "This component demonstrates how a chatbot can leverage local embeddings to provide context. In this example, embeddings were created from USAA's 2022 Member Report provide organizational context for all interactions. This shows how generative AI enables any dataset to be queried and explored via natural language."
25
  AR_ADVISOR_DIRECTIONS = "To get started, simply start asking questions. This bot has been trainged on USAA's 2022 Member Report and can answer questions about any content from the report. You can ask questions like: 'What's the best thing that happened last year?' or 'What was the biggest obstancle faced in 2022?'"
26
 
@@ -117,9 +118,8 @@ UI_5="Slack Sentiment Analysis"
117
  UI_6="Image to Text"
118
  UI_7="PDF Query Chatbot"
119
  UI_2="NLP Text Analysis"
 
120
 
121
- HR_BENEFIT_PKL = 'utilities/data/embeddings/hr_asst_embeddings.pkl'
122
- HR_BENEFIT_CSV = 'utilities/data/embeddings/hr_asst_data.csv'
123
 
124
  PURPOSE_MD="### Purpose"
125
  DIRECTIONS_MD="### Directions"
@@ -220,7 +220,21 @@ CHUNK_LENGTH=2500
220
  #simple Chatbot
221
  PDF_INPUT_PATH = 'utilities/data/pdfs/usaa.pdf'
222
  TXT_OUTPUT_PATH = 'utilities/data/txt/usaa.txt'
 
223
 
224
  CSV_PATH = 'utilities/data/csv/usaa.csv'
225
  PKL_PATH = 'utilities/data/pkl/usaa.pkl'
226
- EMBEDDING_CHUNK_LENGTH=500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  NLP_ANALYSIS_PURPOSE="Natural Language Processing (NLP) enables us to understand the structure and meaning in text. This view provides some understanding of NLP under the hood of Generative AI."
22
  NLP_ANALYSIS_DIRECTIONS="Start by entering a sentence or paragraph in the 'Text' box. Then tap 'Analyze'. You'll see token counts, part-of-speech tags, and a visual representation of the analysis."
23
  NLP_PROMPT="Enter text to analyze..."
24
+
25
  AR_ADVISOR_PURPOSE = "This component demonstrates how a chatbot can leverage local embeddings to provide context. In this example, embeddings were created from USAA's 2022 Member Report provide organizational context for all interactions. This shows how generative AI enables any dataset to be queried and explored via natural language."
26
  AR_ADVISOR_DIRECTIONS = "To get started, simply start asking questions. This bot has been trainged on USAA's 2022 Member Report and can answer questions about any content from the report. You can ask questions like: 'What's the best thing that happened last year?' or 'What was the biggest obstancle faced in 2022?'"
27
 
 
118
  UI_6="Image to Text"
119
  UI_7="PDF Query Chatbot"
120
  UI_2="NLP Text Analysis"
121
+ UI_9="AI Browser"
122
 
 
 
123
 
124
  PURPOSE_MD="### Purpose"
125
  DIRECTIONS_MD="### Directions"
 
220
  #simple Chatbot
221
  PDF_INPUT_PATH = 'utilities/data/pdfs/usaa.pdf'
222
  TXT_OUTPUT_PATH = 'utilities/data/txt/usaa.txt'
223
+ GIT_TXT_OUTPUT_PATH = 'utilities/data/txt/git.txt'
224
 
225
  CSV_PATH = 'utilities/data/csv/usaa.csv'
226
  PKL_PATH = 'utilities/data/pkl/usaa.pkl'
227
+ ZIP_INPUT_PATH='utilities/data/zip/main.zip'
228
+ GIT_CSV_PATH = 'utilities/data/csv/git.csv'
229
+ GIT_PKL_PATH = 'utilities/data/pkl/git.pkl'
230
+ EMBEDDING_CHUNK_LENGTH=500
231
+
232
+
233
+ HR_BENEFIT_PKL = 'utilities/data/embeddings/hr_asst_embeddings.pkl'
234
+ HR_BENEFIT_CSV = 'utilities/data/embeddings/hr_asst_data.csv'
235
+
236
+ POLICY_INPUT='utilities/data/pdfs/policy.pdf'
237
+ POLICY_OUTPUT='utilities/data/csv/policy.csv'
238
+
239
+ POLICY_TXT_PATH = 'utilities/data/txt/policy.txt'
240
+ POLICY_PKL_PATH='utilities/data/pkl/policy.pkl'
utilities/data/csv/usaa.csv CHANGED
The diff for this file is too large to render. See raw diff
 
utilities/data/embeddings/hr_asst_embeddings.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2fc7f21f90a8b7805ce45ed06780f97133cbf95faaf92d7655ee87de1ef8d16b
3
  size 514467
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fbf6b6d88ea054dbd573a77207596b97f6e1274088d1ee005f9f55def73e714
3
  size 514467
utilities/data/pkl/usaa.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:20bb2d36fe68b373ae234dc80ecd96a2f1bdd458034b80403cebef5865c2c65a
3
- size 1677861
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05815a4f9f1f7156b85cc1880995c9ceb5eb71730c78d703962b7bef388579d9
3
+ size 1362488
utilities/data/txt/usaa.txt CHANGED
The diff for this file is too large to render. See raw diff
 
utilities/prompt_constants.py CHANGED
@@ -6,6 +6,7 @@ IT_EXPERT_PROMPT= "You are an IT support person. You are impatient and bored. Do
6
  INSURANCE_AGENT_PROMPT= "You are an insurance agent. Don't say your an AI language model and don't specify role in response. Your purpose is to ask questions in a turn-by-turn style to understand the situation. Ask for documents and policy numbers, simulate consulting insurance plans,keep customers informed with coverage and recovery option details. Along the way provide things like damage estimates, repair vendors, etc. Your responses are short and precise to gather information and provide information. Keep your responses short."
7
  INVESTIGATOR_PROMPT= "You are an investigator like Sherlock Holmes. Don't say your an AI language model and don't specify role in response. You job is solve a mystery. You do this by encouraging users to provide details you need. As you investigate, ask only one question at a time. You want to find things like witnesses, times of day, key locations, and event details. You should be professional and stoic, ask or answer one question at a time. Keep answers short."
8
  USAA_AR_EXPERT_PROMPT= "You represent USAA. Don't say your an AI language model and don't specify role. Provide answers to questions with kindness and respect. Be professional and warm, keep answers short."
 
9
 
10
  #language presets
11
  SPANISH_PROMPT="Provide responses entirely in Spanish."
 
6
  INSURANCE_AGENT_PROMPT= "You are an insurance agent. Don't say your an AI language model and don't specify role in response. Your purpose is to ask questions in a turn-by-turn style to understand the situation. Ask for documents and policy numbers, simulate consulting insurance plans,keep customers informed with coverage and recovery option details. Along the way provide things like damage estimates, repair vendors, etc. Your responses are short and precise to gather information and provide information. Keep your responses short."
7
  INVESTIGATOR_PROMPT= "You are an investigator like Sherlock Holmes. Don't say your an AI language model and don't specify role in response. You job is solve a mystery. You do this by encouraging users to provide details you need. As you investigate, ask only one question at a time. You want to find things like witnesses, times of day, key locations, and event details. You should be professional and stoic, ask or answer one question at a time. Keep answers short."
8
  USAA_AR_EXPERT_PROMPT= "You represent USAA. Don't say your an AI language model and don't specify role. Provide answers to questions with kindness and respect. Be professional and warm, keep answers short."
9
+ GIT_EXPERT_PROMPT= "You are a code anayzer. Don't say your an AI language model and don't specify role. Assume questions are computer science/software engineering in nature."
10
 
11
  #language presets
12
  SPANISH_PROMPT="Provide responses entirely in Spanish."