diff --git a/prompts/base/planner_agent.txt b/prompts/base/planner_agent.txt index 1eac277..a81677c 100644 --- a/prompts/base/planner_agent.txt +++ b/prompts/base/planner_agent.txt @@ -1,4 +1,4 @@ -You are a planner agent. +You are a project manager. Your goal is to divide and conquer the task using the following agents: - Coder: An expert coder agent. - File: An expert agent for finding files. diff --git a/sources/interaction.py b/sources/interaction.py index a4a0351..aee1924 100644 --- a/sources/interaction.py +++ b/sources/interaction.py @@ -1,3 +1,4 @@ +from typing import List, Tuple, Type, Dict, Tuple from sources.text_to_speech import Speech from sources.utility import pretty_print, animate_thinking @@ -11,7 +12,8 @@ class Interaction: def __init__(self, agents, tts_enabled: bool = True, stt_enabled: bool = True, - recover_last_session: bool = False): + recover_last_session: bool = False, + ): self.is_active = True self.current_agent = None self.last_query = None diff --git a/sources/language.py b/sources/language.py index 172e16f..d1fcde8 100644 --- a/sources/language.py +++ b/sources/language.py @@ -1,3 +1,4 @@ +from typing import List, Tuple, Type, Dict, Tuple import langid import re import nltk diff --git a/sources/llm_provider.py b/sources/llm_provider.py index 79034fd..5724d89 100644 --- a/sources/llm_provider.py +++ b/sources/llm_provider.py @@ -1,16 +1,17 @@ +import os import time import ollama from ollama import chat import requests import subprocess import ipaddress +import httpx import platform from dotenv import load_dotenv, set_key from openai import OpenAI from huggingface_hub import InferenceClient -import os -import httpx +from typing import List, Tuple, Type, Dict, Tuple from sources.utility import pretty_print, animate_thinking diff --git a/sources/memory.py b/sources/memory.py index 8d4c323..090bbf5 100644 --- a/sources/memory.py +++ b/sources/memory.py @@ -1,11 +1,12 @@ -import torch -from transformers import AutoTokenizer, AutoModelForSeq2SeqLM import time import datetime import uuid import os import sys import json +from typing import List, Tuple, Type, Dict, Tuple +import torch +from transformers import AutoTokenizer, AutoModelForSeq2SeqLM sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) diff --git a/sources/router.py b/sources/router.py index 1f11604..8f42459 100644 --- a/sources/router.py +++ b/sources/router.py @@ -1,6 +1,8 @@ import os import sys import torch +from typing import List, Tuple, Type, Dict, Tuple + from transformers import pipeline from adaptive_classifier import AdaptiveClassifier diff --git a/sources/speech_to_text.py b/sources/speech_to_text.py index 92f50b3..c554c8c 100644 --- a/sources/speech_to_text.py +++ b/sources/speech_to_text.py @@ -1,4 +1,5 @@ from colorama import Fore +from typing import List, Tuple, Type, Dict, Tuple import queue import threading import numpy as np diff --git a/sources/text_to_speech.py b/sources/text_to_speech.py index 14d4dab..9087fb2 100644 --- a/sources/text_to_speech.py +++ b/sources/text_to_speech.py @@ -1,30 +1,33 @@ +import re +import platform +import subprocess +from sys import modules +from typing import List, Tuple, Type, Dict, Tuple + from kokoro import KPipeline from IPython.display import display, Audio import soundfile as sf -import subprocess -import re -import platform -from sys import modules class Speech(): """ Speech is a class for generating speech from text. """ - def __init__(self, enable: bool = True, language: str = "english") -> None: + def __init__(self, enable: bool = True, language: str = "en", voice_idx: int = 0) -> None: self.lang_map = { - "english": 'a', - "chinese": 'z', - "french": 'f' + "en": 'a', + "zh": 'z', + "fr": 'f' } self.voice_map = { - "english": ['af_alloy', 'af_bella', 'af_kore', 'af_nicole', 'af_nova', 'af_sky', 'am_echo', 'am_michael', 'am_puck'], - "chinese": ['zf_xiaobei', 'zf_xiaoni', 'zf_xiaoxiao', 'zf_xiaoyi', 'zm_yunjian', 'zm_yunxi', 'zm_yunxia', 'zm_yunyang'], - "french": ['ff_siwis'] + "en": ['af_kore', 'af_bella', 'af_alloy', 'af_nicole', 'af_nova', 'af_sky', 'am_echo', 'am_michael', 'am_puck'], + "zh": ['zf_xiaobei', 'zf_xiaoni', 'zf_xiaoxiao', 'zf_xiaoyi', 'zm_yunjian', 'zm_yunxi', 'zm_yunxia', 'zm_yunyang'], + "fr": ['ff_siwis'] } self.pipeline = None + self.language = language if enable: self.pipeline = KPipeline(lang_code=self.lang_map[language]) - self.voice = self.voice_map[language][2] + self.voice = self.voice_map[language][voice_idx] self.speed = 1.2 def speak(self, sentence: str, voice_number: int = 1 , audio_file: str = 'sample.wav'): @@ -38,7 +41,7 @@ class Speech(): if not self.pipeline: return sentence = self.clean_sentence(sentence) - self.voice = self.voice_map["english"][voice_number] + self.voice = self.voice_map[self.language][voice_number] generator = self.pipeline( sentence, voice=self.voice, speed=self.speed, split_pattern=r'\n+'