Skip to content

Commit

Permalink
[Refactor] Reorganised code structure (cont'd)
Browse files Browse the repository at this point in the history
  • Loading branch information
picaultj committed Dec 17, 2024
1 parent bcb1f6e commit fab7e83
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# This file is part of BERTrend.
#

CUDA_VISIBLE_DEVICES=0 OPENAI_API_KEY=$AZURE_WATTELSE_OPENAI_API_KEY OPENAI_ENDPOINT=$AZURE_WATTELSE_OPENAI_ENDPOINT OPENAI_DEFAULT_MODEL_NAME=$AZURE_WATTELSE_OPENAI_DEFAULT_MODEL_NAME streamlit run --theme.primaryColor royalblue app.py
CUDA_VISIBLE_DEVICES=0 OPENAI_API_KEY=$AZURE_WATTELSE_OPENAI_API_KEY OPENAI_ENDPOINT=$AZURE_WATTELSE_OPENAI_ENDPOINT OPENAI_DEFAULT_MODEL_NAME=$AZURE_WATTELSE_OPENAI_DEFAULT_MODEL_NAME streamlit run --theme.primaryColor royalblue summarization/summarizer_app.py
8 changes: 8 additions & 0 deletions bertrend/demos/start_topic_analysis_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2024, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# SPDX-License-Identifier: MPL-2.0
# This file is part of BERTrend.
#

CUDA_VISIBLE_DEVICES=0 OPENAI_API_KEY=$AZURE_WATTELSE_OPENAI_API_KEY OPENAI_ENDPOINT=$AZURE_WATTELSE_OPENAI_ENDPOINT OPENAI_DEFAULT_MODEL_NAME=$AZURE_WATTELSE_OPENAI_DEFAULT_MODEL_NAME streamlit run --theme.primaryColor royalblue topic_analysis/Main_page.py
8 changes: 8 additions & 0 deletions bertrend/demos/start_weak_signals_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2024, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# SPDX-License-Identifier: MPL-2.0
# This file is part of BERTrend.
#

CUDA_VISIBLE_DEVICES=0 OPENAI_API_KEY=$AZURE_WATTELSE_OPENAI_API_KEY OPENAI_ENDPOINT=$AZURE_WATTELSE_OPENAI_ENDPOINT OPENAI_DEFAULT_MODEL_NAME=$AZURE_WATTELSE_OPENAI_DEFAULT_MODEL_NAME streamlit run --theme.primaryColor royalblue weak_signals/app.py
6 changes: 3 additions & 3 deletions bertrend/demos/summarization/summarizer_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import streamlit as st
from loguru import logger

from bertrend.summary.abstractive_summarizer import AbstractiveSummarizer
from bertrend.summary.chatgpt_summarizer import GPTSummarizer
from bertrend.summary.extractive_summarizer import (
from bertrend.services.summary.abstractive_summarizer import AbstractiveSummarizer
from bertrend.services.summary.chatgpt_summarizer import GPTSummarizer
from bertrend.services.summary.extractive_summarizer import (
EnhancedExtractiveSummarizer,
ExtractiveSummarizer,
)
Expand Down
6 changes: 3 additions & 3 deletions bertrend/demos/topic_analysis/pages/4_Generate_Newsletters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
register_widget,
save_widget_state,
)
from bertrend.summary import GPTSummarizer
from bertrend.summary.abstractive_summarizer import AbstractiveSummarizer
from bertrend.summary.extractive_summarizer import (
from bertrend.services.summary import GPTSummarizer
from bertrend.services.summary.abstractive_summarizer import AbstractiveSummarizer
from bertrend.services.summary.extractive_summarizer import (
ExtractiveSummarizer,
EnhancedExtractiveSummarizer,
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
# See AUTHORS.txt
# SPDX-License-Identifier: MPL-2.0
# This file is part of BERTrend.

from bertrend.summary.chatgpt_summarizer import GPTSummarizer
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

from bertrend.summary.summarizer import Summarizer
from bertrend.services.summarizer import Summarizer

device = "cuda:0" if torch.cuda.is_available() else "cpu"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from loguru import logger

from bertrend.llm_utils.openai_client import OpenAI_Client
from bertrend.summary.prompts import (
from bertrend.services.summary.prompts import (
FR_SYSTEM_SUMMARY_SENTENCES,
EN_SYSTEM_SUMMARY_SENTENCES,
)
from bertrend.summary.summarizer import DEFAULT_MAX_SENTENCES
from bertrend.services.summarizer import DEFAULT_MAX_SENTENCES

from bertrend.summary.summarizer import Summarizer
from bertrend.services.summarizer import Summarizer


class GPTSummarizer(Summarizer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
from torch import Tensor

from bertrend.llm_utils.openai_client import OpenAI_Client
from bertrend.summary.lexrank import degree_centrality_scores
from bertrend.summary.prompts import (
from bertrend.services.summary.lexrank import degree_centrality_scores
from bertrend.services.summary.prompts import (
FR_SYSTEM_SUMMARY_SENTENCES,
EN_SYSTEM_SUMMARY_SENTENCES,
)
from bertrend.summary.summarizer import (
from bertrend.services.summarizer import (
Summarizer,
DEFAULT_MAX_SENTENCES,
DEFAULT_SUMMARIZATION_RATIO,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bertrend/trend_analysis/weak_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
SIGNAL_CLASSIF_UPPER_BOUND,
)
from bertrend import SIGNAL_EVOLUTION_DATA_DIR
from bertrend.signal_analysis.prompts import get_prompt, save_html_output
from bertrend.trend_analysis.prompts import get_prompt, save_html_output


def detect_weak_signals_zeroshot(
Expand Down
2 changes: 1 addition & 1 deletion bertrend_apps/data_provider/arxiv_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from loguru import logger
import requests

from bertrend.utils import TEXT_COLUMN
from bertrend.utils.data_loading import TEXT_COLUMN
from bertrend_apps.data_provider.data_provider import DataProvider
from bertrend_apps.data_provider.utils import wait

Expand Down
10 changes: 3 additions & 7 deletions bertrend_apps/exploration/curebot/veille_analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
from loguru import logger
from streamlit.runtime.uploaded_file_manager import UploadedFile

from bertrend.summary.chatgpt_summarizer import GPTSummarizer
from bertrend.services.summary.chatgpt_summarizer import GPTSummarizer
from bertrend.train import train_BERTopic
from bertrend.utils import (
load_data,
TIMESTAMP_COLUMN,
split_df_by_paragraphs,
clean_dataset,
)
from bertrend.utils.data_loading import load_data, TIMESTAMP_COLUMN, split_df_by_paragraphs, clean_dataset

from bertrend_apps.data_provider.curebot_provider import CurebotProvider
from bertrend_apps.newsletters.newsletter_features import generate_newsletter, md2html

Expand Down
4 changes: 2 additions & 2 deletions bertrend_apps/newsletters/newsletter_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
FR_USER_GENERATE_TOPIC_LABEL_SUMMARIES_V2,
EN_USER_GENERATE_TOPIC_LABEL_SUMMARIES_V2,
)
from bertrend.summary.summarizer import Summarizer
from bertrend.summary.abstractive_summarizer import AbstractiveSummarizer
from bertrend.services.summarizer import Summarizer
from bertrend.services.summary.abstractive_summarizer import AbstractiveSummarizer
from bertopic._bertopic import BERTopic
from tqdm import tqdm

Expand Down

0 comments on commit fab7e83

Please sign in to comment.