shanthi-323 commited on
Commit
d7eaedb
·
verified ·
1 Parent(s): f35ee3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,24 +1,22 @@
1
  import streamlit as st
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
 
4
- # Load the model and tokenizer
5
  @st.cache_resource
6
  def load_model():
7
- model_name = "shanthi-323/lora_model_qnachatbot_cbt_q4_k_m"
8
- tokenizer = AutoTokenizer.from_pretrained(model_name)
9
- model = AutoModelForCausalLM.from_pretrained(model_name)
10
- return tokenizer, model
11
 
12
- tokenizer, model = load_model()
13
 
14
- st.title("AI Chatbot")
15
- st.write("Chat with your fine-tuned model!")
16
 
17
  # User input
18
  user_input = st.text_input("You: ", placeholder="Type your message here...")
19
 
20
  if user_input:
21
- inputs = tokenizer(user_input, return_tensors="pt")
22
- outputs = model.generate(inputs["input_ids"], max_length=100)
23
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
24
- st.text_area("Bot:", value=response, height=200, max_chars=None)
 
1
  import streamlit as st
2
+ from llama_cpp import Llama
3
 
4
+ # Load the GGUF model
5
  @st.cache_resource
6
  def load_model():
7
+ model_path = "shanthi-323/lora_model_qnachatbot_cbt_q4_k_m" # Ensure this path matches your uploaded GGUF model file
8
+ return Llama(model_path=model_path)
 
 
9
 
10
+ llm = load_model()
11
 
12
+ st.title("Chat with GGUF Model")
13
+ st.write("Start interacting with your fine-tuned chatbot!")
14
 
15
  # User input
16
  user_input = st.text_input("You: ", placeholder="Type your message here...")
17
 
18
  if user_input:
19
+ # Generate a response using llama-cpp-python
20
+ response = llm(user_input)
21
+ st.text_area("Bot:", value=response["choices"][0]["text"].strip(), height=200)
22
+