Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,42 +15,7 @@ from langchain.chains import ConversationChain
|
|
15 |
from langchain.memory import ConversationBufferMemory
|
16 |
from langchain_community.llms import HuggingFaceEndpoint
|
17 |
import torch
|
18 |
-
|
19 |
-
import sys
|
20 |
-
import getpass
|
21 |
-
|
22 |
-
def masked_input(prompt=''):
|
23 |
-
import sys
|
24 |
-
import tty
|
25 |
-
import termios
|
26 |
-
|
27 |
-
print(prompt, end='', flush=True)
|
28 |
-
fd = sys.stdin.fileno()
|
29 |
-
old_settings = termios.tcgetattr(fd)
|
30 |
-
try:
|
31 |
-
tty.setraw(fd)
|
32 |
-
password = ''
|
33 |
-
while True:
|
34 |
-
ch = sys.stdin.read(1)
|
35 |
-
if ch == '\n' or ch == '\r':
|
36 |
-
break
|
37 |
-
elif ch == '\x7f': # Handle backspace
|
38 |
-
if len(password) > 0:
|
39 |
-
password = password[:-1]
|
40 |
-
sys.stdout.write('\b \b')
|
41 |
-
else:
|
42 |
-
password += ch
|
43 |
-
sys.stdout.write('*')
|
44 |
-
sys.stdout.flush()
|
45 |
-
finally:
|
46 |
-
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
47 |
-
print() # For newline
|
48 |
-
return password
|
49 |
-
|
50 |
-
# Solicita ao usuário a chave API de forma segura
|
51 |
-
api_key = masked_input(prompt="Digite sua chave API: ")
|
52 |
-
os.environ["OPENAI_API_KEY"] = api_key
|
53 |
-
# Solicita ao usuário a chave API de forma segura
|
54 |
|
55 |
|
56 |
|
|
|
15 |
from langchain.memory import ConversationBufferMemory
|
16 |
from langchain_community.llms import HuggingFaceEndpoint
|
17 |
import torch
|
18 |
+
api_token = os.getenv("pdf")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
|