返回提交历史
Modified
g4f/debug.py
+1
-0
Modified
g4f/gui/client/static/css/style.css
+0
-1
Modified
g4f/gui/gui_parser.py
+7
-3
Modified
g4f/gui/server/api.py
+5
-5
XFEstudio/gpt4free
Add aliases to gui arguments, fix logs variable
6e674ca3
代码差异
4 个文件
+13
-9
@@ -6,6 +6,7 @@ last_provider: ProviderType = None
6
6
last_model: str = None
7
7
version: str = None
8
8
log_handler: callable = print
9
logs: list = []
9
10
10
11
def log(text):
11
12
if logging:
@@ -1060,7 +1060,6 @@ a:-webkit-any-link {
1060
1060
1061
1061
.log {
1062
1062
white-space: pre-wrap;
1063
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;
1064
1063
}
1065
1064
1066
1065
.log.hidden {
@@ -2,8 +2,12 @@ from argparse import ArgumentParser
2
2
3
3
def gui_parser():
4
4
parser = ArgumentParser(description="Run the GUI")
5
parser.add_argument("-host", type=str, default="0.0.0.0", help="hostname")
6
parser.add_argument("-port", type=int, default=8080, help="port")
7
parser.add_argument("-debug", action="store_true", help="debug mode")
5
parser.add_argument("--host", type=str, default="0.0.0.0", help="hostname")
6
parser.add_argument_alias('-h', '--host')
7
parser.add_argument("--port", type=int, default=8080, help="port")
8
parser.add_argument_alias('-p', '--port')
9
parser.add_argument("--debug", action="store_true", help="debug mode")
10
parser.add_argument_alias('-d', '--debug')
11
parser.add_argument_alias('-debug', '--debug')
8
12
parser.add_argument("--ignore-cookie-files", action="store_true", help="Don't read .har and cookie files.")
9
13
return parser
@@ -142,10 +142,10 @@ class Api:
142
142
143
143
def _create_response_stream(self, kwargs: dict, conversation_id: str, provider: str) -> Iterator:
144
144
if debug.logging:
145
logs = []
145
debug.logs = []
146
146
print_callback = debug.log_handler
147
147
def log_handler(text: str):
148
logs.append(text)
148
debug.logs.append(text)
149
149
print_callback(text)
150
150
debug.log_handler = log_handler
151
151
try:
@@ -176,10 +176,10 @@ class Api:
176
176
yield self._format_json("content", str(ImageResponse(images, chunk.alt)))
177
177
elif not isinstance(chunk, FinishReason):
178
178
yield self._format_json("content", str(chunk))
179
if logs:
180
for log in logs:
179
if debug.logs:
180
for log in debug.logs:
181
181
yield self._format_json("log", str(log))
182
logs = []
182
debug.logs = []
183
183
except Exception as e:
184
184
logger.exception(e)
185
185
yield self._format_json('error', get_error_message(e))