Ridealist commited on
Commit
3708b8e
1 Parent(s): 3bcbe7a

refactor: 불필요한 코드 제거, DB 관련 코드 주석 처리

Browse files
modules/db_modules.py CHANGED
@@ -2,16 +2,16 @@ import boto3
2
  import streamlit as st
3
 
4
  from boto3.dynamodb.conditions import Key
5
- from dotenv import dotenv_values
6
 
7
- config = dotenv_values(".env")
8
 
9
- if config:
10
- AWS_ACCESS_KEY_ID = config.get('AWS_ACCESS_KEY_ID')
11
- AWS_SECRET_ACCESS_KEY = config.get('AWS_SECRET_ACCESS_KEY')
12
- else:
13
- AWS_ACCESS_KEY_ID = st.secrets['AWS_ACCESS_KEY_ID']
14
- AWS_SECRET_ACCESS_KEY = st.secrets['AWS_SECRET_ACCESS_KEY']
15
 
16
 
17
  @st.cache_resource
@@ -19,8 +19,8 @@ def get_db():
19
  dynamodb = boto3.resource(
20
  'dynamodb',
21
  region_name='ap-northeast-2',
22
- aws_access_key_id=AWS_ACCESS_KEY_ID,
23
- aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
24
  )
25
  print("dynamodb connected", dynamodb)
26
 
 
2
  import streamlit as st
3
 
4
  from boto3.dynamodb.conditions import Key
5
+ # from dotenv import dotenv_values
6
 
7
+ # config = dotenv_values(".env")
8
 
9
+ # if config:
10
+ # AWS_ACCESS_KEY_ID = config.get('AWS_ACCESS_KEY_ID')
11
+ # AWS_SECRET_ACCESS_KEY = config.get('AWS_SECRET_ACCESS_KEY')
12
+ # else:
13
+ # AWS_ACCESS_KEY_ID = st.secrets['AWS_ACCESS_KEY_ID']
14
+ # AWS_SECRET_ACCESS_KEY = st.secrets['AWS_SECRET_ACCESS_KEY']
15
 
16
 
17
  @st.cache_resource
 
19
  dynamodb = boto3.resource(
20
  'dynamodb',
21
  region_name='ap-northeast-2',
22
+ # aws_access_key_id=AWS_ACCESS_KEY_ID,
23
+ # aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
24
  )
25
  print("dynamodb connected", dynamodb)
26
 
modules/gpt_modules.py CHANGED
@@ -36,5 +36,4 @@ def gpt_call_context(api_key, messages):
36
  )
37
  output_text = response["choices"][0]["message"]["content"]
38
 
39
- # raise RuntimeError
40
- return output_text
 
36
  )
37
  output_text = response["choices"][0]["message"]["content"]
38
 
39
+ return output_text
 
modules/history_modules.py CHANGED
@@ -1,4 +1,5 @@
1
- from modules.db_modules import get_db, put_item, get_item, get_lastest_item
 
2
 
3
  def get_history(
4
  table,
@@ -28,4 +29,4 @@ def get_history(
28
 
29
  history = "\n".join(history_dummy_list)
30
 
31
- return history, history_num
 
1
+ from modules.db_modules import get_lastest_item
2
+
3
 
4
  def get_history(
5
  table,
 
29
 
30
  history = "\n".join(history_dummy_list)
31
 
32
+ return history, history_num
modules/query_modules.py CHANGED
@@ -2,7 +2,7 @@ from time import time
2
  from datetime import datetime
3
 
4
  # modules
5
- from modules.db_modules import put_item, get_lastest_item
6
  from modules.history_modules import get_history
7
 
8
  # bots
 
2
  from datetime import datetime
3
 
4
  # modules
5
+ from modules.db_modules import put_item
6
  from modules.history_modules import get_history
7
 
8
  # bots
modules/whisper_modules.py CHANGED
@@ -1,7 +1,6 @@
1
  import openai
2
  import os
3
  import random
4
- # import streamlit as st
5
 
6
  from langchain.prompts import PromptTemplate
7
  from modules.gpt_modules import gpt_call
@@ -30,7 +29,7 @@ def debate_in_sound(api_key, audio):
30
  print("user_audio transcription", user_prompt)
31
  print("**************************************")
32
 
33
- # 일단 테스트를 위해 고정함
34
  debate_subject = "In 2050, AI robots are able to replicate the appearance, conversation, and reaction to emotions of human beings. However, their intelligence still does not allow them to sense emotions and feelings such as pain, happiness, joy, and etc."
35
 
36
  debate_role = [
@@ -74,14 +73,3 @@ def whisper_transcribe(api_key, audio_file):
74
  audio_file.close()
75
 
76
  return result
77
-
78
-
79
- # gr.Interface(
80
- # title = 'Whisper Audio to Text with Speaker Recognition',
81
- # fn=debate,
82
- # inputs=[
83
- # gr.inputs.Audio(source="microphone", type="filepath"),
84
- # #gr.inputs.Number(default=2, label="Number of Speakers")
85
- # ],
86
- # outputs="text"
87
- # ).launch()
 
1
  import openai
2
  import os
3
  import random
 
4
 
5
  from langchain.prompts import PromptTemplate
6
  from modules.gpt_modules import gpt_call
 
29
  print("user_audio transcription", user_prompt)
30
  print("**************************************")
31
 
32
+ # Testing Prompt
33
  debate_subject = "In 2050, AI robots are able to replicate the appearance, conversation, and reaction to emotions of human beings. However, their intelligence still does not allow them to sense emotions and feelings such as pain, happiness, joy, and etc."
34
 
35
  debate_role = [
 
73
  audio_file.close()
74
 
75
  return result