mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-28 11:07:24 +03:00
Merge pull request #2381 from hlohaus/info
Add aliases to gui arguments, fix logs variable
This commit is contained in:
commit
a0f3ea1443
@ -6,6 +6,7 @@ last_provider: ProviderType = None
|
||||
last_model: str = None
|
||||
version: str = None
|
||||
log_handler: callable = print
|
||||
logs: list = []
|
||||
|
||||
def log(text):
|
||||
if logging:
|
||||
|
@ -1060,7 +1060,6 @@ a:-webkit-any-link {
|
||||
|
||||
.log {
|
||||
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 {
|
||||
|
@ -2,8 +2,12 @@ from argparse import ArgumentParser
|
||||
|
||||
def gui_parser():
|
||||
parser = ArgumentParser(description="Run the GUI")
|
||||
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("-debug", action="store_true", help="debug mode")
|
||||
parser.add_argument("--host", type=str, default="0.0.0.0", help="hostname")
|
||||
parser.add_argument_alias('-h', '--host')
|
||||
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.")
|
||||
return parser
|
@ -142,10 +142,10 @@ class Api:
|
||||
|
||||
def _create_response_stream(self, kwargs: dict, conversation_id: str, provider: str) -> Iterator:
|
||||
if debug.logging:
|
||||
logs = []
|
||||
debug.logs = []
|
||||
print_callback = debug.log_handler
|
||||
def log_handler(text: str):
|
||||
logs.append(text)
|
||||
debug.logs.append(text)
|
||||
print_callback(text)
|
||||
debug.log_handler = log_handler
|
||||
try:
|
||||
@ -176,10 +176,10 @@ class Api:
|
||||
yield self._format_json("content", str(ImageResponse(images, chunk.alt)))
|
||||
elif not isinstance(chunk, FinishReason):
|
||||
yield self._format_json("content", str(chunk))
|
||||
if logs:
|
||||
for log in logs:
|
||||
if debug.logs:
|
||||
for log in debug.logs:
|
||||
yield self._format_json("log", str(log))
|
||||
logs = []
|
||||
debug.logs = []
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
yield self._format_json('error', get_error_message(e))
|
||||
|
Loading…
Reference in New Issue
Block a user