kshitij230 commited on
Commit
226cfd8
·
verified ·
1 Parent(s): edf6788

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +53 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from llama_cpp import Llama
3
+
4
+ # Load the GGUF model from Hugging Face
5
+ @st.cache_resource
6
+ def load_model():
7
+ llm = Llama.from_pretrained(
8
+ repo_id="kshitij230/Eunoia",
9
+ filename="unsloth.Q8_0.gguf",
10
+ n_ctx=2048,
11
+ chat_format="llama-2" # Change this if your model uses a different format
12
+ )
13
+ return llm
14
+
15
+ llm = load_model()
16
+
17
+ # Streamlit page config
18
+ st.set_page_config(page_title="Eunoia 💜", layout="centered")
19
+ st.title("🫂 Eunoia - Your Emotional Support Bot")
20
+ st.markdown("Speak your heart. I'm here to listen and help 💖")
21
+
22
+ # Chat history
23
+ if "messages" not in st.session_state:
24
+ st.session_state.messages = []
25
+
26
+ # Show history
27
+ for msg in st.session_state.messages:
28
+ with st.chat_message(msg["role"]):
29
+ st.markdown(msg["content"])
30
+
31
+ # Input box
32
+ user_input = st.chat_input("What's on your mind?")
33
+
34
+ if user_input:
35
+ # Display user message
36
+ st.chat_message("user").markdown(user_input)
37
+ st.session_state.messages.append({"role": "user", "content": user_input})
38
+
39
+ # Build conversation prompt (simple format)
40
+ prompt = ""
41
+ for msg in st.session_state.messages:
42
+ role = "User" if msg["role"] == "user" else "Bot"
43
+ prompt += f"{role}: {msg['content']}\n"
44
+ prompt += "Bot:"
45
+
46
+ # Generate model response
47
+ with st.spinner("Eunoia is listening..."):
48
+ response = llm(prompt, max_tokens=200, stop=["User:", "Bot:"])
49
+ reply = response["choices"][0]["text"].strip()
50
+
51
+ # Display bot reply
52
+ st.chat_message("assistant").markdown(reply)
53
+ st.session_state.messages.append({"role": "assistant", "content": reply})
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ transformers
2
+ torch
3
+ streamlit
4
+ llama-cpp-python
5
+ huggingface_hub