-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from silvanmelchior/dev
Dev
- Loading branch information
Showing
50 changed files
with
279 additions
and
134 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
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 +1 @@ | ||
2.0.2 | ||
2.1.0 |
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,6 +1,5 @@ | ||
#!/bin/bash | ||
|
||
/opt/app/start_interpreter.sh & | ||
/opt/app/start_llm.sh & | ||
/opt/app/start_services.sh & | ||
|
||
nginx -g "daemon off;" |
This file was deleted.
Oops, something went wrong.
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
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,22 @@ | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
from services.auth import auth_router, welcome_lifespan | ||
from services.interpreter import interpreter_router | ||
from services.llm.service import llm_router | ||
from services.utils import get_env_var | ||
|
||
|
||
app = FastAPI(lifespan=welcome_lifespan) | ||
if get_env_var("ENABLE_CORS", "FALSE") == "TRUE": | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["*"], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
app.include_router(auth_router, prefix="/api/auth") | ||
app.include_router(interpreter_router, prefix="/api/interpreter") | ||
app.include_router(llm_router, prefix="/api/llm") |
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
Empty file.
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,4 @@ | ||
from .token import AUTH_TOKEN | ||
from .service import auth_router | ||
from .websocket import verify_websocket, ALLOWED_HOSTS | ||
from .welcome import welcome_lifespan |
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,17 @@ | ||
from fastapi import APIRouter, HTTPException | ||
from pydantic import BaseModel | ||
|
||
from .token import AUTH_TOKEN | ||
|
||
auth_router = APIRouter() | ||
|
||
|
||
class TokenRequest(BaseModel): | ||
token: str | ||
|
||
|
||
@auth_router.post("/verify") | ||
def verify(request: TokenRequest): | ||
if request.token == AUTH_TOKEN: | ||
return {"status": "success"} | ||
raise HTTPException(status_code=401, detail="Invalid token") |
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,5 @@ | ||
import secrets | ||
|
||
from services.utils import get_env_var | ||
|
||
AUTH_TOKEN = get_env_var("AUTH_TOKEN", secrets.token_urlsafe(32)) |
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,26 @@ | ||
import logging | ||
|
||
from fastapi import WebSocket | ||
|
||
from services.auth import AUTH_TOKEN | ||
from services.utils.env_var import get_env_var | ||
|
||
ALLOWED_HOSTS = get_env_var("ALLOWED_HOSTS").split(" ") | ||
|
||
|
||
def _verify_origin(origin: str) -> bool: | ||
origin_raw = origin.replace("http://", "").replace("https://", "") | ||
return origin_raw in ALLOWED_HOSTS | ||
|
||
|
||
async def verify_websocket(websocket: WebSocket): | ||
if not _verify_origin(websocket.headers["origin"]): | ||
logging.warning("Websocket with invalid origin") | ||
return False | ||
|
||
token = await websocket.receive_text() | ||
if token != AUTH_TOKEN: | ||
logging.warning("Websocket with invalid token") | ||
return False | ||
|
||
return True |
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,20 @@ | ||
from contextlib import asynccontextmanager | ||
|
||
from fastapi import FastAPI | ||
|
||
from .websocket import ALLOWED_HOSTS | ||
from .token import AUTH_TOKEN | ||
|
||
|
||
@asynccontextmanager | ||
async def welcome_lifespan(app: FastAPI): | ||
print("***") | ||
print("Welcome to Incognito Pilot") | ||
if len(ALLOWED_HOSTS) == 1: | ||
print("To start, open the following URL:") | ||
else: | ||
print("To start, open one of the the following URLs:") | ||
for host in ALLOWED_HOSTS: | ||
print(f" http://{host}#token={AUTH_TOKEN}") | ||
print("***") | ||
yield |
1 change: 1 addition & 0 deletions
1
services/interpreter/__init__.py → services/services/interpreter/__init__.py
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 +1,2 @@ | ||
from .ipython_interpreter import IPythonInterpreter | ||
from .service import interpreter_router |
File renamed without changes.
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,3 +1,4 @@ | ||
from .base import BaseLLM, LLMException | ||
from .types import Message, Response | ||
from .selector import get_llm | ||
from .service import llm_router |
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
services/llm/gpt/gpt_azure.py → services/services/llm/gpt/gpt_azure.py
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,6 +1,6 @@ | ||
import openai | ||
|
||
from utils import get_env_var | ||
from services.utils import get_env_var | ||
from .gpt import GPT | ||
|
||
|
||
|
2 changes: 1 addition & 1 deletion
2
services/llm/gpt/gpt_openai.py → services/services/llm/gpt/gpt_openai.py
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,6 +1,6 @@ | ||
import openai | ||
|
||
from utils import get_env_var | ||
from services.utils import get_env_var | ||
from .gpt import GPT | ||
|
||
|
||
|
2 changes: 1 addition & 1 deletion
2
services/llm/gpt/parsing.py → services/services/llm/gpt/parsing.py
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
File renamed without changes.
File renamed without changes.
9 changes: 4 additions & 5 deletions
9
services/llm/llama/llama_replicate.py → ...ces/services/llm/llama/llama_replicate.py
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
Oops, something went wrong.