Fix CLI app.py (#910)

- the bindings API changed in 057b9, but the CLI was not updated
- change 'std_passthrough' param to the renamed 'streaming'
- remove '_cli_override_response_callback' as it breaks and is no longer needed
- bump version to 0.3.4
This commit is contained in:
cosmic-snow 2023-06-16 22:06:22 +02:00 committed by GitHub
parent 68f9786ed9
commit b66d0b4fff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ SPECIAL_COMMANDS = {
"/help": lambda _: print("Special commands: /reset, /exit, /help and /clear"),
}
VERSION = "0.1.0"
VERSION = "0.3.4"
CLI_START_MESSAGE = f"""
@ -33,12 +33,6 @@ Type /help for special commands.
"""
def _cli_override_response_callback(token_id, response):
resp = response.decode("utf-8")
print(resp, end="", flush=True)
return True
# create typer app
app = typer.Typer()
@ -68,9 +62,6 @@ def repl(
else:
print(f"\nUsing {gpt4all_instance.model.thread_count()} threads", end="")
# overwrite _response_callback on model
gpt4all_instance.model._response_callback = _cli_override_response_callback
print(CLI_START_MESSAGE)
while True:
@ -103,7 +94,7 @@ def repl(
context_erase=0.0,
# required kwargs for cli ux (incremental response)
verbose=False,
std_passthrough=True,
streaming=True,
)
# record assistant's response to messages
MESSAGES.append(full_response.get("choices")[0].get("message"))
@ -112,7 +103,7 @@ def repl(
@app.command()
def version():
print("gpt4all-cli v0.1.0")
print("gpt4all-cli v0.3.4")
if __name__ == "__main__":