namantjeaswi commited on
Commit
1264fc9
·
1 Parent(s): 8e17490

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -28,19 +28,13 @@ tokenizer = AutoTokenizer.from_pretrained(model_id)
28
  model = AutoModelForCausalLM.from_pretrained(model_id)
29
 
30
  # Create text generation pipeline
31
- pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
32
 
33
 
34
- prompt = st.text_input("Please ask your question here:")
35
-
36
-
37
-
38
- if prompt := st.chat_input("Please ask your question here:"):
39
- # Display user message in chat message container
40
- st.chat_message("user").markdown("<b style='color:Red;'>"+prompt+"</b>", unsafe_allow_html=True)
41
- # Add user message to chat history
42
- st.session_state.query = prompt
43
- st.session_state.messages.append({"role": "user", "content": prompt})
44
- # Generate response
45
- result = pipe(prompt)#, max_length=100, num_return_sequences=1)
46
-
 
28
  model = AutoModelForCausalLM.from_pretrained(model_id)
29
 
30
  # Create text generation pipeline
31
+ pipe = pipeline(model = model, tokenizer = tokenizer)
32
 
33
 
34
+ with st.form('my_form'):
35
+ question = st.text_area('Enter your question:', 'Tell me about attention mechanisms in a transformer?')
36
+ submitted = st.form_submit_button('Submit')
37
+ if submitted:
38
+ result = pipe(question, max_length=100)
39
+ st.write(question)
40
+ st.write(result[0]['generated_text'])