Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shackless committed May 22, 2024
2 parents 12d483e + b2a41b7 commit 9d588fe
Show file tree
Hide file tree
Showing 15 changed files with 3,835 additions and 546 deletions.
21 changes: 15 additions & 6 deletions api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,18 @@ class NestedConfig(BaseModel):
skills: Optional[list[SkillConfig]] = None


class BasicWingmanConfig(BaseModel):
"""All configuration options that can be save in the "Basic" config in the client"""

name: str
disabled: Optional[bool] = False
record_key: Optional[str] = None
record_key_codes: Optional[list[int]] = None
sound: SoundConfig
voice: str | OpenAiTtsVoice
backstory: Optional[str] = None


class WingmanConfig(NestedConfig):
def __getitem__(self, item):
return self.extra_properties.get(item)
Expand All @@ -522,14 +534,11 @@ def __setitem__(self, key, value):
description: str
"""A short description of this Wingman."""
record_key: Optional[str] = None
"""The "push-to-talk" key for this wingman. Keep it pressed while talking!
Modifiers for this key are not supported yet. Don't use the same key for multiple wingmen!"""
"""The "push-to-talk" key for this wingman. Keep it pressed while talking! Don't use the same key for multiple wingmen!"""
record_key_codes: Optional[list[int]] = None
"""The "push-to-talk" key code for this wingman. Keep it pressed while talking!
Modifiers for this key are not supported yet. Don't use the same key for multiple wingmen!"""
"""The "push-to-talk" key code for this wingman. Keep it pressed while talking! Don't use the same key for multiple wingmen!"""
record_mouse_button: Optional[str] = None
"""The "push-to-talk" mouse button for this wingman. Keep it pressed while talking!
Don't use the same button for multiple wingmen!"""
"""The "push-to-talk" mouse button for this wingman. Keep it pressed while talking! Don't use the same button for multiple wingmen!"""
is_voice_activation_default: Optional[bool] = None
"""If voice activation is enabled and this is true, the Wingman will listen to your voice by default and without saying its name."""

Expand Down
3 changes: 2 additions & 1 deletion keyboard/keyboard/_winkeyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ def _setup_name_tables():
# Remember the "id" of the name, as the first techniques
# have better results and therefore priority.
for i, name in enumerate(map(normalize_name, names + lowercase_names)):
from_name[name].append((i, entry))
if name != "alt gr": # alt gr gets added manually later
from_name[name].append((i, entry))

# TODO: single quotes on US INTL is returning the dead key (?), and therefore
# not typing properly.
Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
azure-cognitiveservices-speech==1.37.0
edge-tts==6.1.10
elevenlabslib~=0.22.1
fastapi~=0.110.1
edge-tts==6.1.11
elevenlabslib~=0.22.3
fastapi~=0.111.0
numpy~=1.26.4
openai~=1.23.2
openai~=1.30.1
packaging~=24.0
pedalboard~=0.9.3
platformdirs~=4.2.0
pedalboard~=0.9.6
platformdirs~=4.2.2
pyaudio~=0.2.14
pydantic~=2.7.0
pydantic~=2.7.1
pydirectinput-rgx==2.1.1
pyinstaller==6.6.0
python-multipart==0.0.9
PyYAML~=6.0.1
requests~=2.31.0
requests~=2.32.2
scipy~=1.13.0
sounddevice~=0.4.6
soundfile~=0.12.1
SpeechRecognition~=3.10.3
SpeechRecognition~=3.10.4
typing_extensions~=4.11.0
uvicorn~=0.29.0
2 changes: 1 addition & 1 deletion services/audio_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def safe_start():
safe_start()

def stop_continuous_listening(self):
if self.is_listening_continuously and self.stop_function:
if self.stop_function:
self.stop_function(wait_for_stop=True)
self.stop_function = None
self.is_listening_continuously = False
Expand Down
28 changes: 22 additions & 6 deletions services/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def get_template_dirs(self) -> list[ConfigDirInfo]:

