Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
fixing url issues when running inside container
Browse files Browse the repository at this point in the history
  • Loading branch information
codebanesr committed Sep 16, 2023
1 parent 9399ff6 commit fd318a1
Show file tree
Hide file tree
Showing 4 changed files with 24 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
2 changes: 1 addition & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ http {
listen 80;
location /backend/flows/ {
rewrite /backend/flows/(.*) /workflow/$1 break;
proxy_pass http://llm-server;
proxy_pass http://llm-server:8002/;
}

location /backend/ {
Expand Down

0 comments on commit fd318a1

Please sign in to comment.