COMMENT
🤖️ ChatGPT Siri 1.2.5
🌐 Author Site:
https://github.com/Yue-Yang/ChatGPT-Siri
⚠️ OpenAI API key acquisition steps:
1. Log in to https://platform.openai.com
2. Click on the avatar in the upper right corner and select "View API keys"
3. Click the "Create new secret key" button on the right side to generate API key
4. Copy the API key and paste it into the text box below
TEXT
Text

Text
VARIABLES
Set variable
API-key
to
Text
TEXT
I am here, always at your service!

Text
VARIABLES
Set variable
welcome-text
to
Text
TEXT
I have finished answering, please continue.

Text
VARIABLES
Set variable
continue-text
to
Text
TEXT
Quit chat

Text
VARIABLES
Set variable
exit-command
to
Text
TEXT
Okay, bye!

Text
VARIABLES
Set variable
exit-text
to
Text
TEXT
New chat

Text
VARIABLES
Set variable
new-chat-command
to
Text
TEXT
Ok, it's a pleasure to serve you again!

Text
VARIABLES
Set variable
new-chat-welcome-text
to
Text
DATE
Current Date

Date
TEXT
You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible. Knowledge cutoff: Sep 2021.

Text
VARIABLES
Set variable
system-message
to
Text
LIST

List
SCRIPTING
Get
First Item
from
List

Item from List
SCRIPTING
If
Item from List
is
gpt-4
NUMBER
512

Number
VARIABLES
Set variable
max-tokens
to
Number
SCRIPTING
Otherwise
NUMBER
1024

Number
VARIABLES
Set variable
max-tokens
to
Number
SCRIPTING
End If

If Result
DICTIONARY

Dictionary
VARIABLES
Set variable
request-body
to
Dictionary
TEXT
⚠️ API key invalid!

Text
VARIABLES
Set variable
error-tittle
to
Text
TEXT
The API key is not set or set incorrectly.
Would you like to open this Shortcut‘s tutorial page?

Text
VARIABLES
Set variable
error-message
to
Text
SCRIPTING
If
API-key
begins with
sk-
SCRIPTING
Repeat
100 times

Repeat Results
SCRIPTING
If
Repeat Index
is
1
VARIABLES
Set variable
input-tittle
to
welcome-text
SCRIPTING
If
Shortcut Input
has any value
VARIABLES
Set variable
shortcut-input
to
Shortcut Input
SCRIPTING
If
shortcut-input
is
new-chat-command
TEXT
Text

Text
VARIABLES
Set variable
shortcut-input
to
Text
VARIABLES
Set variable
input-tittle
to
new-chat-welcome-text
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
VARIABLES
Set variable
input-tittle
to
continue-text
SCRIPTING
End If

If Result
SCRIPTING
Ask
input-tittle
Default Answer
[{'class': 'magic', 'value': 'shortcut-input', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}]

Provided Input
TEXT
Text

Text
VARIABLES
Set variable
shortcut-input
to
Text
VARIABLES
Set variable
user-input
to
Provided Input
SCRIPTING
If
user-input
is
exit-command
SCRIPTING
Show
exit-text
SCRIPTING
Exit shortcut with
Result
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
SCRIPTING
If
user-input
is
new-chat-command
SHORTCUTS
Run
AI 助手
Input
new-chat-command

Shortcut Result
SCRIPTING
Exit shortcut with
Result
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
DICTIONARY

Dictionary
VARIABLES
Set variable
user-message
to
Dictionary
SCRIPTING
Get
Value
for
messages
in
request-body

Dictionary Value
VARIABLES
Set variable
request-messages
to
Dictionary Value
VARIABLES
Add
user-message
to
request-messages
SCRIPTING
Set
messages
to
request-messages
in
Dictionary

Dictionary
VARIABLES
Set variable
request-body
to
Dictionary
VARIABLES
Set variable
user-input-time
to
Current Date
URL
https://api.openai.com/v1/chat/completions

URL
NETWORK
Get contents of
URL
Options Under Construction

Contents of URL
SCRIPTING
If
Contents of URL
does not contain
"choices":
SCRIPTING
Get
Value
for
error.type
in
Contents of URL

Dictionary Value
SCRIPTING
Get
Value
for
error.code
in
Contents of URL

Dictionary Value
SCRIPTING
Get
Value
for
error.message
in
Contents of URL

Dictionary Value
TEXT
Dictionary Value
:
Dictionary Value
Dictionary Value

Text
SCRIPTING
Show alert
Request Error
SCRIPTING
Exit shortcut with
Result
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
SCRIPTING
Get
Value
for
choices.1.message
in
Contents of URL

Dictionary Value
VARIABLES
Set variable
response-message
to
Dictionary Value
SCRIPTING
Get
Value
for
content
in
response-message

Dictionary Value
SCRIPTING
Get
Value
for
usage
in
Contents of URL

Dictionary Value
VARIABLES
Set variable
usage-dictionary
to
Dictionary Value
VARIABLES
Set variable
chatgpt-output
to
Dictionary Value
VARIABLES
Set variable
chatgpt-output-time
to
Current Date
SCRIPTING
If
Repeat Index
is
1
TEXT
©️ChatGPT Shortcut 1.2.5 made by Yue Yang with ❤️, powered by OpenAI ChatGPT API gpt-3.5-turbo & gpt-4 model.
Website: https://github.com/Yue-Yang/ChatGPT-Siri
Twitter: @YueYangDev WeChat: YueYangDev
--------------------------------
💻 model:
Item from List
system-message

Text
TEXT
/ChatGPT-log/
Current Date
/
Current Date
.txt

Text
VARIABLES
Set variable
chat-file-name
to
Text
DOCUMENTS
Append
Text
File Path
[{'class': 'magic', 'value': 'chat-file-name', 'glyph': 'assets/cat/Variable.svg', 'UUID': ''}]

Appended File
SCRIPTING
Otherwise
SCRIPTING
End If

If Result
SCRIPTING
Get
Value
for
prompt_tokens
in
usage-dictionary

Dictionary Value
SCRIPTING
Get
Value
for
completion_tokens
in
usage-dictionary

Dictionary Value
SCRIPTING
Get
Value
for
total_tokens
in
usage-dictionary

Dictionary Value