Spaces:
Runtime error
Runtime error
Deepak Yadav
commited on
Commit
Β·
7d988b6
1
Parent(s):
a2f8e12
updated new version deepseek-r1
Browse files- Dockerfile +1 -1
- app.py +9 -0
- doc.txt +0 -14
- install_ollama.sh +32 -0
- services/llm.py +1 -1
Dockerfile
CHANGED
|
@@ -21,4 +21,4 @@ COPY . .
|
|
| 21 |
EXPOSE 11434 8501
|
| 22 |
|
| 23 |
# Start both Ollama and Streamlit
|
| 24 |
-
# CMD ["bash", "-c", "
|
|
|
|
| 21 |
EXPOSE 11434 8501
|
| 22 |
|
| 23 |
# Start both Ollama and Streamlit
|
| 24 |
+
# CMD ["bash", "-c", "streamlit run app.py --server.port 8501 --server.enableCORS false --server.enableXsrfProtection false"]
|
app.py
CHANGED
|
@@ -5,6 +5,15 @@ from services.llm import initialize_llm, initialize_embeddings
|
|
| 5 |
from services.vector_store import create_vector_store, retrive_vector_store, generate_prompt
|
| 6 |
from services.pdf_processing import load_and_split_pdf
|
| 7 |
from utils.helpers import extract_thoughts, response_generator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Custom CSS for chat styling
|
| 10 |
CHAT_CSS = """
|
|
|
|
| 5 |
from services.vector_store import create_vector_store, retrive_vector_store, generate_prompt
|
| 6 |
from services.pdf_processing import load_and_split_pdf
|
| 7 |
from utils.helpers import extract_thoughts, response_generator
|
| 8 |
+
import subprocess
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
print("π Checking and starting Ollama...")
|
| 12 |
+
subprocess.run(["bash", "install_ollama.sh"], check=True)
|
| 13 |
+
print("β
Ollama is running!")
|
| 14 |
+
except subprocess.CalledProcessError as e:
|
| 15 |
+
print(f"β Error: {e}")
|
| 16 |
+
|
| 17 |
|
| 18 |
# Custom CSS for chat styling
|
| 19 |
CHAT_CSS = """
|
doc.txt
DELETED
|
@@ -1,14 +0,0 @@
|
|
| 1 |
-
rag_chatbot/
|
| 2 |
-
βββ app.py # Main Streamlit app
|
| 3 |
-
βββ components/
|
| 4 |
-
β βββ sidebar.py # Sidebar UI (model selection, upload, user info)
|
| 5 |
-
β βββ chat_ui.py # Chat UI styling and history
|
| 6 |
-
βββ services/
|
| 7 |
-
β βββ pdf_processing.py # PDF loading and text splitting
|
| 8 |
-
β βββ vector_store.py # Vector database (FAISS) setup
|
| 9 |
-
β βββ llm.py # Model initialization and QA chain
|
| 10 |
-
βββ utils/
|
| 11 |
-
β βββ helpers.py # Helper functions (e.g., get_file_size)
|
| 12 |
-
βββ docs/ # Folder for storing uploaded PDFs (created dynamically)
|
| 13 |
-
βββ requirements.txt # Dependencies
|
| 14 |
-
βββ README.md # Project documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
install_ollama.sh
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Function to check if Ollama is installed
|
| 4 |
+
is_ollama_installed() {
|
| 5 |
+
command -v ollama >/dev/null 2>&1
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
# Install Ollama only if not already installed
|
| 9 |
+
if is_ollama_installed; then
|
| 10 |
+
echo "β
Ollama is already installed. Skipping installation..."
|
| 11 |
+
else
|
| 12 |
+
echo "π Installing Ollama..."
|
| 13 |
+
sudo apt-get update && sudo apt-get install -y curl
|
| 14 |
+
curl -fsSL https://ollama.com/install.sh | sh
|
| 15 |
+
echo "β
Ollama installation completed!"
|
| 16 |
+
fi
|
| 17 |
+
|
| 18 |
+
# Start Ollama
|
| 19 |
+
echo "π Starting Ollama..."
|
| 20 |
+
ollama serve &
|
| 21 |
+
sleep 5
|
| 22 |
+
|
| 23 |
+
# Pull the model if not already present
|
| 24 |
+
if ollama list | grep -q "deepseek-r1:1.5b"; then
|
| 25 |
+
echo "β
Model 'deepseek-r1:1.5b' is already available."
|
| 26 |
+
else
|
| 27 |
+
echo "π Pulling model 'deepseek-r1:1.5b'..."
|
| 28 |
+
ollama pull deepseek-r1:1.5b
|
| 29 |
+
echo "β
Model pulled successfully!"
|
| 30 |
+
fi
|
| 31 |
+
|
| 32 |
+
echo "π Ollama is running!"
|
services/llm.py
CHANGED
|
@@ -8,7 +8,7 @@ def initialize_llm(model_name, temperature, top_p, max_tokens):
|
|
| 8 |
# Configure the LLM with additional parameters
|
| 9 |
llm = OllamaLLM(
|
| 10 |
model=model_name,
|
| 11 |
-
base_url="https://deepak7376-ollama-server.hf.space",
|
| 12 |
temperature=temperature, # Controls randomness (0 = deterministic, 1 = max randomness)
|
| 13 |
max_tokens=max_tokens, # Limit the number of tokens in the output
|
| 14 |
top_p=top_p # Nucleus sampling for controlling diversity
|
|
|
|
| 8 |
# Configure the LLM with additional parameters
|
| 9 |
llm = OllamaLLM(
|
| 10 |
model=model_name,
|
| 11 |
+
# base_url="https://deepak7376-ollama-server.hf.space",
|
| 12 |
temperature=temperature, # Controls randomness (0 = deterministic, 1 = max randomness)
|
| 13 |
max_tokens=max_tokens, # Limit the number of tokens in the output
|
| 14 |
top_p=top_p # Nucleus sampling for controlling diversity
|