mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
started re-working python code
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
.venv
|
||||
*.pyc
|
||||
*.swp
|
||||
*.egg-info
|
||||
__pycache__
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
|
||||
|
||||
COPY ./requirements.txt /app/requirements.txt
|
||||
|
||||
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
||||
|
||||
ENV PORT 8080
|
||||
|
||||
COPY ./app /app
|
||||
@@ -3,7 +3,7 @@ from logging.config import fileConfig
|
||||
|
||||
import sqlmodel
|
||||
from alembic import context
|
||||
from oasst import models # noqa: F401
|
||||
from oasst_backend import models # noqa: F401
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
@@ -1,2 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
__all__ = []
|
||||
@@ -5,8 +5,8 @@ import alembic.command
|
||||
import alembic.config
|
||||
import fastapi
|
||||
from loguru import logger
|
||||
from oasst.api.v1.api import api_router
|
||||
from oasst.config import settings
|
||||
from oasst_backend.api.v1.api import api_router
|
||||
from oasst_backend.config import settings
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
app = fastapi.FastAPI(title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json")
|
||||
@@ -6,9 +6,9 @@ from uuid import UUID
|
||||
from fastapi import HTTPException, Security
|
||||
from fastapi.security.api_key import APIKey, APIKeyHeader, APIKeyQuery
|
||||
from loguru import logger
|
||||
from oasst.config import settings
|
||||
from oasst.database import engine
|
||||
from oasst.models import ApiClient
|
||||
from oasst_backend.config import settings
|
||||
from oasst_backend.database import engine
|
||||
from oasst_backend.models import ApiClient
|
||||
from sqlmodel import Session
|
||||
from starlette.status import HTTP_403_FORBIDDEN
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from fastapi import APIRouter
|
||||
from oasst.api.v1 import tasks
|
||||
from oasst_backend.api.v1 import tasks
|
||||
|
||||
api_router = APIRouter()
|
||||
api_router.include_router(tasks.router, prefix="/tasks", tags=["tasks"])
|
||||
@@ -6,10 +6,10 @@ from uuid import UUID
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from fastapi.security.api_key import APIKey
|
||||
from loguru import logger
|
||||
from oasst.api import deps
|
||||
from oasst.models.db_payload import TaskPayload
|
||||
from oasst.prompt_repository import PromptRepository
|
||||
from oasst.schemas import protocol as protocol_schema
|
||||
from oasst_backend.api import deps
|
||||
from oasst_backend.models.db_payload import TaskPayload
|
||||
from oasst_backend.prompt_repository import PromptRepository
|
||||
from oasst_shared.schemas import protocol as protocol_schema
|
||||
from sqlmodel import Session
|
||||
from starlette.status import HTTP_400_BAD_REQUEST
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from oasst.config import settings
|
||||
from oasst_backend.config import settings
|
||||
from sqlmodel import create_engine
|
||||
|
||||
if settings.DATABASE_URI is None:
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Literal
|
||||
|
||||
from oasst.models.payload_column_type import payload_type
|
||||
from oasst.schemas import protocol as protocol_schema
|
||||
from oasst_backend.models.payload_column_type import payload_type
|
||||
from oasst_shared.schemas import protocol as protocol_schema
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ from datetime import datetime
|
||||
from typing import Optional
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
import oasst.models.db_payload as db_payload
|
||||
import oasst_backend.models.db_payload as db_payload
|
||||
from loguru import logger
|
||||
from oasst.models import ApiClient, Person, Post, PostReaction, WorkPackage
|
||||
from oasst.models.payload_column_type import PayloadContainer
|
||||
from oasst.schemas import protocol as protocol_schema
|
||||
from oasst_backend.models import ApiClient, Person, Post, PostReaction, WorkPackage
|
||||
from oasst_backend.models.payload_column_type import PayloadContainer
|
||||
from oasst_shared.schemas import protocol as protocol_schema
|
||||
from sqlmodel import Session
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os
|
||||
|
||||
def _read_reqs(relpath):
|
||||
fullpath = os.path.join(os.path.dirname(__file__), relpath)
|
||||
with open(fullpath) as f:
|
||||
return [s.strip() for s in f.readlines() if (s.strip() and not s.startswith("#"))]
|
||||
|
||||
REQUIREMENTS = _read_reqs("requirements.txt")
|
||||
|
||||
setup(
|
||||
name="open-assistant",
|
||||
packages=find_packages(),
|
||||
version="0.0.1",
|
||||
license="Apache 2.0",
|
||||
description="A Discord Bot for collecting and ranking prompts to train an Open Assistant",
|
||||
keywords=["machine learning", "natural language processing", "discord"],
|
||||
install_requires=REQUIREMENTS,
|
||||
classifiers=[
|
||||
"Development Status :: Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||
"License :: OSI Approved :: Apache License",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
|
||||
|
||||
COPY ./backend/requirements.txt /app/requirements.txt
|
||||
|
||||
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
||||
|
||||
ENV PORT 8080
|
||||
|
||||
COPY ./oasst-shared /oasst-shared
|
||||
RUN pip install -e /oasst-shared
|
||||
|
||||
COPY ./backend/alembic /app/alembic
|
||||
COPY ./backend/alembic.ini /app/alembic.ini
|
||||
COPY ./backend/main.py /app/main.py
|
||||
COPY ./backend/oasst_backend /app/oasst_backend
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM python:3.10-slim-bullseye
|
||||
RUN mkdir /app
|
||||
ADD requirements.txt /app/requirements.txt
|
||||
WORKDIR /app
|
||||
COPY ./discord-bot/requirements.txt /requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
COPY ./discord-bot /app
|
||||
CMD ["python", "bot.py"]
|
||||
@@ -0,0 +1,3 @@
|
||||
# Shared Python code for Open Assisstant
|
||||
|
||||
Run `pip install -e .` to install the package in editable mode.
|
||||
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# setup.py for the shared python modules
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
from setuptools import find_namespace_packages
|
||||
|
||||
setup(
|
||||
name="oasst-shared",
|
||||
version="1.0",
|
||||
packages=find_namespace_packages(),
|
||||
author="OASST Team",
|
||||
install_requires=[
|
||||
"pydantic==1.9.1",
|
||||
],
|
||||
)
|
||||
@@ -2,7 +2,7 @@
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
||||
|
||||
# switch to backend directory
|
||||
pushd "$parent_path/../../backend/app"
|
||||
pushd "$parent_path/../../backend"
|
||||
|
||||
export ALLOW_ANY_API_KEY=True
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ services:
|
||||
file: ../backend-development/docker-compose.yaml
|
||||
service: adminer
|
||||
backend:
|
||||
build: ../../backend/.
|
||||
build:
|
||||
dockerfile: docker/Dockerfile.backend
|
||||
context: ../..
|
||||
image: oasst-backend
|
||||
environment:
|
||||
- POSTGRES_HOST=db
|
||||
|
||||
Reference in New Issue
Block a user