mirror of
https://github.com/LouisShark/chatgpt_system_prompt.git
synced 2025-07-05 14:20:33 -04:00
fixed gptparser.py
This commit is contained in:
parent
c88e5b4bee
commit
3efe0a3452
1 changed files with 11 additions and 10 deletions
|
@ -65,16 +65,8 @@ class GptMarkdownFile:
|
|||
Return the GPT identifier.
|
||||
:return: GptIdentifier object.
|
||||
"""
|
||||
url = self.fields.get('url')
|
||||
if url and url.startswith(GPT_BASE_URL):
|
||||
id = url[GPT_BASE_URL_L:].split('\n')[0]
|
||||
i = id.find('-')
|
||||
if i != -1:
|
||||
return GptIdentifier(id[:i], id[i+1:].strip())
|
||||
else:
|
||||
return GptIdentifier(id, '')
|
||||
return None
|
||||
|
||||
return parse_gpturl(self.fields.get('url'))
|
||||
|
||||
def __str__(self) -> str:
|
||||
sorted_fields = sorted(self.fields.items(), key=lambda x: SUPPORTED_FIELDS[x[0]].order)
|
||||
# Check if the field value contains the start marker of the markdown block and add a blank line before it
|
||||
|
@ -129,6 +121,15 @@ class GptMarkdownFile:
|
|||
except Exception as e:
|
||||
return (False, f"Failed to save file '{file_path}': {e}")
|
||||
|
||||
def parse_gpturl(url: str) -> Union[GptIdentifier, None]:
|
||||
if url and url.startswith(GPT_BASE_URL):
|
||||
id = url[GPT_BASE_URL_L:].split('\n')[0]
|
||||
i = id.find('-')
|
||||
if i != -1:
|
||||
return GptIdentifier(id[:i], id[i+1:])
|
||||
else:
|
||||
return GptIdentifier(id, '')
|
||||
|
||||
|
||||
def get_prompts_path() -> str:
|
||||
"""Return the path to the prompts directory."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue