Skip to content

Commit

Permalink
Merge pull request #98 from edubotics-ai/dev_branch
Browse files Browse the repository at this point in the history
Dev branch to Main
  • Loading branch information
trgardos authored Aug 27, 2024
2 parents c571e3b + b7d3eda commit d55c537
Show file tree
Hide file tree
Showing 54 changed files with 110 additions and 65 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish to PyPI

on:
push:
branches:
- main
tags:
- "v*"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} # from pypi
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 1 addition & 1 deletion .github/workflows/push_to_hf_space.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: Deploy Production (main) to HuggingFace
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: git push --force https://trgardos:[email protected]/spaces/dl4ds/dl4ds_tutor main:main
run: git push --force https://trgardos:[email protected]/spaces/edubotics/dl4ds_tutor main:main
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{ "name":"Python Debugger: Module store_manager",
"type":"debugpy",
"request":"launch",
"module":"modules.vectorstore.store_manager",
"module":"edubotics_core.vectorstore.store_manager",
"env": {"PYTHONPATH": "${workspaceFolder}/code"},
"cwd": "${workspaceFolder}/code",
"justMyCode": true
Expand All @@ -26,7 +26,7 @@
"name": "Python Debugger: Module data_loader",
"type": "debugpy",
"request": "launch",
"module": "modules.dataloader.data_loader",
"module": "edubotics_core.dataloader.data_loader",
"env": {"PYTHONPATH": "${workspaceFolder}/code"},
"cwd": "${workspaceFolder}/code",
"justMyCode": true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ RUN --mount=type=secret,id=LITERAL_API_KEY_LOGGING,mode=0444,required=true
RUN --mount=type=secret,id=CHAINLIT_AUTH_SECRET,mode=0444,required=true

# Default command to run the application
CMD python -m modules.vectorstore.store_manager --config_file config/config.yml --project_config_file config/project_config.yml && python -m uvicorn app:app --host 0.0.0.0 --port 7860
CMD python -m edubotics_core.vectorstore.store_manager --config_file config/config.yml --project_config_file config/project_config.yml && python -m uvicorn app:app --host 0.0.0.0 --port 7860
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ RUN ls -R /code
EXPOSE 7860

# Default command to run the application
CMD python -m modules.vectorstore.store_manager --config_file config/config.yml --project_config_file config/project_config.yml && python -m uvicorn app:app --host 0.0.0.0 --port 7860
CMD python -m edubotics_core.vectorstore.store_manager --config_file config/config.yml --project_config_file config/project_config.yml && python -m uvicorn app:app --host 0.0.0.0 --port 7860
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ app_port: 7860
---
# DL4DS Tutor 🏃

![Build Status](https://github.com/DL4DS/dl4ds_tutor/actions/workflows/push_to_hf_space.yml/badge.svg)
![License](https://img.shields.io/github/license/DL4DS/dl4ds_tutor)
![GitHub stars](https://img.shields.io/github/stars/DL4DS/dl4ds_tutor)
![Build Status](https://github.com/edubotics-ai/edubot-core/actions/workflows/push_to_hf_space.yml/badge.svg)
![License](https://img.shields.io/github/license/edubotics-ai/edubot-core)
![GitHub stars](https://img.shields.io/github/stars/edubotics-ai/edubot-core)
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)


Expand All @@ -34,7 +34,7 @@ Please visit [setup](https://dl4ds.github.io/dl4ds_tutor/guide/setup/) for more

1. **Clone the Repository**
```bash
git clone https://github.com/DL4DS/dl4ds_tutor
git clone https://github.com/edubotics-ai/edubot-core
```

2. Create your app in the apps folder. (An example is the `apps/ai_tutor` app)
Expand All @@ -50,13 +50,13 @@ Please visit [setup](https://dl4ds.github.io/dl4ds_tutor/guide/setup/) for more
3. **To test Data Loading (Optional)**
```bash
cd apps/your_app
python -m modules.dataloader.data_loader --links "your_pdf_link" --config_file config/config.yml --project_config_file config/project_config.yml
python -m edubotics_core.dataloader.data_loader --links "your_pdf_link" --config_file config/config.yml --project_config_file config/project_config.yml
```

4. **Create the Vector Database**
```bash
cd apps/your_app
python -m modules.vectorstore.store_manager --config_file config/config.yml --project_config_file config/project_config.yml
python -m edubotics_core.vectorstore.store_manager --config_file config/config.yml --project_config_file config/project_config.yml
```

6. **Run the FastAPI App**
Expand Down
2 changes: 1 addition & 1 deletion apps/ai_tutor/.chainlit/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ default_collapse_content = true
cot = "hidden"

# Link to your github repo. This will add a github button in the UI's header.
github = "https://github.com/DL4DS/dl4ds_tutor"
github = "https://github.com/edubotics-ai/edubot-core"

# Specify a CSS file that can be used to customize the user interface.
# The CSS file can be served from the public directory or via an external link.
Expand Down
2 changes: 1 addition & 1 deletion apps/ai_tutor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
reset_tokens_for_user,
check_user_cooldown,
)
from modules.chat_processor.helpers import get_user_details, update_user_info
from edubotics_core.chat_processor.helpers import get_user_details, update_user_info
from config.config_manager import config_manager
import hashlib

Expand Down
8 changes: 4 additions & 4 deletions apps/ai_tutor/chainlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
LITERAL_API_KEY_LOGGING,
LITERAL_API_URL,
)
from modules.chat_processor.literal_ai import CustomLiteralDataLayer
from edubotics_core.chat_processor.literal_ai import CustomLiteralDataLayer
import json
from typing import Any, Dict, no_type_check
import chainlit as cl
from modules.chat.llm_tutor import LLMTutor
from modules.chat.helpers import (
from edubotics_core.chat.llm_tutor import LLMTutor
from edubotics_core.chat.helpers import (
get_sources,
get_history_chat_resume,
get_history_setup_llm,
# get_last_config,
)
from modules.chat_processor.helpers import (
from edubotics_core.chat_processor.helpers import (
update_user_info,
get_user_details,
)
Expand Down
2 changes: 1 addition & 1 deletion apps/ai_tutor/config/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TokenConfig(BaseModel):


class MiscConfig(BaseModel):
github_repo: HttpUrl = "https://github.com/DL4DS/dl4ds_tutor"
github_repo: HttpUrl = "https://github.com/edubotics-ai/edubot-core"
docs_website: HttpUrl = "https://dl4ds.github.io/dl4ds_tutor/"


Expand Down
2 changes: 1 addition & 1 deletion apps/ai_tutor/config/project_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ token_config:
all_time_tokens_allocated: 1000000

misc:
github_repo: "https://github.com/DL4DS/dl4ds_tutor"
github_repo: "https://github.com/edubotics-ai/edubot-core"
docs_website: "https://dl4ds.github.io/dl4ds_tutor/"

api_config:
Expand Down
2 changes: 1 addition & 1 deletion apps/ai_tutor/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime, timedelta, timezone
import tiktoken
from modules.chat_processor.helpers import update_user_info, convert_to_dict
from edubotics_core.chat_processor.helpers import update_user_info, convert_to_dict


def get_time():
Expand Down
4 changes: 2 additions & 2 deletions apps/chainlit_base/chainlit_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import asyncio
from typing import Any, Dict, no_type_check
import chainlit as cl
from modules.chat.llm_tutor import LLMTutor
from modules.chat.helpers import (
from edubotics_core.chat.llm_tutor import LLMTutor
from edubotics_core.chat.helpers import (
get_sources,
get_history_setup_llm,
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from langchain_core.prompts import ChatPromptTemplate

# from modules.chat.langchain.utils import
# from edubotics_core.chat.langchain.utils import
from langchain_community.chat_message_histories import ChatMessageHistory
from modules.chat.base import BaseRAG
from edubotics_core.chat.base import BaseRAG
from langchain_core.prompts import PromptTemplate
from langchain.memory import ConversationBufferWindowMemory
from langchain_core.runnables.utils import ConfigurableFieldSpec
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions modules/chat/llm_tutor.py → edubotics_core/chat/llm_tutor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from modules.chat.helpers import get_prompt
from modules.chat.chat_model_loader import ChatModelLoader
from modules.vectorstore.store_manager import VectorStoreManager
from modules.retriever.retriever import Retriever
from modules.chat.langchain.langchain_rag import (
from edubotics_core.chat.helpers import get_prompt
from edubotics_core.chat.chat_model_loader import ChatModelLoader
from edubotics_core.vectorstore.store_manager import VectorStoreManager
from edubotics_core.retriever.retriever import Retriever
from edubotics_core.chat.langchain.langchain_rag import (
Langchain_RAG_V2,
QuestionGenerator,
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import html2text
import bs4
import PyPDF2
from modules.dataloader.pdf_readers.base import PDFReader
from modules.dataloader.pdf_readers.llama import LlamaParser
from modules.dataloader.pdf_readers.gpt import GPTParser
from modules.dataloader.helpers import get_metadata
from modules.config.constants import TIMEOUT
from edubotics_core.dataloader.pdf_readers.base import PDFReader
from edubotics_core.dataloader.pdf_readers.llama import LlamaParser
from edubotics_core.dataloader.pdf_readers.gpt import GPTParser
from edubotics_core.dataloader.helpers import get_metadata
from edubotics_core.config.constants import TIMEOUT

logger = logging.getLogger(__name__)
BASE_DIR = os.getcwd()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from bs4 import BeautifulSoup
from urllib.parse import urlparse
import tempfile
from modules.config.constants import (
from edubotics_core.config.constants import (
TIMEOUT,
) # TODO: MOVE THIS TO APP SPECIFIC DIRECTORY

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from openai import OpenAI
from pdf2image import convert_from_path
from langchain.schema import Document
from modules.config.constants import TIMEOUT
from edubotics_core.config.constants import TIMEOUT


class GPTParser:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import requests
from llama_parse import LlamaParse
from langchain.schema import Document
from modules.config.constants import OPENAI_API_KEY, LLAMA_CLOUD_API_KEY, TIMEOUT
from modules.dataloader.helpers import download_pdf_from_url
from edubotics_core.config.constants import OPENAI_API_KEY, LLAMA_CLOUD_API_KEY, TIMEOUT
from edubotics_core.dataloader.helpers import download_pdf_from_url


class LlamaParser:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin, urldefrag
from modules.config.constants import TIMEOUT
from edubotics_core.config.constants import TIMEOUT


class WebpageCrawler:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from modules.retriever.faiss_retriever import FaissRetriever
from modules.retriever.chroma_retriever import ChromaRetriever
from modules.retriever.colbert_retriever import ColbertRetriever
from modules.retriever.raptor_retriever import RaptorRetriever
from edubotics_core.retriever.faiss_retriever import FaissRetriever
from edubotics_core.retriever.chroma_retriever import ChromaRetriever
from edubotics_core.retriever.colbert_retriever import ColbertRetriever
from edubotics_core.retriever.raptor_retriever import RaptorRetriever


class Retriever:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from langchain_community.vectorstores import Chroma
from modules.vectorstore.base import VectorStoreBase
from edubotics_core.vectorstore.base import VectorStoreBase
import os


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ragatouille import RAGPretrainedModel
from modules.vectorstore.base import VectorStoreBase
from edubotics_core.vectorstore.base import VectorStoreBase
from langchain_core.retrievers import BaseRetriever
from langchain_core.callbacks.manager import CallbackManagerForRetrieverRun
from langchain_core.documents import Document
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.embeddings import HuggingFaceEmbeddings
from modules.config.constants import OPENAI_API_KEY, HUGGINGFACE_TOKEN
from edubotics_core.config.constants import OPENAI_API_KEY, HUGGINGFACE_TOKEN


class EmbeddingModelLoader:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from langchain_community.vectorstores import FAISS
from modules.vectorstore.base import VectorStoreBase
from edubotics_core.vectorstore.base import VectorStoreBase
import os


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from langchain_community.chat_models import ChatOpenAI
from langchain_community.vectorstores import FAISS
from langchain.text_splitter import RecursiveCharacterTextSplitter
from modules.vectorstore.base import VectorStoreBase
from edubotics_core.vectorstore.base import VectorStoreBase

RANDOM_SEED = 42

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from modules.vectorstore.vectorstore import VectorStore
from modules.dataloader.helpers import get_urls_from_file
from modules.dataloader.webpage_crawler import WebpageCrawler
from modules.dataloader.data_loader import DataLoader
from modules.vectorstore.embedding_model_loader import EmbeddingModelLoader
from edubotics_core.vectorstore.vectorstore import VectorStore
from edubotics_core.dataloader.helpers import get_urls_from_file
from edubotics_core.dataloader.webpage_crawler import WebpageCrawler
from edubotics_core.dataloader.data_loader import DataLoader
from edubotics_core.vectorstore.embedding_model_loader import EmbeddingModelLoader
import logging
import os
import time
import asyncio
import yaml
import argparse


class VectorStoreManager:
Expand Down Expand Up @@ -137,7 +139,7 @@ def load_database(self):
self.loaded_vector_db = self.vector_db._load_database(self.embedding_model)
except Exception as e:
raise ValueError(
f"Error loading database, check if it exists. if not run python -m modules.vectorstore.store_manager / Resteart the HF Space: {e}"
f"Error loading database, check if it exists. if not run python -m edubotics_core.vectorstore.store_manager / Resteart the HF Space: {e}"
)
# print(f"Creating database")
# self.create_database()
Expand All @@ -162,10 +164,7 @@ def __len__(self):
return len(self.vector_db)


if __name__ == "__main__":
import yaml
import argparse

def main():
# Add argument parsing for config files
parser = argparse.ArgumentParser(description="Load configuration files.")
parser.add_argument(
Expand Down Expand Up @@ -216,3 +215,7 @@ def __len__(self):
print("Loaded database")

print(f"View the logs at {config['log_dir']}/vector_db.log")


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from modules.vectorstore.faiss import FaissVectorStore
from modules.vectorstore.chroma import ChromaVectorStore
from modules.vectorstore.colbert import ColbertVectorStore
from modules.vectorstore.raptor import RAPTORVectoreStore
from edubotics_core.vectorstore.faiss import FaissVectorStore
from edubotics_core.vectorstore.chroma import ChromaVectorStore
from edubotics_core.vectorstore.colbert import ColbertVectorStore
from edubotics_core.vectorstore.raptor import RAPTORVectoreStore
from huggingface_hub import snapshot_download
import os
import shutil
Expand Down
Loading

0 comments on commit d55c537

Please sign in to comment.