nikos99n commited on
Commit
7a1339e
·
verified ·
1 Parent(s): 4091c84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -45
app.py CHANGED
@@ -13,51 +13,8 @@ from openai import OpenAI
13
 
14
  st.set_page_config(layout="wide")
15
 
16
-
17
- my_initial_rag_text = f"""This is a RAG (Retrieval-Augmented Generation) chatbot application built with Streamlit that combines document context with LLM responses. Here's a breakdown of its main components:
18
-
19
- 1. Initial Setup:
20
- - Uses Streamlit for the web interface
21
- - Employs SentenceTransformer for generating embeddings
22
- - Uses HuggingFace's InferenceClient for LLM interaction
23
-
24
- 2. State Management:
25
- - Maintains several session state variables for:
26
- - RAG text (the context document)
27
- - LLM model selection
28
- - Chat message history
29
- - Embeddings and sentences
30
- - HuggingFace client
31
-
32
- 3. Interface Layout:
33
- - Split into two columns (1:2 ratio):
34
- - Left column: Model selection dropdown and RAG text input
35
- - Right column: Chat interface and message history
36
-
37
- 4. Core Functionality:
38
- - RAG Implementation:
39
- - Splits the context document into sentences
40
- - When a user asks a question, it:
41
- - Converts the question into embeddings
42
- - Finds the 3 most relevant sentences from the context
43
- - Adds these relevant pieces as context to the prompt
44
-
45
- - Chat Interface:
46
- - Streams responses from the LLM
47
- - Maintains a chat history
48
- - Shows message history and augmented prompts
49
- - Uses different avatars for user and AI messages
50
-
51
- 5. Model Options:
52
- - Offers three LLM choices:
53
- - Mistral-7B-Instruct-v0.3 (default)
54
- - Qwen2.5-72B-Instruct
55
- - Zephyr-7b-beta
56
-
57
- The application essentially creates an intelligent chatbot that can answer questions while taking into account the context provided in the RAG text, making it particularly useful for domain-specific Q&A scenarios.
58
-
59
- A disclaimer at the bottom reminds users about potential LLM inaccuracies and the need for verification of responses.
60
- """
61
 
62
  # Check if the LLM model is not already in the session state
63
  if "my_llm_model" not in st.session_state:
 
13
 
14
  st.set_page_config(layout="wide")
15
 
16
+ with open("/app/labeled_text_small.txt", "r", encoding="utf-8") as f:
17
+ my_initial_rag_text = f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  # Check if the LLM model is not already in the session state
20
  if "my_llm_model" not in st.session_state: