juancamval commited on
Commit
f29a06c
·
verified ·
1 Parent(s): 9e76dd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -2,15 +2,20 @@ import os
2
  import streamlit as st
3
  from transformers import pipeline
4
 
 
5
  st.title("Testing Gemma")
6
- input_text = st.text_input("How can i help you: ")
7
- process = st.button("ask")
8
 
9
  messages = [
10
  {"role": "user", "content": input_text},
11
  {"role": "system", "content": "You are a helpful assistant."}
12
  ]
13
- pipe = pipeline("text-generation", model="google/gemma-3-1b-it",token=os.getenv("HF_TOKEN"))
14
 
15
- if process:
16
- st.write(pipe(input_text))
 
 
 
 
 
2
  import streamlit as st
3
  from transformers import pipeline
4
 
5
+
6
  st.title("Testing Gemma")
7
+ input_text = st.text_input("How can I help you: ")
8
+ process = st.button("Ask")
9
 
10
  messages = [
11
  {"role": "user", "content": input_text},
12
  {"role": "system", "content": "You are a helpful assistant."}
13
  ]
14
+ pipe = pipeline("text-generation", model="google/gemma-3-1b-it", token=os.getenv("HF_TOKEN"))
15
 
16
+ if process and input_text:
17
+ output = pipe(input_text)
18
+ if output and isinstance(output, list) and len(output) > 0 and "generated_text" in output[0]:
19
+ st.write(output[0]["generated_text"])
20
+ else:
21
+ st.write("No response generated or unexpected output format.")