Skip to content

Commit

Permalink
Superagent v0.0.41
Browse files Browse the repository at this point in the history
  • Loading branch information
mgunnin committed Aug 5, 2023
1 parent 993ed59 commit a74d3d6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 26 deletions.
8 changes: 2 additions & 6 deletions app/api/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from app.lib.auth.prisma import JWTBearer
from app.lib.documents import upsert_document, valid_ingestion_types
from app.lib.models.document import Document
from app.lib.vectorstores.base import VectorStoreBase
from app.lib.prisma import prisma

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -50,12 +51,6 @@ async def create_document(body: Document, token=Depends(JWTBearer())):
to_page=body.to_page,
user_id=token["userId"],
)
else:
logger.error("Invalid ingestion type")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Invalid ingestion type",
)
return {"success": True, "data": document}
except Exception as e:
logger.error("Couldn't create document", exc_info=e)
Expand Down Expand Up @@ -117,6 +112,7 @@ async def delete_document(documentId: str, token=Depends(JWTBearer())):
"""Delete a document"""
try:
prisma.document.delete(where={"id": documentId})
VectorStoreBase().get_database().delete(namespace=documentId)
return {"success": True, "data": None}
except Exception as e:
logger.error("Couldn't delete document with id {documentId}", exc_info=e)
Expand Down
5 changes: 4 additions & 1 deletion app/lib/vectorstores/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
environment=config("PINECONE_ENVIRONMENT"), # next to api key in console
)

pinecone.Index("superagent")
index = pinecone.Index("superagent")


class PineconeVectorstore:
Expand All @@ -23,3 +23,6 @@ def from_existing_index(self, embeddings, namespace):
return Pinecone.from_existing_index(
"superagent", embedding=embeddings, namespace=namespace
)

def delete(self, namespace):
return index.delete(delete_all=True, namespace=namespace)
35 changes: 17 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ transformers = "^4.30.2"
youtube-transcript-api = "^0.6.1"
replicate = "^0.8.3"
python-slugify = "^8.0.1"
langchain = "^0.0.218"
google-cloud-firestore = "^2.11.1"
google-auth = "^2.21.0"
llama-index = "^0.6.38.post1"
Expand All @@ -50,6 +49,7 @@ colorlog = "^6.7.0"
llama-hub = "^0.0.16"
pygithub = "^1.59.0"
gitpython = "^3.1.32"
langchain = "^0.0.252"


[build-system]
Expand Down
26 changes: 26 additions & 0 deletions replit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ pkgs }: {
deps = [
pkgs.nodejs-18_x
pkgs.sudo
pkgs.q
pkgs.python310Full
pkgs.replitPackages.prybar-python310
pkgs.replitPackages.stderred
];
env = {
PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
# Needed for pandas / numpy
pkgs.stdenv.cc.cc.lib
pkgs.zlib
# Needed for pygame
pkgs.glib
# Needed for matplotlib
pkgs.xorg.libX11
];
PYTHONHOME = "${pkgs.python310Full}";
PYTHONBIN = "${pkgs.python310Full}/bin/python3.10";
LANG = "en_US.UTF-8";
STDERREDBIN = "${pkgs.replitPackages.stderred}/bin/stderred";
PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python310}/bin/prybar-python310";
};
}
9 changes: 9 additions & 0 deletions replit.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# Get the currently installed Poetry version
CURRENT_POETRY_VERSION=$(poetry --version | awk '{print $3}')

# Check if Poetry is installed and if the version is lower than 1.5.1
if [[ -z "$CURRENT_POETRY_VERSION" || "$CURRENT_POETRY_VERSION" < "1.5.1" ]]; then
# Install Poetry version 1.5.1
pip install poetry==1.5.1
fi

# Install dependencies using Poetry
poetry install

Expand Down

0 comments on commit a74d3d6

Please sign in to comment.