valencar commited on
Commit
13ba95b
·
verified ·
1 Parent(s): c625dc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -22
app.py CHANGED
@@ -10,9 +10,9 @@ import os
10
  token = os.getenv("modelo")
11
  login(token = token)
12
 
13
- question = "Name the planets in the solar system? A: "
14
- question = "Quais são os planetas do sistema solar?"
15
- question = "Qual é o maior planeta do sistema solar?"
16
 
17
  before = datetime.datetime.now()
18
 
@@ -30,30 +30,31 @@ pipeline = transformers.pipeline(
30
  device_map="auto",
31
  )
32
 
 
 
33
  with st.container():
34
  st.write('\n\n')
35
  st.title('LLM-LANAChat\n\n')
36
  question = st.text_input("Chat", placeholder="E ai?")
37
 
38
-
39
-
40
- messages = [
41
- # {"role": "system", "content": "You are a chatbot"},
42
- {"role": "user", "content": question}
43
- ]
44
- st.write('Gerando a saída...')
45
- outputs = pipeline(
46
- messages,
47
- max_new_tokens=256,
48
- )
49
- response = outputs[0]["generated_text"][-1]
50
- st.write('Saída gerada...')
51
-
52
-
53
- # =====================================================
54
-
55
- print('\n\n')
56
- st.write(response)
57
 
58
 
59
  after = datetime.datetime.now()
 
10
  token = os.getenv("modelo")
11
  login(token = token)
12
 
13
+ # question = "Name the planets in the solar system? A: "
14
+ # question = "Quais são os planetas do sistema solar?"
15
+ # question = "Qual é o maior planeta do sistema solar?"
16
 
17
  before = datetime.datetime.now()
18
 
 
30
  device_map="auto",
31
  )
32
 
33
+ question = None
34
+
35
  with st.container():
36
  st.write('\n\n')
37
  st.title('LLM-LANAChat\n\n')
38
  question = st.text_input("Chat", placeholder="E ai?")
39
 
40
+ if question is not None:
41
+ messages = [
42
+ # {"role": "system", "content": "You are a chatbot"},
43
+ {"role": "user", "content": question}
44
+ ]
45
+ st.write('Gerando a saída...')
46
+ outputs = pipeline(
47
+ messages,
48
+ max_new_tokens=256,
49
+ )
50
+ response = outputs[0]["generated_text"][-1]
51
+ st.write('Saída gerada...')
52
+
53
+
54
+ # =====================================================
55
+
56
+ print('\n\n')
57
+ st.write(response)
 
58
 
59
 
60
  after = datetime.datetime.now()