mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-27 05:04:19 +03:00
Add aliases to gui arguments, fix logs variable
This commit is contained in:
parent
8f3fbee0d8
commit
6e674ca33d
@ -6,6 +6,7 @@ last_provider: ProviderType = None
|
|||||||
last_model: str = None
|
last_model: str = None
|
||||||
version: str = None
|
version: str = None
|
||||||
log_handler: callable = print
|
log_handler: callable = print
|
||||||
|
logs: list = []
|
||||||
|
|
||||||
def log(text):
|
def log(text):
|
||||||
if logging:
|
if logging:
|
||||||
|
@ -1060,7 +1060,6 @@ a:-webkit-any-link {
|
|||||||
|
|
||||||
.log {
|
.log {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.log.hidden {
|
.log.hidden {
|
||||||
|
@ -2,8 +2,12 @@ from argparse import ArgumentParser
|
|||||||
|
|
||||||
def gui_parser():
|
def gui_parser():
|
||||||
parser = ArgumentParser(description="Run the GUI")
|
parser = ArgumentParser(description="Run the GUI")
|
||||||
parser.add_argument("-host", type=str, default="0.0.0.0", help="hostname")
|
parser.add_argument("--host", type=str, default="0.0.0.0", help="hostname")
|
||||||
parser.add_argument("-port", type=int, default=8080, help="port")
|
parser.add_argument_alias('-h', '--host')
|
||||||
parser.add_argument("-debug", action="store_true", help="debug mode")
|
parser.add_argument("--port", type=int, default=8080, help="port")
|
||||||
|
parser.add_argument_alias('-p', '--port')
|
||||||
|
parser.add_argument("--debug", action="store_true", help="debug mode")
|
||||||
|
parser.add_argument_alias('-d', '--debug')
|
||||||
|
parser.add_argument_alias('-debug', '--debug')
|
||||||
parser.add_argument("--ignore-cookie-files", action="store_true", help="Don't read .har and cookie files.")
|
parser.add_argument("--ignore-cookie-files", action="store_true", help="Don't read .har and cookie files.")
|
||||||
return parser
|
return parser
|
@ -142,10 +142,10 @@ class Api:
|
|||||||
|
|
||||||
def _create_response_stream(self, kwargs: dict, conversation_id: str, provider: str) -> Iterator:
|
def _create_response_stream(self, kwargs: dict, conversation_id: str, provider: str) -> Iterator:
|
||||||
if debug.logging:
|
if debug.logging:
|
||||||
logs = []
|
debug.logs = []
|
||||||
print_callback = debug.log_handler
|
print_callback = debug.log_handler
|
||||||
def log_handler(text: str):
|
def log_handler(text: str):
|
||||||
logs.append(text)
|
debug.logs.append(text)
|
||||||
print_callback(text)
|
print_callback(text)
|
||||||
debug.log_handler = log_handler
|
debug.log_handler = log_handler
|
||||||
try:
|
try:
|
||||||
@ -176,10 +176,10 @@ class Api:
|
|||||||
yield self._format_json("content", str(ImageResponse(images, chunk.alt)))
|
yield self._format_json("content", str(ImageResponse(images, chunk.alt)))
|
||||||
elif not isinstance(chunk, FinishReason):
|
elif not isinstance(chunk, FinishReason):
|
||||||
yield self._format_json("content", str(chunk))
|
yield self._format_json("content", str(chunk))
|
||||||
if logs:
|
if debug.logs:
|
||||||
for log in logs:
|
for log in debug.logs:
|
||||||
yield self._format_json("log", str(log))
|
yield self._format_json("log", str(log))
|
||||||
logs = []
|
debug.logs = []
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
yield self._format_json('error', get_error_message(e))
|
yield self._format_json('error', get_error_message(e))
|
||||||
|
Loading…
Reference in New Issue
Block a user