Skip to content

Commit e20186d

Browse files
committed
Merge branch '29-update-constants-format' of https://github.com/S0L0GUY/nova-ai into 29-update-constants-format
2 parents ff608b9 + 38a8a2b commit e20186d

File tree

13 files changed

+108
-499
lines changed

13 files changed

+108
-499
lines changed

.github/workflows/python-lint.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,8 @@ jobs:
2222
- name: Install linting tools
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install flake8 pylint
25+
pip install flake8
2626
2727
- name: Lint with flake8
2828
run: |
29-
flake8 .
30-
31-
- name: Lint with pylint
32-
run: |
33-
pylint $(git ls-files '*.py') || true
34-
pylint_score=$(pylint $(git ls-files '*.py') --exit-zero | grep 'Your code has been rated at' | awk '{print $7}' | cut -d'/' -f1)
35-
if (( $(echo "$pylint_score >= 7" | bc -l) )); then
36-
echo "Pylint score is $pylint_score, which is acceptable."
37-
exit 0
38-
else
39-
echo "Pylint score is $pylint_score, which is below the acceptable threshold."
40-
exit 1
41-
fi
29+
flake8 .

classes/json_wrapper.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
"""
2-
This module provides a JsonWrapper class for handling JSON file operations.
3-
It includes functionality for reading, writing, and managing JSON files.
4-
"""
5-
61
import json
72

83

94
class JsonWrapper:
10-
"""
11-
A utility class for reading, writing, and managing JSON files.
12-
Provides methods for reading JSON and text files, writing JSON data,
13-
and clearing JSON file contents.
14-
"""
155
@staticmethod
166
def read_json(file_path):
177
"""
@@ -23,7 +13,7 @@ def read_json(file_path):
2313
str: The contents of the JSON file as a pretty-printed JSON string.
2414
"""
2515

26-
with open(file_path, 'r', encoding='utf-8') as file:
16+
with open(file_path, 'r') as file:
2717
data = json.load(file)
2818
return json.dumps(data, indent=4)
2919

@@ -36,7 +26,7 @@ def read_txt(self, file_path):
3626
str: The contents of the text file as a string.
3727
"""
3828

39-
with open(file_path, 'r', encoding='utf-8') as file:
29+
with open(file_path, 'r') as file:
4030
return file.read()
4131

4232
@staticmethod
@@ -51,7 +41,7 @@ def write(file_path, data):
5141
IOError: If the file cannot be opened or written to.
5242
"""
5343

54-
with open(file_path, 'a', encoding='utf-8') as file:
44+
with open(file_path, 'a') as file:
5545
json.dump(data, file, indent=4)
5646

5747
@staticmethod
@@ -64,7 +54,7 @@ def delete(file_path):
6454
IOError: If the file cannot be deleted.
6555
"""
6656

67-
with open(file_path, 'r', encoding='utf-8') as file:
57+
with open(file_path, 'r') as file:
6858
data = json.load(file)
6959

7060
if isinstance(data, list):
@@ -75,5 +65,5 @@ def delete(file_path):
7565
raise ValueError(
7666
"The file does not contain a JSON object or array.")
7767

78-
with open(file_path, 'w', encoding='utf-8') as file:
68+
with open(file_path, 'w') as file:
7969
json.dump(empty_data, file, indent=4)

classes/osc.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
"""
2-
Module for handling OSC (Open Sound Control) communications with VRChat.
3-
This module provides a class for sending messages and managing typing
4-
indicators in the VRChat chatbox through OSC protocol. It utilizes the
5-
python-osc library for UDP client functionality.
6-
Classes:
7-
VRChatOSC: A class for managing OSC communications with VRChat chatbox.
8-
"""
9-
101
from pythonosc import udp_client
112

123

134
class VRChatOSC:
14-
"""
15-
A class for managing OSC communications with VRChat chatbox.
16-
Provides methods for sending messages and controlling typing indicators
17-
through OSC protocol.
18-
"""
195
def __init__(self, ip: str, port: int):
206
"""
217
Initializes the OSC client with the specified IP address and port.

