-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
159 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
start: | ||
docker-compose -f ./docker-compose.yaml down -v; \ | ||
docker-compose -f ./docker-compose.yaml rm -fsv; \ | ||
docker-compose -f ./docker-compose.yaml up --remove-orphans; | ||
|
||
start-gpu: | ||
docker-compose -f ./docker-compose-gpu.yaml down -v; \ | ||
docker-compose -f ./docker-compose-gpu.yaml rm -fsv; \ | ||
docker-compose -f ./docker-compose-gpu.yaml up --remove-orphans; | ||
|
||
stop: | ||
docker-compose -f ./docker-compose.yaml down -v; \ | ||
docker-compose -f ./docker-compose.yaml rm -fsv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
services: | ||
|
||
ollama: | ||
image: ollama/ollama:latest | ||
ports: | ||
- 11434:11434 | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [ gpu ] | ||
volumes: | ||
- ~/ollama:/root/.ollama | ||
networks: | ||
- net | ||
|
||
app: | ||
image: amithkoujalgi/pdf-bot:1.0.0 | ||
ports: | ||
- 8501:8501 | ||
environment: | ||
- OLLAMA_API_BASE_URL=http://ollama:11434 | ||
- MODEL=llama2 | ||
networks: | ||
- net | ||
|
||
networks: | ||
net: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os | ||
|
||
|
||
class Config: | ||
MODEL = os.environ.get('MODEL', "llama2") | ||
EMBEDDING_MODEL_NAME = os.environ.get('EMBEDDING_MODEL_NAME', "all-MiniLM-L6-v2") | ||
OLLAMA_API_BASE_URL = os.environ.get('OLLAMA_API_BASE_URL', "http://localhost:11434") | ||
HUGGING_FACE_EMBEDDINGS_DEVICE_TYPE = os.environ.get('HUGGING_FACE_EMBEDDINGS_DEVICE_TYPE', | ||
"cpu") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import json | ||
import os | ||
|
||
import requests | ||
|
||
model_name = os.environ.get('MODEL', "orca-mini") | ||
ollama_api_base_url = os.environ.get('OLLAMA_API_BASE_URL', "http://localhost:11434") | ||
from config import Config | ||
|
||
model_name = Config.MODEL | ||
ollama_api_base_url = Config.OLLAMA_API_BASE_URL | ||
print(f"Using model: {model_name}") | ||
print(f"Using Ollama base URL: {ollama_api_base_url}") | ||
|
||
|
||
def pull_model(model_name_): | ||
print(f"pulling model '{model_name_}'...") | ||
print(f"Pulling model '{model_name_}'...") | ||
url = f"{ollama_api_base_url}/api/pull" | ||
data = json.dumps(dict(name=model_name_)) | ||
print(data) | ||
headers = {'Content-Type': 'application/json'} | ||
_response = requests.post(url, data=data, headers=headers) | ||
print(_response.text) | ||
|
||
# Use stream=True to handle streaming response | ||
with requests.post(url, data=data, headers=headers, stream=True) as response: | ||
if response.status_code == 200: | ||
# Process the response content in chunks | ||
for chunk in response.iter_content(chunk_size=1024): | ||
if chunk: | ||
print(chunk.decode('utf-8'), end='') # Replace 'utf-8' with the appropriate encoding | ||
else: | ||
print(f"Error: {response.status_code} - {response.text}") | ||
|
||
|
||
pull_model(model_name_=model_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
langchain | ||
streamlit | ||
replicate | ||
pymupdf | ||
huggingface-hub | ||
faiss-cpu | ||
sentence-transformers | ||
requests | ||
langchain==0.0.334 | ||
streamlit==1.28.1 | ||
replicate==0.18.1 | ||
pymupdf==1.23.6 | ||
huggingface-hub==0.17.3 | ||
faiss-cpu==1.7.4 | ||
sentence-transformers==2.2.2 | ||
requests==2.31.0 |