mirror of
https://github.com/LouisShark/chatgpt_system_prompt.git
synced 2025-07-05 22:30:37 -04:00
Merge pull request #64 from lallouslab/fixidxtool
This commit is contained in:
commit
0ff994a810
1 changed files with 11 additions and 10 deletions
|
@ -65,16 +65,8 @@ class GptMarkdownFile:
|
||||||
Return the GPT identifier.
|
Return the GPT identifier.
|
||||||
:return: GptIdentifier object.
|
:return: GptIdentifier object.
|
||||||
"""
|
"""
|
||||||
url = self.fields.get('url')
|
return parse_gpturl(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
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
sorted_fields = sorted(self.fields.items(), key=lambda x: SUPPORTED_FIELDS[x[0]].order)
|
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
|
# 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:
|
except Exception as e:
|
||||||
return (False, f"Failed to save file '{file_path}': {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:
|
def get_prompts_path() -> str:
|
||||||
"""Return the path to the prompts directory."""
|
"""Return the path to the prompts directory."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue