Ridealist commited on
Commit
6d7dbcd
1 Parent(s): ae805db

feat: implement env variables setting for building dependency in Hugging Face

Browse files
modules/db_modules.py CHANGED
@@ -1,15 +1,17 @@
1
-
2
  import boto3
 
 
3
  from boto3.dynamodb.conditions import Key
4
  from dotenv import dotenv_values
5
 
6
  config = dotenv_values(".env")
7
 
8
- AWS_ACCESS_KEY_ID = config.get('AWS_ACCESS_KEY_ID')
9
- AWS_SECRET_ACCESS_KEY = config.get('AWS_SECRET_ACCESS_KEY')
10
-
11
- # AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
12
- # AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
 
13
 
14
 
15
  def get_db():
 
 
1
  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
  def get_db():
modules/gpt_modules.py CHANGED
@@ -1,11 +1,17 @@
1
  import openai
 
2
 
3
  from dotenv import dotenv_values
4
 
5
  config = dotenv_values(".env")
6
 
7
- openai.organization = config.get('OPENAI_ORGANIZATION')
8
- openai.api_key = config.get('OPENAI_API_KEY')
 
 
 
 
 
9
 
10
  def gpt_call(prompt, role="user"):
11
  response = openai.ChatCompletion.create(
 
1
  import openai
2
+ import streamlit as st
3
 
4
  from dotenv import dotenv_values
5
 
6
  config = dotenv_values(".env")
7
 
8
+ if config:
9
+ openai.organization = config.get('OPENAI_ORGANIZATION')
10
+ openai.api_key = config.get('OPENAI_API_KEY')
11
+ else:
12
+ openai.organization = st.secrets['OPENAI_ORGANIZATION']
13
+ openai.api_key = st.secrets['OPENAI_API_KEY']
14
+
15
 
16
  def gpt_call(prompt, role="user"):
17
  response = openai.ChatCompletion.create(
modules/whisper_modules.py CHANGED
@@ -1,9 +1,11 @@
1
- from dotenv import dotenv_values
2
  import openai
3
  import os
 
 
 
4
  from langchain.prompts import PromptTemplate
5
  from modules.gpt_modules import gpt_call
6
- import random
7
 
8
  """
9
  apt-get update
@@ -12,8 +14,13 @@ apt-get install ffmpeg
12
 
13
  config = dotenv_values(".env")
14
 
15
- openai.organization = config.get('OPENAI_ORGANIZATION')
16
- openai.api_key = config.get('OPENAI_API_KEY')
 
 
 
 
 
17
 
18
  def debate_in_sound(audio):
19
  os.rename(audio, audio + '.wav')
 
 
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
8
+ from dotenv import dotenv_values
9
 
10
  """
11
  apt-get update
 
14
 
15
  config = dotenv_values(".env")
16
 
17
+ if config:
18
+ openai.organization = config.get('OPENAI_ORGANIZATION')
19
+ openai.api_key = config.get('OPENAI_API_KEY')
20
+ else:
21
+ openai.organization = st.secrets['OPENAI_ORGANIZATION'] #config.get('OPENAI_ORGANIZATION')
22
+ openai.api_key = st.secrets['OPENAI_API_KEY'] #config.get('OPENAI_API_KEY')
23
+
24
 
25
  def debate_in_sound(audio):
26
  os.rename(audio, audio + '.wav')