mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
Merge branch 'main' of github.com:Fosowl/agenticSeek
This commit is contained in:
commit
e552e7cd04
@ -9,4 +9,6 @@ torch==2.5.1
|
|||||||
ollama==0.4.7
|
ollama==0.4.7
|
||||||
scipy==1.15.1
|
scipy==1.15.1
|
||||||
kokoro==0.7.12
|
kokoro==0.7.12
|
||||||
flask==3.1.0
|
flask==3.1.0
|
||||||
|
soundfile==0.13.1
|
||||||
|
termcolor
|
@ -11,7 +11,7 @@ class Provider:
|
|||||||
def __init__(self, provider_name, model, server_address = "127.0.0.1:5000"):
|
def __init__(self, provider_name, model, server_address = "127.0.0.1:5000"):
|
||||||
self.provider_name = provider_name.lower()
|
self.provider_name = provider_name.lower()
|
||||||
self.model = model
|
self.model = model
|
||||||
self.server = self.check_address_format(server_address)
|
self.server = self.check_address_format(server_address)
|
||||||
self.available_providers = {
|
self.available_providers = {
|
||||||
"ollama": self.ollama_fn,
|
"ollama": self.ollama_fn,
|
||||||
"server": self.server_fn,
|
"server": self.server_fn,
|
||||||
@ -24,7 +24,7 @@ class Provider:
|
|||||||
|
|
||||||
def check_address_format(self, address):
|
def check_address_format(self, address):
|
||||||
"""
|
"""
|
||||||
Validate if the address is valid IP.
|
Validate if the address is valid IP.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
ip, port = address.rsplit(":", 1)
|
ip, port = address.rsplit(":", 1)
|
||||||
@ -34,7 +34,7 @@ class Provider:
|
|||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise Exception(f"Invalid address format: {e}")
|
raise Exception(f"Invalid address format: {e}")
|
||||||
return address
|
return address
|
||||||
|
|
||||||
def respond(self, history, verbose = True):
|
def respond(self, history, verbose = True):
|
||||||
"""
|
"""
|
||||||
Use the choosen provider to generate text.
|
Use the choosen provider to generate text.
|
||||||
@ -60,7 +60,7 @@ class Provider:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"An error occurred: {e}")
|
print(f"An error occurred: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def server_fn(self, history, verbose = True):
|
def server_fn(self, history, verbose = True):
|
||||||
"""
|
"""
|
||||||
Use a remote server wit LLM to generate text.
|
Use a remote server wit LLM to generate text.
|
||||||
@ -103,7 +103,7 @@ class Provider:
|
|||||||
raise Exception("Ollama connection failed. is the server running ?")
|
raise Exception("Ollama connection failed. is the server running ?")
|
||||||
raise e
|
raise e
|
||||||
return thought
|
return thought
|
||||||
|
|
||||||
def test_fn(self, history, verbose = True):
|
def test_fn(self, history, verbose = True):
|
||||||
"""
|
"""
|
||||||
Test function to generate text.
|
Test function to generate text.
|
||||||
@ -120,4 +120,4 @@ class Provider:
|
|||||||
echo "Hello world from bash"
|
echo "Hello world from bash"
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
return thought
|
return thought
|
||||||
|
@ -3,6 +3,8 @@ from IPython.display import display, Audio
|
|||||||
import soundfile as sf
|
import soundfile as sf
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
|
import platform
|
||||||
|
|
||||||
|
|
||||||
class Speech():
|
class Speech():
|
||||||
def __init__(self, language = "english") -> None:
|
def __init__(self, language = "english") -> None:
|
||||||
@ -26,11 +28,16 @@ class Speech():
|
|||||||
speed=1, split_pattern=r'\n+'
|
speed=1, split_pattern=r'\n+'
|
||||||
)
|
)
|
||||||
for i, (gs, ps, audio) in enumerate(generator):
|
for i, (gs, ps, audio) in enumerate(generator):
|
||||||
audio_file = f'sample.wav'
|
audio_file = 'sample.wav'
|
||||||
|
print(audio_file)
|
||||||
display(Audio(data=audio, rate=24000, autoplay=i==0))
|
display(Audio(data=audio, rate=24000, autoplay=i==0))
|
||||||
sf.write(audio_file, audio, 24000) # save each audio file
|
sf.write(audio_file, audio, 24000) # save each audio file
|
||||||
subprocess.call(["afplay", audio_file])
|
if platform.system().lower() != "windows":
|
||||||
|
subprocess.call(["afplay", audio_file])
|
||||||
|
else:
|
||||||
|
import winsound
|
||||||
|
winsound.PlaySound(audio_file, winsound.SND_FILENAME)
|
||||||
|
|
||||||
def clean_sentence(self, sentence):
|
def clean_sentence(self, sentence):
|
||||||
sentence = re.sub(r'`.*?`', '', sentence)
|
sentence = re.sub(r'`.*?`', '', sentence)
|
||||||
sentence = re.sub(r'[^a-zA-Z0-9.,!? ]+', '', sentence)
|
sentence = re.sub(r'[^a-zA-Z0-9.,!? ]+', '', sentence)
|
||||||
|
@ -1,20 +1,37 @@
|
|||||||
|
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
from termcolor import colored
|
||||||
|
import platform
|
||||||
|
|
||||||
|
|
||||||
def pretty_print(text, color = "info"):
|
def pretty_print(text, color = "info"):
|
||||||
"""
|
"""
|
||||||
print text with color
|
print text with color
|
||||||
"""
|
"""
|
||||||
color_map = {
|
if platform.system().lower() != "windows":
|
||||||
"success": Fore.GREEN,
|
color_map = {
|
||||||
"failure": Fore.RED,
|
"success": Fore.GREEN,
|
||||||
"status": Fore.LIGHTGREEN_EX,
|
"failure": Fore.RED,
|
||||||
"code": Fore.LIGHTBLUE_EX,
|
"status": Fore.LIGHTGREEN_EX,
|
||||||
"warning": Fore.YELLOW,
|
"code": Fore.LIGHTBLUE_EX,
|
||||||
"output": Fore.LIGHTCYAN_EX,
|
"warning": Fore.YELLOW,
|
||||||
}
|
"output": Fore.LIGHTCYAN_EX,
|
||||||
if color not in color_map:
|
}
|
||||||
print(text)
|
if color not in color_map:
|
||||||
pretty_print("Invalid color in pretty_print", "warning")
|
print(text)
|
||||||
return
|
pretty_print("Invalid color in pretty_print", "warning")
|
||||||
print(color_map[color], text, Fore.RESET)
|
return
|
||||||
|
print(color_map[color], text, Fore.RESET)
|
||||||
|
else:
|
||||||
|
color_map = {
|
||||||
|
"success": "green",
|
||||||
|
"failure": "red",
|
||||||
|
"status": "light_green",
|
||||||
|
"code": "light_blue",
|
||||||
|
"warning": "yello",
|
||||||
|
"output": "cyan",
|
||||||
|
"default": "black"
|
||||||
|
}
|
||||||
|
if color not in color_map:
|
||||||
|
color = "default"
|
||||||
|
print(colored(text, color_map[color]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user