Renato Cardoso Zimmer commited on
Commit
0d6fbea
1 Parent(s): 6382838

#OpenAi_Api_Key#

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -11,7 +11,9 @@ import time
11
  import os
12
 
13
  # Carregar chave da API OpenAI
14
- os.environ["OPENAI_API_KEY"]
 
 
15
 
16
  # Variáveis globais para armazenamento dos objetos carregados
17
  global bd, chain
@@ -27,7 +29,7 @@ def initialize_chatbot():
27
  llm = ChatOpenAI(
28
  temperature=0.0,
29
  model="gpt-3.5-turbo",
30
- api_key=os.environ["OPENAI_API_KEY"],
31
  )
32
 
33
  carregador = TextLoader("docs/Produtos.txt", encoding="utf-8")
@@ -73,4 +75,4 @@ with gr.Blocks(css=css, title='Adega Hippo') as demo:
73
  # Inicializar o chatbot
74
  initialize_chatbot()
75
 
76
- demo.launch()
 
11
  import os
12
 
13
  # Carregar chave da API OpenAI
14
+ api_key = os.getenv("OPENAI_API_KEY")
15
+ if not api_key:
16
+ raise ValueError("OPENAI_API_KEY não está definido no ambiente.")
17
 
18
  # Variáveis globais para armazenamento dos objetos carregados
19
  global bd, chain
 
29
  llm = ChatOpenAI(
30
  temperature=0.0,
31
  model="gpt-3.5-turbo",
32
+ api_key=api_key,
33
  )
34
 
35
  carregador = TextLoader("docs/Produtos.txt", encoding="utf-8")
 
75
  # Inicializar o chatbot
76
  initialize_chatbot()
77
 
78
+ demo.launch(share=True)