Demosthene-OR commited on
Commit
ca1d2f5
·
1 Parent(s): 03c5d82
Files changed (2) hide show
  1. app.py +1 -1
  2. tabs/playground.py +28 -24
app.py CHANGED
@@ -102,7 +102,7 @@ def run():
102
  st.session_state['OPENAI_API_KEY'] = openai_api_key
103
  st.sidebar.success("OpenAI API Key set successfully.")
104
  else:
105
- openai_api_key = ""
106
  with st.sidebar:
107
  st.selectbox("langue:",lang_tgt, format_func = find_lang_label, key="Language", label_visibility="hidden")
108
 
 
102
  st.session_state['OPENAI_API_KEY'] = openai_api_key
103
  st.sidebar.success("OpenAI API Key set successfully.")
104
  else:
105
+ os.environ['OPENAI_API_KEY'] = ""
106
  with st.sidebar:
107
  st.selectbox("langue:",lang_tgt, format_func = find_lang_label, key="Language", label_visibility="hidden")
108
 
tabs/playground.py CHANGED
@@ -7,10 +7,12 @@ import os
7
  import warnings
8
  warnings.filterwarnings('ignore')
9
 
10
- if st.session_state.Cloud != 0:
11
- load_dotenv()
12
  os.getenv("OPENAI_API_KEY")
13
- openai.api_key = os.environ["OPENAI_API_KEY"]
 
 
14
 
15
  title = "Playground ChatGPT"
16
  sidebar_name = "Playground"
@@ -86,27 +88,29 @@ def run():
86
  Cet espace a pour objectif d'observer la génération de token par ChatGPT'
87
  """)
88
  , unsafe_allow_html=True)
89
-
90
- try:
91
- col1, col2 = st.columns([3, 1])
92
- with col2:
93
- temperature = st.slider(
94
- label=tr("Temperature"),
95
- min_value=0.0,
96
- max_value=1.0,
97
- value=0.0 # Valeur initiale
98
- )
99
- max_token = st.slider(
100
- label=tr("Max tokens"),
101
- min_value=1,
102
- max_value=500,
103
- value=100 # Valeur initiale
104
- )
105
- with col1:
106
- prompt = st.text_area(label=tr("Prompt:"), value="La souris est mangée par le",height=100)
107
- display_proba_next_token(prompt,temperature,max_token)
108
- except Exception as e:
109
- st.error(f"An unexpected error occurred: {e}")
 
 
110
 
111
 
112
 
 
7
  import warnings
8
  warnings.filterwarnings('ignore')
9
 
10
+ # if st.session_state.Cloud == 0:
11
+ # load_dotenv()
12
  os.getenv("OPENAI_API_KEY")
13
+ openai_api_key = os.environ["OPENAI_API_KEY"]
14
+ if openai_api_key !="":
15
+ openai.api_key = os.environ["OPENAI_API_KEY"]
16
 
17
  title = "Playground ChatGPT"
18
  sidebar_name = "Playground"
 
88
  Cet espace a pour objectif d'observer la génération de token par ChatGPT'
89
  """)
90
  , unsafe_allow_html=True)
91
+ if openai_api_key != "":
92
+ try:
93
+ col1, col2 = st.columns([3, 1])
94
+ with col2:
95
+ temperature = st.slider(
96
+ label=tr("Temperature"),
97
+ min_value=0.0,
98
+ max_value=1.0,
99
+ value=0.0 # Valeur initiale
100
+ )
101
+ max_token = st.slider(
102
+ label=tr("Max tokens"),
103
+ min_value=1,
104
+ max_value=500,
105
+ value=100 # Valeur initiale
106
+ )
107
+ with col1:
108
+ prompt = st.text_area(label=tr("Prompt:"), value="La souris est mangée par le",height=100)
109
+ display_proba_next_token(prompt,temperature,max_token)
110
+ except Exception as e:
111
+ st.error(f"An unexpected error occurred: {e}")
112
+ else:
113
+ st.write("Saisissez d'abord votre clé API OpenAI !")
114
 
115
 
116