Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
import json
|
3 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
-
import torch
|
5 |
-
import time
|
6 |
|
7 |
# Page configuration
|
8 |
st.set_page_config(
|
@@ -54,23 +51,6 @@ def get_context(query: str, knowledge_base: dict) -> str:
|
|
54 |
|
55 |
return "\n".join(contexts)
|
56 |
|
57 |
-
def initialize_model():
|
58 |
-
"""Initialize the model and tokenizer"""
|
59 |
-
try:
|
60 |
-
# For testing, use a smaller model
|
61 |
-
model_name = "meta-llama/Llama-2-7b-chat-hf" # You'll need to adjust this
|
62 |
-
|
63 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
64 |
-
model = AutoModelForCausalLM.from_pretrained(
|
65 |
-
model_name,
|
66 |
-
torch_dtype=torch.float16,
|
67 |
-
device_map="auto"
|
68 |
-
)
|
69 |
-
return tokenizer, model
|
70 |
-
except Exception as e:
|
71 |
-
st.error(f"Error initializing model: {str(e)}")
|
72 |
-
return None, None
|
73 |
-
|
74 |
def main():
|
75 |
st.title("Portfolio Chatbot Testing Interface")
|
76 |
st.write("Test the chatbot's responses and interaction patterns")
|
@@ -96,8 +76,8 @@ def main():
|
|
96 |
# Get context for the query
|
97 |
context = get_context(prompt, knowledge_base)
|
98 |
|
99 |
-
# For
|
100 |
-
response = f"
|
101 |
|
102 |
# Display assistant response in chat message container
|
103 |
with st.chat_message("assistant"):
|
|
|
1 |
import streamlit as st
|
2 |
import json
|
|
|
|
|
|
|
3 |
|
4 |
# Page configuration
|
5 |
st.set_page_config(
|
|
|
51 |
|
52 |
return "\n".join(contexts)
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
def main():
|
55 |
st.title("Portfolio Chatbot Testing Interface")
|
56 |
st.write("Test the chatbot's responses and interaction patterns")
|
|
|
76 |
# Get context for the query
|
77 |
context = get_context(prompt, knowledge_base)
|
78 |
|
79 |
+
# For testing, just echo back the context
|
80 |
+
response = f"TEST RESPONSE: Here's what I know about this:\n\n{context}"
|
81 |
|
82 |
# Display assistant response in chat message container
|
83 |
with st.chat_message("assistant"):
|