Fix some error
FIX:
llm_provider.py 102: _model -> model
MOD:
utility.py 25: add windows termial color print
text_to_speech.py 29: add windows version
ADD:
add termcolor in requirements.txt
This commit is contained in:
@@ -11,7 +11,7 @@ class Provider:
|
||||
def __init__(self, provider_name, model, server_address = "127.0.0.1:5000"):
|
||||
self.provider_name = provider_name.lower()
|
||||
self.model = model
|
||||
self.server = self.check_address_format(server_address)
|
||||
self.server = self.check_address_format(server_address)
|
||||
self.available_providers = {
|
||||
"ollama": self.ollama_fn,
|
||||
"server": self.server_fn,
|
||||
@@ -25,7 +25,7 @@ class Provider:
|
||||
|
||||
def check_address_format(self, address):
|
||||
"""
|
||||
Validate if the address is valid IP.
|
||||
Validate if the address is valid IP.
|
||||
"""
|
||||
try:
|
||||
ip, port = address.rsplit(":", 1)
|
||||
@@ -35,7 +35,7 @@ class Provider:
|
||||
except ValueError as e:
|
||||
raise Exception(f"Invalid address format: {e}")
|
||||
return address
|
||||
|
||||
|
||||
def respond(self, history, verbose = True):
|
||||
"""
|
||||
Use the choosen provider to generate text.
|
||||
@@ -61,7 +61,7 @@ class Provider:
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def server_fn(self, history, verbose = True):
|
||||
"""
|
||||
Use a remote server wit LLM to generate text.
|
||||
@@ -99,12 +99,12 @@ class Provider:
|
||||
thought += chunk['message']['content']
|
||||
except ollama.ResponseError as e:
|
||||
if e.status_code == 404:
|
||||
ollama.pull(self._model)
|
||||
ollama.pull(self.model)
|
||||
if "refused" in str(e):
|
||||
raise Exception("Ollama connection failed. is the server running ?")
|
||||
raise e
|
||||
return thought
|
||||
|
||||
|
||||
def test_fn(self, history, verbose = True):
|
||||
"""
|
||||
Test function to generate text.
|
||||
@@ -121,4 +121,4 @@ class Provider:
|
||||
echo "Hello world from bash"
|
||||
```
|
||||
"""
|
||||
return thought
|
||||
return thought
|
||||
|
||||
Reference in New Issue
Block a user