classes/system_prompt.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,7 @@
1-
"""
2-
A class that handles system prompts for an AI assistant.
3-
This class provides static methods to manage and retrieve prompts from
4-
a 'prompts' directory. It can combine mood-specific prompts with additional
5-
prompt content to create comprehensive system instructions.
6-
The class assumes a specific directory structure where prompt files are
7-
stored in a 'prompts' directory, with filenames that begin with a mood
8-
identifier followed by underscores.
9-
Example:
10-
full_prompt = SystemPrompt.get_full_prompt('happy')
11-
Attributes:
12-
None
13-
Methods:
14-
get_prompt_directory(): Returns a dictionary of prompt files.
15-
get_full_prompt(mood): Returns combined prompt content for a specific mood.
16-
"""
171
import os
182

193

204
class SystemPrompt:
21-
"""
22-
A class that handles system prompts for an AI assistant.
23-
24-
This class provides static methods to manage and retrieve prompts from
25-
a 'prompts' directory. It combines mood-specific prompts with additional
26-
prompt content to create comprehensive system instructions.
27-
28-
Methods:
29-
get_prompt_directory(): Returns a dictionary of prompt files.
30-
get_full_prompt(mood): Returns combined prompt content for a specific
31-
mood.
32-
"""
33-
345
@staticmethod
356
def get_prompt_directory():
367
"""
@@ -80,11 +51,10 @@ def get_full_prompt(mood):
8051
mood_prompt_path = prompt_dict[mood]
8152
additional_prompt_path = prompt_dict['additional']
8253

83-
with open(mood_prompt_path, 'r', encoding='utf-8') as mood_file:
54+
with open(mood_prompt_path, 'r') as mood_file:
8455
mood_prompt_content = mood_file.read()
8556

86-
with open(additional_prompt_path, 'r',
87-
encoding='utf-8') as additional_file:
57+
with open(additional_prompt_path, 'r') as additional_file:
8858
additional_prompt_content = additional_file.read()
8959

9060
return mood_prompt_content + "\n" + additional_prompt_content

classes/whisper.py

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
1-
"""
2-
This module provides functionality for transcribing speech to text using
3-
OpenAI's Whisper model. It includes audio recording capabilities and silence
4-
detection for automatic recording termination.
5-
"""
6-
7-
import wave
8-
import pyaudio
91
import whisper
2+
import pyaudio
3+
import wave
104
from pydub import AudioSegment
115

126

137
class WhisperTranscriber:
14-
"""
15-
A class for transcribing speech to text using OpenAI's Whisper model.
16-
Provides functionality for real-time audio recording and transcription,
17-
as well as transcription from existing audio files.
18-
"""
19-
208
def __init__(self):
21-
"""Initialize the WhisperTranscriber with the base Whisper model."""
229
self.model = whisper.load_model("base")
2310

24-
def transcribe_file(self, audio_file_path):
25-
"""
26-
Transcribe an existing audio file using the Whisper model.
27-
28-
Args:
29-
audio_file_path (str): Path to the audio file to transcribe
30-
31-
Returns:
32-
str: The transcribed text from the audio file
33-
"""
34-
result = self.model.transcribe(audio_file_path)
35-
return result['text']
36-
3711
def get_speech_input(self):
3812
"""
3913
Records audio input from the microphone, detects silence to stop
@@ -48,15 +22,15 @@ def get_speech_input(self):
4822
p = pyaudio.PyAudio()
4923

5024
# Set audio recording parameters
51-
audio_format = pyaudio.paInt16
25+
format = pyaudio.paInt16
5226
channels = 1
5327
rate = 16000
5428
chunk = 1024
5529
silence_threshold = -40 # Silence threshold in dB
5630
silence_duration = 1000 # Duration of silence in ms (1 second)
5731

