Skip to content

Commit

Permalink
Merge pull request #109 from GSA-TTS/track-costs
Browse files Browse the repository at this point in the history
Track costs
  • Loading branch information
jimmoffet authored Nov 7, 2024
2 parents 194b94f + 1fcdaa9 commit 0efd11d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 39 deletions.
11 changes: 0 additions & 11 deletions backend/apps/socket/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
from utils.utils import decode_token

sio = socketio.AsyncServer(cors_allowed_origins=[], async_mode="asgi")

# ENABLE_WEBSOCKET_SUPPORT = False

# sio = socketio.AsyncServer(
# cors_allowed_origins=[],
# async_mode="asgi",
# transports=(["polling", "websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]),
# allow_upgrades=ENABLE_WEBSOCKET_SUPPORT,
# always_connect=True,
# )

app = socketio.ASGIApp(sio, socketio_path="/ws/socket.io")

# Dictionary to maintain the user pool
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/webui/routers/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def delete_doc_by_name(name: str, user=Depends(get_current_user)):
log.info(f"Deleting document {name}")
result = Documents.delete_doc_by_name(name)

# NOTE: storing the vectors less than creating them, let's skip while in beta
# NOTE: storing the vectors costs less than creating them, let's skip while in beta
# success = VECTOR_CLIENT.delete(collection_name)

return result
21 changes: 2 additions & 19 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
import pkgutil
import chromadb

# from chromadb import Settings
# from redis.asyncio import Redis

# from base64 import b64encode
from bs4 import BeautifulSoup
from typing import TypeVar, Generic # , Union
from typing import TypeVar, Generic
from pydantic import BaseModel
from typing import Optional

Expand Down Expand Up @@ -794,21 +790,8 @@ class BannerModel(BaseModel):
os.environ.get("RAG_EMBEDDING_ENGINE", "openai"),
)

# Redis connection settings
# REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
# REDIS_PORT = int(os.environ.get("REDIS_PORT", "6379"))
# REDIS_PASSWORD = os.environ.get("REDIS_PASSWORD", "")
# REDIS_URL = f"redis://localhost:{REDIS_PORT}"
# REDIS_ENABLED = True
# REDIS_SSL = False
# REDIS_SSL_CERT_REQS = None
# REDIS_CONFIG = dict(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWORD)
# REDIS_DB = int(os.environ.get("REDIS_DB", "0"))
# REDIS_INDEX_NAME = os.environ.get("REDIS_INDEX_NAME", "document-index")
# REDIS_PREFIX = os.environ.get("REDIS_PREFIX", "doc")
# REDIS_VECTOR_DIM = 1536 if RAG_EMBEDDING_ENGINE == "openai" else 384

VECTOR_STORE = os.environ.get("VECTOR_STORE", "postgres")
# TODO: rip out chroma
CHROMA_DATA_PATH = f"{DATA_DIR}/vector_db"
CHROMA_TENANT = os.environ.get("CHROMA_TENANT", chromadb.DEFAULT_TENANT)
CHROMA_DATABASE = os.environ.get("CHROMA_DATABASE", chromadb.DEFAULT_DATABASE)
Expand Down
8 changes: 1 addition & 7 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
VECTOR_CLIENT,
REDIS_VL_SCHEMA,
AppConfig,
# initialize_vector_client,
)
from constants import ERROR_MESSAGES

Expand Down Expand Up @@ -373,12 +372,7 @@ async def dispatch(self, request: Request, call_next):
# If docs field is present, generate RAG completions
if "docs" in data:
data = {**data}
log.error(
f"docs: {data}\n"
# + f"len messages: {len(data['messages'])}\n"
# + f"{rag_app.state.EMBEDDING_FUNCTION}\n"
# + f"{rag_app.state.config.ENABLE_RAG_HYBRID_SEARCH}"
)
log.error(f"docs: {data}\n")
try:
log.error("About to call get_rag_context...")
rag_context, citations = await get_rag_context(
Expand Down
2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ requests==2.32.2
aiohttp==3.9.5
peewee==3.17.5
peewee-migrate==1.12.2
psycopg==3.2.3
psycopg2-binary==2.9.9
pgvector==0.2.5
PyMySQL==1.1.1
bcrypt==4.1.3

Expand Down
1 change: 0 additions & 1 deletion src/lib/apis/rag/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export const uploadDocToVectorDB = async (token: string, collection_name: string
const data = new FormData();
data.append('file', file);
data.append('collection_name', collection_name);
console.log('collection_name', collection_name);

let error = null;

Expand Down

0 comments on commit 0efd11d

Please sign in to comment.