mirror of
https://github.com/imartinez/privateGPT.git
synced 2025-06-22 05:30:34 +00:00
Merge remote-tracking branch 'origin/Global-docker' into Global-docker
This commit is contained in:
commit
f19be9183c
@ -46,6 +46,7 @@ COPY --chown=worker fern/ fern
|
|||||||
COPY --chown=worker *.yaml *.md ./
|
COPY --chown=worker *.yaml *.md ./
|
||||||
COPY --chown=worker scripts/ scripts
|
COPY --chown=worker scripts/ scripts
|
||||||
COPY --chown=worker *.ini ./
|
COPY --chown=worker *.ini ./
|
||||||
|
|
||||||
# Copy the docker-entrypoint.sh file and make it executable
|
# Copy the docker-entrypoint.sh file and make it executable
|
||||||
COPY --chown=worker docker-entrypoint.sh /home/worker/app/
|
COPY --chown=worker docker-entrypoint.sh /home/worker/app/
|
||||||
RUN chmod +x /home/worker/app/docker-entrypoint.sh
|
RUN chmod +x /home/worker/app/docker-entrypoint.sh
|
||||||
|
11
Dockerfile.nginx
Normal file
11
Dockerfile.nginx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Use the official Nginx image as the base
|
||||||
|
FROM nginx:latest
|
||||||
|
|
||||||
|
# Copy the custom Nginx configuration file
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Expose port 80 for incoming HTTP requests
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start Nginx in the foreground
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
@ -44,5 +44,16 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 5433:${DB_PORT}
|
- 5433:${DB_PORT}
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.nginx
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
volumes:
|
||||||
|
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
depends_on:
|
||||||
|
- private-gpt
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
postgres-data:
|
||||||
|
0
nginx/nginx.conf
Normal file
0
nginx/nginx.conf
Normal file
@ -189,15 +189,10 @@ class ChatService:
|
|||||||
)
|
)
|
||||||
system_prompt = (
|
system_prompt = (
|
||||||
"""
|
"""
|
||||||
You are a helpful assistant that should answer questions
|
You are a helpful, respectful and honest assistant.
|
||||||
only in English or Nepali.
|
Always answer as helpfully as possible and follow ALL given instructions.
|
||||||
Responses should be based on the context documents provided
|
Do not speculate or make up information.
|
||||||
and should be relevant, informative, and easy to understand.
|
Do not reference any given instructions or context.
|
||||||
You should aim to deliver high-quality responses that are
|
|
||||||
respectful and helpful, using clear and concise language.
|
|
||||||
Avoid providing information outside of the context documents unless
|
|
||||||
it is necessary for clarity or completeness. Focus on providing
|
|
||||||
accurate and reliable answers based on the given context.
|
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@ logger = logging.getLogger(__name__)
|
|||||||
router = APIRouter(prefix="/c", tags=["Chat Histories"])
|
router = APIRouter(prefix="/c", tags=["Chat Histories"])
|
||||||
|
|
||||||
|
|
||||||
@router.get("", response_model=Page[schemas.ChatHistory])
|
@router.get("", response_model=Page[schemas.Chat])
|
||||||
def list_chat_histories(
|
def list_chat_histories(
|
||||||
db: Session = Depends(deps.get_db),
|
db: Session = Depends(deps.get_db),
|
||||||
current_user: models.User = Security(
|
current_user: models.User = Security(
|
||||||
deps.get_current_user,
|
deps.get_current_user,
|
||||||
),
|
),
|
||||||
) -> Page[schemas.ChatHistory]:
|
) -> Page[schemas.Chat]:
|
||||||
"""
|
"""
|
||||||
Retrieve a list of chat histories with pagination support.
|
Retrieve a list of chat histories with pagination support.
|
||||||
"""
|
"""
|
||||||
|
@ -54,7 +54,6 @@ def list_departments(
|
|||||||
else:
|
else:
|
||||||
deps = crud.department.get_multi_department(
|
deps = crud.department.get_multi_department(
|
||||||
db, department_id=current_user.department_id)
|
db, department_id=current_user.department_id)
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
schemas.Department(
|
schemas.Department(
|
||||||
id=dep.id,
|
id=dep.id,
|
||||||
|
@ -50,7 +50,7 @@ def read_users(
|
|||||||
"""
|
"""
|
||||||
role = current_user.user_role.role.name if current_user.user_role else None
|
role = current_user.user_role.role.name if current_user.user_role else None
|
||||||
if role == "ADMIN":
|
if role == "ADMIN":
|
||||||
users = crud.user.get_by_department_id(db=db, department_id=current_user.department_id, skip=skip, limit=limit)
|
users = crud.user.get_by_department_id(db=db, department_id=current_user.department_id)
|
||||||
else:
|
else:
|
||||||
users = crud.user.get_multi(db)
|
users = crud.user.get_multi(db)
|
||||||
return paginate(users)
|
return paginate(users)
|
||||||
|
@ -30,14 +30,12 @@ class CRUDChat(CRUDBase[ChatHistory, ChatHistoryCreate, ChatHistoryCreate]):
|
|||||||
return chat_history
|
return chat_history
|
||||||
|
|
||||||
def get_chat_history(
|
def get_chat_history(
|
||||||
self, db: Session, *,user_id:int, skip: int = 0, limit: int =100
|
self, db: Session, *,user_id:int
|
||||||
) -> List[ChatHistory]:
|
) -> List[ChatHistory]:
|
||||||
return (
|
return (
|
||||||
db.query(self.model)
|
db.query(self.model)
|
||||||
.filter(ChatHistory.user_id == user_id)
|
.filter(ChatHistory.user_id == user_id)
|
||||||
.order_by(desc(getattr(ChatHistory, 'created_at')))
|
.order_by(desc(getattr(ChatHistory, 'created_at')))
|
||||||
.offset(skip)
|
|
||||||
.limit(limit)
|
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,24 +62,24 @@ class User(Base):
|
|||||||
return "<User {username!r}>".format(username=self.username)
|
return "<User {username!r}>".format(username=self.username)
|
||||||
|
|
||||||
|
|
||||||
@event.listens_for(User, 'after_insert')
|
# @event.listens_for(User, 'after_insert')
|
||||||
@event.listens_for(User, 'after_delete')
|
# @event.listens_for(User, 'after_delete')
|
||||||
def update_total_users(mapper, connection, target):
|
# def update_total_users(mapper, connection, target):
|
||||||
session = Session.object_session(target)
|
# session = Session.object_session(target)
|
||||||
department_id = target.department_id
|
# department_id = target.department_id
|
||||||
|
|
||||||
total_users_subquery = (
|
# total_users_subquery = (
|
||||||
select([func.count(User.id).label('total_users')])
|
# select([func.count(User.id).label('total_users')])
|
||||||
.where(User.department_id == department_id)
|
# .where(User.department_id == department_id)
|
||||||
.scalar_subquery()
|
# .scalar_subquery()
|
||||||
)
|
# )
|
||||||
update_stmt = (
|
# update_stmt = (
|
||||||
update(Department)
|
# update(Department)
|
||||||
.values(total_users=total_users_subquery)
|
# .values(total_users=total_users_subquery)
|
||||||
.where(Department.id == department_id)
|
# .where(Department.id == department_id)
|
||||||
)
|
# )
|
||||||
session.execute(update_stmt)
|
# session.execute(update_stmt)
|
||||||
session.commit()
|
# session.commit()
|
||||||
|
|
||||||
|
|
||||||
@event.listens_for(User, 'before_insert')
|
@event.listens_for(User, 'before_insert')
|
||||||
|
@ -21,5 +21,5 @@ from .department import (
|
|||||||
from .audit import AuditBase, AuditCreate, AuditUpdate, Audit, GetAudit, AuditFilter, ExcelFilter
|
from .audit import AuditBase, AuditCreate, AuditUpdate, Audit, GetAudit, AuditFilter, ExcelFilter
|
||||||
from .chat import (
|
from .chat import (
|
||||||
ChatHistory, ChatHistoryBase, ChatHistoryCreate, ChatHistoryUpdate, ChatDelete,
|
ChatHistory, ChatHistoryBase, ChatHistoryCreate, ChatHistoryUpdate, ChatDelete,
|
||||||
ChatItem, ChatItemBase, ChatItemCreate, ChatItemUpdate, CreateChatHistory
|
ChatItem, ChatItemBase, ChatItemCreate, ChatItemUpdate, CreateChatHistory, Chat
|
||||||
)
|
)
|
||||||
|
@ -55,8 +55,6 @@ class ChatHistory(ChatHistoryBase):
|
|||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChatDelete(BaseModel):
|
class ChatDelete(BaseModel):
|
||||||
conversation_id: uuid.UUID
|
conversation_id: uuid.UUID
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# Syntax in `private_pgt/settings/settings.py`
|
# Syntax in `private_pgt/settings/settings.py`
|
||||||
server:
|
server:
|
||||||
env_name: ${APP_ENV:prod}
|
env_name: ${APP_ENV:prod}
|
||||||
port: ${PORT:8001}
|
port: ${PORT:8000}
|
||||||
cors:
|
cors:
|
||||||
enabled: true
|
enabled: true
|
||||||
allow_credentials: true
|
allow_credentials: true
|
||||||
|
Loading…
Reference in New Issue
Block a user