5832
# Open the audio stream
59-
stream = p.open(format=audio_format,
33+
stream = p.open(format=format,
6034
channels=channels,
6135
rate=rate,
6236
input=True,
@@ -73,7 +47,7 @@ def get_speech_input(self):
7347
# Convert audio chunk to Pydub's AudioSegment for silence detection
7448
audio_chunk = AudioSegment(
7549
data,
76-
sample_width=p.get_sample_size(audio_format),
50+
sample_width=p.get_sample_size(format),
7751
frame_rate=rate,
7852
channels=channels
7953
)

commit_history.py

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,17 @@
1-
"""
2-
GitHub Commit History Module
3-
4-
This module provides functionality to fetch commit history from GitHub
5-
repositories and write it to a markdown file. It uses GitHub's REST API to
6-
retrieve commit information and formats it into a readable markdown document.
7-
8-
Functions:
9-
fetch_commits(repo_owner, repo_name): Fetches commit data from GitHub
10-
write_commits_to_file(commits, file_path): Writes commits to markdown
11-
main(): Entry point that demonstrates the module usage
12-
"""
13-
141
import requests
152

163

174
def fetch_commits(repo_owner, repo_name):
18-
"""
19-
Module for fetching commit history from GitHub repositories using the
20-
GitHub API. This module provides functionality to interact with GitHub's
21-
REST API to retrieve commit information for specified repositories.
22-
"""
23-
245
commits_url = (
256
f"https://api.github.com/repos/{repo_owner}/{repo_name}/commits"
267
)
27-
response = requests.get(commits_url, timeout=10)
8+
response = requests.get(commits_url)
289
response.raise_for_status() # Check for request errors
2910
return response.json()
3011

3112

3213
def write_commits_to_file(commits, file_path):
33-
"""
34-
Module for handling Git commit history and writing it to a file in
35-
Markdown format. This module provides functionality to create a formatted
36-
commit history log.
37-
"""
38-
39-
with open(file_path, 'w', encoding='utf-8') as file:
14+
with open(file_path, 'w') as file:
4015
file.write("# Commit History\n\n")
4116
for commit in commits:
4217
sha = commit['sha']
@@ -49,20 +24,6 @@ def write_commits_to_file(commits, file_path):
4924

5025

5126
def main():
52-
"""
53-
Main function to fetch and write GitHub repository commits to a file.
54-
The function uses predefined repository details:
55-
- Repository owner: "S0L0GUY"
56-
- Repository name: "NOVA-AI"
57-
- Output file path: "commits.md"
58-
It fetches all commits from the specified repository and writes them to a
59-
markdown file.
60-
Requires:
61-
- fetch_commits() function to get commits from GitHub
62-
- write_commits_to_file() function to write commits to file
63-
Prints a confirmation message once the commits are written to the file.
64-
"""
65-
6627
repo_owner = "S0L0GUY"
6728
repo_name = "NOVA-AI"
6829
file_path = "commits.md"

constants.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
"""
2-
Constants module for Nova AI project.
3-
This module contains all the configuration constants used throughout the
4-
project.
5-
Constants:
6-
Network Settings:
7-
LOCAL_IP (str): Local IP address of the computer
8-
VRC_PORT (int): VRChat port number, default is 9000
9-
Audio Settings:
10-
AUDIO_OUTPUT_INDEX (int): Index number for audio output device
11-
(VB-Audio Cable B)
12-
Language Model Settings:
13-
MODEL_ID (str): Identifier for the language model being used
14-
LM_TEMPERATURE (float): Temperature setting for language model output
15-
generation
16-
File Paths:
17-
HISTORY_PATH (str): Path to the history JSON file
18-
Note:
19-
Make sure to adjust LOCAL_IP and AUDIO_OUTPUT_INDEX according to your
20-
system configuration.
21-
"""
22-
23-
241
class Network:
252
"""
263
Class representing network configuration parameters.

0 commit comments

Comments
 (0)