返回提交历史
Modified
g4f/client/helper.py
+2
-2
Modified
g4f/client/stubs.py
+2
-2
XFEstudio/gpt4free
fix: Rename misspelled parameter "allowd_types" to "allowed_types"
- In **g4f/client/helper.py**, update the `filter_markdown` function by renaming the parameter from `allowd_types` to `allowed_types` and modifying its corresponding conditional check. - In **g4f/client/stubs.py**, update the `save` method in `ChatCompletionMessage` by renaming the parameter from `allowd_types` to `allowed_types` and adjusting the call to `filter_markdown` accordingly.
b1f01d46
代码差异
2 个文件
+4
-4
@@ -5,7 +5,7 @@ import logging
5
5
6
6
from typing import AsyncIterator, Iterator, AsyncGenerator, Optional
7
7
8
def filter_markdown(text: str, allowd_types=None, default=None) -> str:
8
def filter_markdown(text: str, allowed_types=None, default=None) -> str:
9
9
"""
10
10
Parses code block from a string.
11
11
@@ -17,7 +17,7 @@ def filter_markdown(text: str, allowd_types=None, default=None) -> str:
17
17
"""
18
18
match = re.search(r"```(.+)\n(?P<code>[\S\s]+?)(\n```|$)", text)
19
19
if match:
20
if allowd_types is None or match.group(1) in allowd_types:
20
if allowed_types is None or match.group(1) in allowed_types:
21
21
return match.group("code")
22
22
return default
23
23
@@ -121,7 +121,7 @@ class ChatCompletionMessage(BaseModel):
121
121
def serialize_content(self, content: str):
122
122
return str(content)
123
123
124
def save(self, filepath: str, allowd_types = None):
124
def save(self, filepath: str, allowed_types = None):
125
125
if hasattr(self.content, "data"):
126
126
os.rename(self.content.data.replace("/media", get_media_dir()), filepath)
127
127
return
@@ -129,7 +129,7 @@ class ChatCompletionMessage(BaseModel):
129
129
with open(filepath, "wb") as f:
130
130
f.write(extract_data_uri(self.content))
131
131
return
132
content = filter_markdown(self.content, allowd_types)
132
content = filter_markdown(self.content, allowed_types)
133
133
if content is not None:
134
134
with open(filepath, "w") as f:
135
135
f.write(content)