Skip to content

Commit

Permalink
Merge pull request #72 from openchatai/feat/nginx-routing
Browse files Browse the repository at this point in the history
updating nginx config file
  • Loading branch information
gharbat authored Sep 17, 2023
2 parents fe1bd47 + fd318a1 commit 455fb7c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion llm-server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ OPENAI_API_TYPE=openai
OPENAI_API_KEY=
PINECONE_API_KEY=
PINECONE_ENV=
MONGODB_URL=mongodb://mongodb:27017/opencopilot
# MONGODB_URL=mongodb://dbuser:dbpass@mongodb:27017/opencopilot?authSource=admin&retryWrites=true&w=majority
MONGODB_URL=mongodb://dbuser:dbpass@localhost:27017/opencopilot?authSource=admin&retryWrites=true&w=majority

QDRANT_URL=http://qdrant:6333
STORE=QDRANT
Expand Down
4 changes: 0 additions & 4 deletions llm-server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
from prompts.base import api_base_prompt, non_api_base_prompt

app = Flask(__name__)
app.config["MONGO_URI"] = os.getenv(
"MONGODB_URL", "mongodb://localhost:27017/opencopilot"
)
mongo = PyMongo(app)

app.register_blueprint(workflow, url_prefix="/workflow")

Expand Down
35 changes: 21 additions & 14 deletions llm-server/utils/db.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
# type: ignore
from pymongo import MongoClient
from pymongo.database import Database as PyMongoDatabase
from dotenv import load_dotenv

import os
load_dotenv()

class Database:
_instance: MongoClient = None

def __new__(cls, app=None):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance.client = MongoClient(
"localhost", 27017, username="dbuser", password="dbpass"
)
cls._instance.db = cls._instance.client.opencopilot
return cls._instance

@staticmethod
def get_db() -> PyMongoDatabase:
return Database._instance.db # Access _instance directly from the class

_instance: MongoClient = None

def __new__(cls, app=None):

if cls._instance is None:
cls._instance = super().__new__(cls)

mongo_url = os.environ.get("MONGODB_URL")
cls._instance.client = MongoClient(mongo_url)

cls._instance.db = cls._instance.client.opencopilot

return cls._instance

@staticmethod
def get_db() -> PyMongoDatabase:
return Database._instance.db
6 changes: 5 additions & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ http {

server {
listen 80;
location /backend/flows/ {
rewrite /backend/flows/(.*) /workflow/$1 break;
proxy_pass http://llm-server:8002/;
}

location /backend/ {
proxy_pass http://backend:5000/;
Expand All @@ -24,4 +28,4 @@ http {
proxy_pass http://dashboard:8000/;
}
}
}
}

0 comments on commit 455fb7c

Please sign in to comment.