def __get_template_dir(self, config_dir: ConfigDirInfo) -> Optional[ConfigDirInfo]:
"""Gets the template directory for a given config directory."""
template_dir = path.join(self.templates_dir, config_dir.directory)
template_dir = path.join(self.templates_dir, CONFIGS_DIR, config_dir.directory)
if not path.exists(template_dir):
# check if "defaulted" template dir exists
default_template_dir = path.join(
Expand Down Expand Up @@ -221,16 +221,19 @@ def __get_template(
return (None, None)

for root, dirs, files in walk(
path.join(self.templates_dir, config_dir.directory)
path.join(self.templates_dir, CONFIGS_DIR, config_dir.directory)
):
for filename in files:
# templates are never logically deleted
base_file_name = filename.replace(".template", "")
if filename.endswith(
"template.yaml"
if (
filename.endswith("template.yaml")
# but the given wingman config might be logically deleted
) and base_file_name == wingman_file.file.replace(
DELETED_PREFIX, "", 1
and base_file_name == wingman_file.file
or (
wingman_file.file.startswith(DELETED_PREFIX)
and base_file_name == wingman_file.file[1:]
)
):
file_info = WingmanConfigFileInfo(
file=base_file_name,
Expand Down Expand Up @@ -528,6 +531,19 @@ def save_wingman_config(
self.config_dir, config_dir.directory, wingman_file.file
)

# check if there is a template for the old name
tpl, wng = self.__get_template(config_dir, wingman_file)
if tpl and wng:
# leave a .[OLD] file so that it won't be recreated next time
shutil.copyfile(
old_config_path,
path.join(
self.config_dir,
config_dir.directory,
f"{DELETED_PREFIX}{wng.file}",
),
)

# move the config
shutil.move(
old_config_path,
Expand Down
44 changes: 44 additions & 0 deletions services/config_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Optional
from fastapi import APIRouter
from api.enums import OpenAiTtsVoice
from api.interface import (
BasicWingmanConfig,
ConfigDirInfo,
ConfigWithDirInfo,
ConfigsInfo,
Expand Down Expand Up @@ -118,6 +120,12 @@ def __init__(self, config_manager: ConfigManager):
endpoint=self.save_wingman_config,
tags=tags,
)
self.router.add_api_route(
methods=["POST"],
path="/config/save-wingman-basic",
endpoint=self.save_basic_wingman_config,
tags=tags,
)
self.router.add_api_route(
methods=["GET"],
path="/available-skills",
Expand Down Expand Up @@ -277,6 +285,42 @@ async def save_wingman_config(
else:
self.printr.toast_error(f"{error_message}")

# POST config/save-wingman-basic
async def save_basic_wingman_config(
self,
config_dir: ConfigDirInfo,
wingman_file: WingmanConfigFileInfo,
basic_config: BasicWingmanConfig,
silent: bool = False,
):
# get the current config
wingman_config = self.config_manager.load_wingman_config(
config_dir=config_dir, wingman_file=wingman_file
)

wingman_config.name = basic_config.name
wingman_config.disabled = basic_config.disabled
wingman_config.record_key = basic_config.record_key
wingman_config.record_key_codes = basic_config.record_key_codes
wingman_config.sound = basic_config.sound
wingman_config.prompts.backstory = basic_config.backstory
try:
wingman_config.openai.tts_voice = OpenAiTtsVoice(basic_config.voice)
except ValueError:
wingman_config.azure.tts.voice = basic_config.voice

self.config_manager.save_wingman_config(
config_dir=config_dir,
wingman_file=wingman_file,
wingman_config=wingman_config,
)
try:
if not silent:
await self.load_config(config_dir)
self.printr.toast("Wingman saved successfully.")
except Exception as e:
self.printr.toast_error(f"Invalid Wingman configuration: {str(e)}")

# POST config/wingman/default
async def set_default_wingman(
self,
Expand Down
2 changes: 1 addition & 1 deletion services/system_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from packaging import version
from api.interface import SystemCore, SystemInfo

LOCAL_VERSION = "1.3.0"
LOCAL_VERSION = "1.3.1"
VERSION_ENDPOINT = "https://shipbit.de/wingman.json"


Expand Down
25 changes: 19 additions & 6 deletions skills/uexcorp/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ prompt: |
You have tools to access the UEXcorp API which you can use to retrieve live trading data and additional information about ships, locations, commodities and more in Star Citizen.
Here are some examples when to use the different tools at your disposal:
Do not use markdown formatting (e.g. **name**) in your answers, but prefer lists to show multiple options or information.
Do not (never) translate any properties when giving them to the player. They must stay in english or untouched.
Only give functions parameters that were previously clearly provided by a request. Never assume any values, not the current ship, not the location, not the available money, nothing! Always send a None-value instead.
If you are not using one of the definied functions, dont give any trading recommendations.
Expand Down Expand Up @@ -108,18 +109,21 @@ custom_properties:
- id: uexcorp_api_url
name: API URL
hint: The URL of the UEX corp API.
value: https://portal.uexcorp.space/api
value: https://uexcorp.space/api/2.0/
required: true
property_type: string
- id: uexcorp_api_timeout
name: API Timeout
hint: The timeout for the UEX corp API in seconds.
value: 5
hint: The timeout for the UEX corp API in seconds. (If set below 3s, 3s will be used.)
value: 10
required: true
property_type: number
- id: uexcorp_api_timeout_retries
name: API Timeout Retries
hint: How often the request should be retried in case of a timeout. (Timeout setting may increase automatically on each retry.)
value: 3
required: true
property_type: number
# ────────────────────────────── No touchy zone end ──────────────────────────────

# ──────────────────────── uexcorp specific config start ─────────────────────────
# Set this option to "true" to enable caching of the UEX corp API responses. This is recommended, as the API key's quota is very limited.
# If you set this option to "false", the Wingman will fetch all data from the UEX corp API on every start.
# If you want to update the prices, just tell the Wingman to do so.
Expand Down Expand Up @@ -182,3 +186,12 @@ custom_properties:
value: 1
required: true
property_type: number

# Set this option to true to take estimated scu availability into account for trade route calculations.
# This will reduce the amount of trade routes shown, but will give you more accurate results.
- id: uexcorp_use_estimated_availability
name: Use Estimated Availability
hint: Enable this option to take estimated scu availability into account for trade route calculations.
value: true
required: true
property_type: boolean
Loading

0 comments on commit 9d588fe

Please sign in to comment.