Skip to content

Commit 526b3b4

Browse files
author
RobuRishabh
committed
Dockerfile_updated
1 parent 71371e9 commit 526b3b4

File tree

5 files changed

+87
-16
lines changed

5 files changed

+87
-16
lines changed

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Use an official Python image as a base
2+
FROM python:3.10
3+
4+
# Set the working directory in the container
5+
WORKDIR /app
6+
7+
# Copy all necessary files
8+
COPY . .
9+
10+
# Install system dependencies
11+
RUN apt-get update && apt-get install -y --no-install-recommends \
12+
build-essential \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Install dependencies
16+
RUN pip install --no-cache-dir -r requirements.txt
17+
18+
# Expose the port Streamlit runs on
19+
EXPOSE 8501
20+
21+
# Set environment variables
22+
# ENV OLLAMA_URL=http://localhost:11434
23+
ENV OLLAMA_URL=http://10.0.0.210:11434
24+
# ENV OLLAMA_URL=http://host.docker.internal:11434
25+
ENV OLLAMA_MODEL=llama2:latest
26+
27+
28+
# Command to run the Streamlit app
29+
CMD ["streamlit", "run", "app.py"]
30+
# CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]

mock_database.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
import os
12
import requests
23

34
def check_ollama_availability():
45
"""Check if the Ollama server is available."""
6+
ollama_url = os.getenv("OLLAMA_URL", "http://localhost:11434")
57
try:
6-
response = requests.get("http://localhost:11434/api/tags", timeout=3)
7-
return response.status_code == 200
8-
except requests.RequestException:
9-
print("⚠️ Ollama server is not available.")
8+
response = requests.get(f"{ollama_url}/api/tags", timeout=3)
9+
if response.status_code == 200:
10+
print(f"🟢 Ollama server is available at {ollama_url}.")
11+
return True
12+
else:
13+
print(f"⚠️ Ollama server returned status {response.status_code} at {ollama_url}.")
14+
return False
15+
except requests.RequestException as e:
16+
print(f"⚠️ Ollama server is not available at {ollama_url}: {str(e)}")
1017
return False
1118

1219

ollama_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def initialize_ollama():
2020
"""Initialize the Ollama LLM model safely."""
2121
try:
22-
ollama_llm = OllamaLLM(model=OLLAMA_MODEL)
22+
ollama_llm = OllamaLLM(model=OLLAMA_MODEL, base_url=OLLAMA_URL)
2323
print(f"🟢 Successfully initialized Ollama LLM with model: {OLLAMA_MODEL}")
2424
return ollama_llm
2525
except Exception as e:

query_handler.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,12 @@
33
import os
44
import re
55
from dotenv import load_dotenv
6-
from mock_database import search_flights # Import the correct function
6+
from mock_database import search_flights, check_ollama_availability
77

88
# Load environment variables
99
load_dotenv()
1010
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", "llama2:latest") # Load model dynamically
1111

12-
def check_ollama_availability():
13-
"""Check if the Ollama server is available before calling it."""
14-
import requests
15-
try:
16-
response = requests.get("http://localhost:11434/api/tags", timeout=3)
17-
return response.status_code == 200
18-
except requests.RequestException:
19-
print("⚠️ Ollama server is not available.")
20-
return False
21-
2212
OLLAMA_AVAILABLE = check_ollama_availability()
2313

2414
def extract_entities_llama2(query):

requirements.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
aiohttp
2+
altair
3+
anyio
4+
attrs
5+
blinker
6+
cachetools
7+
certifi
8+
charset-normalizer
9+
click
10+
colorama
11+
dataclasses-json
12+
exceptiongroup
13+
gitdb
14+
GitPython
15+
h11
16+
httpx
17+
idna
18+
Jinja2
19+
joblib
20+
jsonschema
21+
langchain
22+
langchain-community
23+
langchain-core
24+
langchain-ollama==0.2.3
25+
MarkupSafe
26+
marshmallow
27+
numpy
28+
ollama==0.4.7
29+
pandas
30+
pillow
31+
pydantic
32+
python-dateutil
33+
python-dotenv
34+
PyYAML
35+
requests
36+
scikit-learn
37+
scipy
38+
SQLAlchemy
39+
streamlit
40+
tenacity
41+
tqdm
42+
typing_extensions
43+
urllib3
44+
watchdog

0 commit comments

Comments
 (0)