Skip to content

Commit

Permalink
Merge pull request #21 from NexaAI/david/bugfix
Browse files Browse the repository at this point in the history
David/bugfix
  • Loading branch information
zhiyuan8 authored Aug 21, 2024
2 parents 3ba8f7c + a188fd4 commit aca455c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 7 additions & 5 deletions nexa/gguf/nexa_inference_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,21 @@ def run(self):
generated_text += delta

if self.chat_format:
self.conversation_history.append(
{"role": "assistant", "content": generated_text}
)
if len(self.conversation_history) >= 2:
self.conversation_history = self.conversation_history[2:]

self.conversation_history.append({"role": "user", "content": user_input})
self.conversation_history.append({"role": "assistant", "content": generated_text})
except KeyboardInterrupt:
pass
except Exception as e:
logging.error(f"Error during generation: {e}", exc_info=True)
print("\n")

def _chat(self, user_input: str) -> Iterator:
self.conversation_history.append({"role": "user", "content": user_input})
current_messages = self.conversation_history + [{"role": "user", "content": user_input}]
return self.model.create_chat_completion(
messages=self.conversation_history,
messages=current_messages,
temperature=self.params["temperature"],
max_tokens=self.params["max_new_tokens"],
top_k=self.params["top_k"],
Expand Down
2 changes: 1 addition & 1 deletion nexa/gguf/nexa_inference_vlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(self, model_path, stop_words=None, **kwargs):
)
exit(1)
else:
logging.error("Using model from hub is not supported yet.")
logging.error("VLM user model from hub is not supported yet.")
exit(1)

if self.downloaded_path is None:
Expand Down
4 changes: 3 additions & 1 deletion nexa/gguf/nexa_inference_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
NEXA_RUN_MODEL_MAP_VOICE,
)
from nexa.general import pull_model
from nexa.utils import SpinningCursorAnimation, nexa_prompt, suppress_stdout_stderr
from nexa.utils import nexa_prompt
from faster_whisper import WhisperModel
from nexa.utils import nexa_prompt, SpinningCursorAnimation, suppress_stdout_stderr

logging.basicConfig(level=logging.INFO)

Expand Down

0 comments on commit aca455c

Please sign in to comment.