This commit is contained in:
Saifeddine ALOUI 2023-05-29 21:26:20 +02:00
parent 3da776d605
commit 2a6f70bd87
3 changed files with 11 additions and 8 deletions

View File

@ -369,8 +369,8 @@ class ModelProcess:
def _callback(self, text, text_type=0): def _callback(self, text, text_type=0):
try: try:
print(str(text),end="", flush=True) print(str(text), end="", flush=True)
except: except Exception as ex:
print(".") print(".")
self.curent_text += text self.curent_text += text
detected_anti_prompt = False detected_anti_prompt = False
@ -388,7 +388,7 @@ class ModelProcess:
# Stream the generated text to the main process # Stream the generated text to the main process
self.generation_queue.put((text,self.id, text_type)) self.generation_queue.put((text,self.id, text_type))
# if stop generation is detected then stop # if stop generation is detected then stop
if self.completion_signal.is_set(): if not self.completion_signal.is_set():
return True return True
else: else:
return False return False

View File

@ -82,12 +82,12 @@ class GPT4ALL(LLMBinding):
verbose (bool, optional): If true, the code will spit many informations about the generation process. Defaults to False. verbose (bool, optional): If true, the code will spit many informations about the generation process. Defaults to False.
""" """
try: try:
response_tokens = [] response_text = []
def local_callback(token_id, response): def local_callback(token_id, response):
decoded_token = response.decode('utf-8') decoded_word = response.decode('utf-8')
response_tokens.append( decoded_token ); response_text.append( decoded_word )
if new_text_callback is not None: if new_text_callback is not None:
if not new_text_callback(''.join(response_tokens)): if not new_text_callback(decoded_word):
return False return False
# Do whatever you want with decoded_token here. # Do whatever you want with decoded_token here.
@ -106,7 +106,7 @@ class GPT4ALL(LLMBinding):
) )
except Exception as ex: except Exception as ex:
print(ex) print(ex)
return ''.join(response_tokens) return ''.join(response_text)
@staticmethod @staticmethod
def get_available_models(): def get_available_models():

View File

@ -0,0 +1,3 @@
Hi there, welcome to a snippet about bindings and models selection.
In this short video we will look at bindings and models