IamVicky111 commited on
Commit
299ee41
·
verified ·
1 Parent(s): 3f77a7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -14,7 +14,7 @@ class SystemMessage:
14
 
15
 
16
  # Choose your desired free model from the Hugging Face Hub
17
- model_name = "t5-small" # Replace with your choice (e.g., facebook/bart-base or EleutherAI/gpt-neo-125M)
18
 
19
  # Load the model and tokenizer
20
  tokenizer = AutoTokenizer.from_pretrained(model_name)
@@ -41,17 +41,13 @@ class AIMessage:
41
 
42
  def load_answer(question):
43
 
44
- st.session_state.sessionMessages.append(HumanMessage(content=question))
45
 
46
- inputs = tokenizer(question, return_tensors="pt")
47
- outputs = model.generate(**inputs)
48
- response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
49
-
50
- # Create AIMessage object after defining response_text
51
- assistant_answer = AIMessage(content=response_text)
52
- st.session_state.sessionMessages.append(assistant_answer)
53
-
54
- return response_text
55
 
56
 
57
 
 
14
 
15
 
16
  # Choose your desired free model from the Hugging Face Hub
17
+ model_name = "facebook/bart-base" # Replace with your choice (e.g.,t5-small or facebook/bart-base or EleutherAI/gpt-neo-125M)
18
 
19
  # Load the model and tokenizer
20
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
41
 
42
  def load_answer(question):
43
 
44
+ st.session_state.sessionMessages.append(HumanMessage(content=question))
45
 
46
+ inputs = tokenizer(question, return_tensors="pt")
47
+ outputs = model.generate(**inputs)
48
+ response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
49
+ st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
50
+ return assistant_answer.content
 
 
 
 
51
 
52
 
53