Skip to content

Commit

Permalink
uv package
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmatthis committed Oct 15, 2024
1 parent 9cf6a2b commit 9d67bfc
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .env.discord.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DISCORD_BOT_TOKEN=<Insert Your Created Bot Token Here>
DISCORD_BOT_TOKEN=<Insert Your Created Bot Token Here>
2 changes: 1 addition & 1 deletion .env.openai.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OPENAI_API_KEY = <Your OpenAI API Key>
OPENAI_API_KEY = <Your OpenAI API Key>
1 change: 1 addition & 0 deletions .github/workflows/google-cloudrun-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ on:
branches: [ "main" ]
paths-ignore:
- 'Writerside/**' #don't build if changes are only to docs
- 'src_python/**' #don't build if changes are only to python analysis code

env:
PROJECT_ID: mocap-test-project # TODO: update Google Cloud project id
Expand Down
6 changes: 3 additions & 3 deletions src_python/main.py → src_python/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from src.configure_logging import configure_logging

from src_python.src.scrape_server.save_to_disk import save_server_data_to_disk
from src_python.src.scrape_server.scrape_server import process_server
from src_python.src.utilities.load_env_variables import DISCORD_DEV_BOT_ID, OUTPUT_DIRECTORY, TARGET_SERVER_ID, \
from src.scrape_server.save_to_disk import save_server_data_to_disk
from src.scrape_server.scrape_server import process_server
from src.utilities.load_env_variables import DISCORD_DEV_BOT_ID, OUTPUT_DIRECTORY, TARGET_SERVER_ID, \
STUDENT_IDENTIFIERS_CSV_PATH, DISCORD_DEV_BOT_TOKEN

configure_logging()
Expand Down
6 changes: 0 additions & 6 deletions src_python/requirements.txt

This file was deleted.

8 changes: 4 additions & 4 deletions src_python/src/ai/analyze_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from pydantic import BaseModel

from src_python.src.ai.analyze_text import analyze_text
from src_python.src.configure_logging import configure_logging
from src_python.src.models.extract_text_data import ExtractedTextData
from src.ai.analyze_text import analyze_text
from src.configure_logging import configure_logging
from src.models.extract_text_data import ExtractedTextData

configure_logging()
import logging
Expand Down Expand Up @@ -80,7 +80,7 @@ async def analyze_markdown_file(base_prompt_text: str,


if __name__ == "__main__":
from src_python.src.utilities.load_env_variables import OUTPUT_DIRECTORY
from src.utilities.load_env_variables import OUTPUT_DIRECTORY

in_server_name = "HMN_Fall24"
classbot_prompt_file_name = f"{in_server_name}-prompt.txt"
Expand Down
8 changes: 4 additions & 4 deletions src_python/src/ai/analyze_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from openai import AsyncOpenAI
from pydantic import BaseModel

from src_python.src.ai.construct_prompt import construct_analyzer_prompt
from src_python.src.configure_logging import configure_logging
from src.ai.construct_prompt import construct_analyzer_prompt
from src.configure_logging import configure_logging

from src_python.src.models.extract_text_data import ExtractedTextData
from src.models.extract_text_data import ExtractedTextData
configure_logging()
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -105,7 +105,7 @@ async def get_ai_response(analyzer_prompt, llm_model, openai_client):


if __name__ == "__main__":
from src_python.src.tests.test_extraction import TEST_STRING
from src.tests.test_extraction import TEST_STRING
test_string = TEST_STRING

constructed_pydantic_model_out = analyze_text(test_string, ExtractedTextData)
Expand Down
2 changes: 1 addition & 1 deletion src_python/src/ai/construct_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic import BaseModel, Field

from src_python.src.models.extract_text_data import ExtractedTextData
from src.models.extract_text_data import ExtractedTextData

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src_python/src/models/extract_text_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field

from src_python.src.utilities.sanitize_filename import sanitize_name
from src.utilities.sanitize_filename import sanitize_name


class ExtractedTextData(BaseModel):
Expand Down Expand Up @@ -52,7 +52,7 @@ def __str__(self):


if __name__ == "__main__":
from src_python.src.ai.construct_prompt import construct_analyzer_prompt
from src.ai.construct_prompt import construct_analyzer_prompt

data = ExtractedTextData(
detailed_summary="This is a detailed summary of the text",
Expand Down
4 changes: 2 additions & 2 deletions src_python/src/models/server_data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from pydantic import BaseModel

from src_python.src.models.content_message_models import ContentMessage
from src_python.src.utilities.sanitize_filename import sanitize_name
from src.models.content_message_models import ContentMessage
from src.utilities.sanitize_filename import sanitize_name


class ChatThread(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion src_python/src/models/student_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic import BaseModel, EmailStr, FilePath

from src_python.src.models.server_data_model import CategoryData
from src.models.server_data_model import CategoryData


class StudentInfoModel(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion src_python/src/scrape_server/build_couplet_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import List

from src_python.src.models.content_message_models import ContentMessage
from src.models.content_message_models import ContentMessage

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions src_python/src/scrape_server/save_to_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from datetime import datetime
from pathlib import Path

from src_python.src.models.server_data_model import ServerData, save_as_markdown_directory, save_as_json
from src_python.src.models.student_info import ClassRosterModel
from src_python.src.utilities.sanitize_filename import sanitize_name
from src.models.server_data_model import ServerData, save_as_markdown_directory, save_as_json
from src.models.student_info import ClassRosterModel
from src.utilities.sanitize_filename import sanitize_name

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src_python/src/scrape_server/scrape_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import discord

from src_python.src.models.content_message_models import ContentMessage
from src_python.src.models.server_data_model import ChannelData, CategoryData, ServerData, ChatThread
from src.models.content_message_models import ContentMessage
from src.models.server_data_model import ChannelData, CategoryData, ServerData, ChatThread

logger = logging.getLogger(__name__)

Expand Down
7 changes: 7 additions & 0 deletions src_python/src/utilities/load_env_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
raise FileNotFoundError(f".env.analysis file not found at: {env_analysis_path}")
load_dotenv(str(env_analysis_path))

env_discord_path = Path(__file__).parent.parent.parent.parent / ".env.discord"
if not os.path.exists(env_discord_path):
raise FileNotFoundError(f".env.discord file not found at: {env_discord_path}")
load_dotenv(str(env_discord_path))


DISCORD_DEV_BOT_TOKEN = os.getenv('DISCORD_DEV_BOT_TOKEN')
DISCORD_DEV_BOT_ID = os.getenv('DISCORD_DEV_BOT_ID')
TARGET_SERVER_ID = os.getenv('TARGET_SERVER_ID')
OUTPUT_DIRECTORY = os.getenv('OUTPUT_DIRECTORY')
STUDENT_IDENTIFIERS_CSV_PATH = os.getenv('STUDENT_IDENTIFIERS_CSV_PATH')

OUTPUT_DIRECTORY = OUTPUT_DIRECTORY.replace("~", str(Path.home()))

# Ensure the environment variables are set
if not DISCORD_DEV_BOT_TOKEN or not OUTPUT_DIRECTORY or not OUTPUT_DIRECTORY:
raise ValueError("Please set DISCORD_DEV_BOT_TOKEN and OUTPUT_DIRECTORY in your .env file")

0 comments on commit 9d67bfc

Please sign in to comment.