ShareShortcuts

View or continue Gemini conversation

twilsonco
Создать форк «View or continue Gemini conversation»

Создали что-то новое на основе этой команды? Поделитесь ей как форком: она станет вашей собственной командой, которой вы управляете, а обе страницы будут ссылаться друг на друга, чтобы twilsonco получил(а) признание.

  1. 1Получите команду и измените её в приложении «Быстрые команды». Дайте ей собственное название.
  2. 2Поделись ею из приложения «Быстрые команды» и скопируй ссылку iCloud.
  3. 3Вернись сюда, вставь ссылку и опиши, что изменилось, например: «Добавлен шаг, который использует Apple Intelligence для персонализации текста».
Загрузки
26K
Сохранено
0
Действия
216
Категория
API
Версия
1.0
Язык
EN

Просмотр

Easily view or continue conversations logged with the “Gemini via API” shortcut.

Optionally uses free actions provided by the Toolbox Pro app to provide the pretty menus. Can be disabled during install if you don't want them

Что нового

Версия 1.0

First release

История версий
1.0 9 фев 2024 г.

First release

Что делает

Действий: 216
  1. Comment
    Gemini conversation viewer Tim Wilson, December 2023 Easily view or continue conversations logged with the “Gemini via API” shortcut. https://routinehub.co/shortcut/17624/
  2. Comment
    Prepare dictionary of logged conversations
  3. Comment
    Set whether large preview of image for image-based conversations should be shown. 0 for no, 1 for yes to show large preview
  4. Number
  5. Set Variable
    ShowLargeImagePreview
  6. Comment
    Set whether the free Toolbox Pro app should be used (and must therefore be installed) to show image thumbnails for image conversations in conversation list. 1 to use Toolbox Pro, 0 to not use it. If not used, large image preview will be shown regard…
  7. Number
  8. Set Variable
    UseTBP
  9. Comment
    Check for shortcut updates
  10. Nothing
  11. Comment
    【Auto-Update Routine】 Checks For Latest Shortcut Version ↳ https://routinehub.co/shortcut/16590/
  12. Dictionary
  13. Get Dictionary Value
  14. If
  15. Get IP Address
  16. If
  17. Get Contents of URL
    https://routinehub.co/api/v1/shortcuts/…/versions/latest
  18. If
  19. Split Text
  20. Repeat with Each
  21. Calculate Expression
  22. Set Variable
    Latest Version
  23. Split Text
  24. Repeat with Each
  25. Calculate Expression
  26. Set Variable
    Current Version
  27. If
  28. Choose from Menu
    New Version: … Release: … Whats New: "…"
  29. Choose from Menu
    Update → Result (Version)
  30. Expand URL
  31. Replace Text
  32. Open URLs
  33. Stop This Shortcut
  34. Choose from Menu
    Skip (Info (Version))
  35. Comment
    【Auto-Update Routine Ends Here】 Support → https://www.reddit.com/r/shortcuts/comments/18j4f9p/ 【⚙️】 Convert Semantic Number to Decimals ↳ https://routinehub.co/shortcut/16589/
  36. Nothing
  37. Comment
    Begin dependency check (using “Check-install dependencies (v1)” by Tim Wilson: https://routinehub.co/shortcut/17694/) Dictionary of dependencies, where each: * Key is the name fo the shortcut (used to check if install, so much match perfectly), and …
  38. Dictionary
  39. Get My Shortcuts
  40. Repeat with Each
  41. Filter Files
  42. If
  43. Get IP Address
  44. If
  45. Show Result
  46. If
  47. Show Result
  48. Get Dictionary Value
  49. Set Variable
    URL
  50. Match Text
  51. If
  52. Get Contents of URL
    https://routinehub.co/api/v1/shortcuts/…/versions/latest
  53. Expand URL
  54. Set Variable
    URL
  55. Replace Text
  56. Open URLs
  57. Stop This Shortcut
  58. Nothing
  59. Comment
    End dependency check
  60. Number
  61. Number
  62. Number
  63. Nothing
  64. Set Variable
    ConvoDict
  65. Set Variable
    ImageDict
  66. If
  67. Get Device Details
  68. If
  69. Run Shell Script
  70. Set Variable
    UseTBP
  71. If
  72. Set Variable
    ShowLargeImagePreview
  73. Create Folder
  74. Get Contents of Folder
  75. Filter Files
  76. Repeat with Each
  77. Replace Text
  78. If
  79. Get Dictionary from Input
  80. Split Text
  81. Get Item from List
  82. Set Dictionary Value
  83. Set Dictionary Value
  84. Text
  85. Set Dictionary Value
  86. Set Variable
    ConvoDict
  87. Add to Variable
  88. If
  89. Base64 Encode
  90. Set Dictionary Value
  91. Set Variable
    ImageDict
  92. Comment
    Exit if there are no conversations
  93. Count
  94. If
  95. Show Result
  96. Stop This Shortcut
  97. Count
  98. If
  99. Set Variable
    UseTBP
  100. Comment
    Prepare menu of conversations to choose from
  101. If
  102. Get Device Details
  103. If
  104. Text
  105. If
  106. Text
  107. Create Menu
    com.alexhay.ToolboxProForShortcuts
  108. Add to Variable
  109. Repeat with Each
  110. Split Text
  111. Get Item from List
  112. Replace Text
  113. Get Dictionary Value
  114. If
  115. Get Dictionary Value
  116. Base64 Encode
  117. Resize Image
  118. Create Menu
    com.alexhay.ToolboxProForShortcuts
  119. If
  120. Create Menu
    com.alexhay.ToolboxProForShortcuts
  121. Add to Variable
  122. Add to Variable
  123. If
  124. Text
  125. Add to Variable
  126. Add to Variable
  127. Set Variable
    DeleteList
  128. Repeat
  129. Choose from List
  130. If
  131. Get Menu Item
    com.alexhay.ToolboxProForShortcuts
  132. Text
  133. If
  134. Text
  135. If
  136. Choose from List
  137. Get Contents of Folder
  138. Repeat with Each
  139. If
  140. Get Menu Item
    com.alexhay.ToolboxProForShortcuts
  141. Text
  142. If
  143. Text
  144. Get Dictionary Value
  145. Get Dictionary Value
  146. Repeat with Each
  147. If
  148. Add to Variable
  149. Delete Files
  150. Run Shortcut
    View or continue Gemini conversation
  151. Stop This Shortcut
  152. Get Dictionary Value
  153. Set Variable
    ChosenConvo
  154. Get Dictionary Value
  155. If
  156. Text
  157. If
  158. Replace Text
  159. Text
  160. Set Variable
    ConvoStr
  161. Repeat with Each
  162. Text
  163. Set Variable
    ConvoStr
  164. Get Dictionary Value
  165. Repeat with Each
  166. Text
  167. Set Variable
    ConvoStr
  168. Text
  169. Set Variable
    ConvoStr
  170. Show Result
  171. If
  172. Get Dictionary Value
  173. If
  174. Set Variable
    Image
  175. If
  176. Base64 Encode
  177. Show Result
  178. If
  179. Text
  180. Quick Menu2
    com.alexhay.ToolboxProForShortcuts
  181. Choose from List
  182. Set Variable
    UserChoice
  183. If
  184. List
  185. Choose from List
  186. Set Variable
    UserChoice
  187. If
  188. Dictionary
  189. If
  190. Set Dictionary Value
  191. Run Shortcut
    Gemini via API
  192. If
  193. Set Dictionary Value
  194. Run Shortcut
    Gemini via API
  195. Stop This Shortcut
  196. If
  197. Get Dictionary Value
  198. Get Contents of Folder
  199. Set Variable
    DeleteList
  200. Repeat with Each

Посмотреть как код
Бета

Все действия этой команды, записанные на Cherri — языке программирования для приложения «Быстрые команды». Отлично подходит, чтобы разобраться, как она работает.

#define mac true
#include 'actions/web'
#include 'actions/network'
#define color lightblue
#define glyph noteText

/*
Gemini conversation viewer
Tim Wilson, December 2023

Easily view 
or continue conversations logged with the “Gemini via API” shortcut. https://routinehub.co/shortcut/17624/
*/
// Prepare dictionary of logged conversations

// Set whether large preview of image for image-based conversations should be shown. 0 for no, 1 for yes to show large preview

@ShowLargeImagePreview = 1
// Set whether the free Toolbox Pro app should be used (and must therefore be installed) to show image thumbnails for image conversations in conversation list. 1 to use Toolbox Pro, 0 to not use it. If not used, large image preview will be shown regardless.

@UseTBP = 1
// Check for shortcut updates

nothing()
/*
【Auto-Update Routine】
Checks For Latest Shortcut Version
↳ https://routinehub.co/shortcut/16590/
*/
const Info = {
	"Author": "twilsonco",
	"RoutineHub ID": 17671,
	"Version": "1.4.0",
	"Version Check": true
}
const True = getValue(Info, "Version Check")

if True == "Yes" {
	const CurrentIPAddress = getExternalIP("IPv4")
	if CurrentIPAddress {
		const Result = downloadURL("https://routinehub.co/api/v1/shortcuts/{Info['RoutineHub ID']}/versions/latest")
		if Result contains "success" {
			const SplitText = splitText(Result['Version'], ".")
			for _ in SplitText {
				@LatestVersion = ((1/1000)^@RepeatIndex)*@RepeatItem+@LatestVersion
			}
			const SplitText1 = splitText(Info['Version'], ".")
			for _ in SplitText1 {
				@CurrentVersion = ((1/1000)^@RepeatIndex)*@RepeatItem+@CurrentVersion
			}
			if @LatestVersion > @CurrentVersion {
				menu "New Version: {Result['Version']}\nRelease: {Result['Release']}\nWhats New: \"{Result['Notes']}\"" {
				item "Update → {Result['Version']}":
					expandURL(Result['URL'])
					const UpdatedText = replaceText("https://www.icloud.com/", "shortcuts://", false)
					openURL(UpdatedText)
					stop()
				item "Skip ({Info['Version']})":
				}
			}
		}
	}
}
/*
【Auto-Update Routine Ends Here】
Support → https://www.reddit.com/r/shortcuts/comments/18j4f9p/

【⚙️】
Convert Semantic Number to Decimals
↳ https://routinehub.co/shortcut/16589/
*/
nothing()
/*
Begin dependency check
(using “Check-install dependencies (v1)” by Tim Wilson: https://routinehub.co/shortcut/17694/)

Dictionary of dependencies, where each:
* Key is the name fo the shortcut (used to check if install, so much match perfectly), and each value is either:
  * The RoutineHub ID (number), or
  * The URL (text type; iCloud link to shortcut or some other URL)
*/
const DependencyDict = {
	"Gemini via API": 17624
}
const FullShortcutList = getShortcuts()

for _ in DependencyDict['Keys'] {
	const Files = filterFiles(FullShortcutList, 1, "Last Modified Date", "Latest First")
	if !Files {
		const CurrentIPAddress1 = getExternalIP()
		if !CurrentIPAddress1 {
			show("This shortcut depends on the \"{@RepeatItem}\" shortcut, which was not found (by name) in your installed Shortcuts. You need to be connected to the internet in order to install it. Please connect and try again.")
		} else {
			show("This shortcut depends on the \"{@RepeatItem}\" shortcut, which was not found (by name) in your installed Shortcuts. Contiunue to install it now, then try this Shortcut again.")
			@URL = DependencyDict[@RepeatItem]
			const Matches = containsText(DependencyValue, "^[0-9]+$")
			if Matches {
				const Result1 = downloadURL("https://routinehub.co/api/v1/shortcuts/{DependencyValue}/versions/latest")
				expandURL(Result1['URL'])
				@URL
			}
			const UpdatedText1 = replaceText("https://www.icloud.com/", "shortcuts://", @URL, false)
			openURL(UpdatedText1)
		}
		stop()
	}
}
nothing()
// End dependency check

const Number = 1000
nothing()
@ConvoDict
@ImageDict

if @UseTBP ==  {
	const DeviceModel = getDeviceDetail("Device Model")
	if DeviceModel == "Mac" {
		runShellScript("if [[ $(uname -m) == 'arm64' ]]; then\n  echo 1\nelse\n  echo 0\nfi", DeviceModel)
		@UseTBP
	}
}

if @UseTBP == 0 {
	@ShowLargeImagePreview = True1
}
createFolder("GeminiAPI")
const ContentsOfFolder = getFolderContents()
const Files1 = filterFiles(ContentsOfFolder, "Last Modified Date", "Latest First")

for _ in Files1 {
	const UpdatedText2 = replaceText(".{@RepeatItem['File Extension']}", "", @RepeatItem['File Path'])
	if @RepeatItem == "txt" {
		const Dictionary = getDictionary(@RepeatItem)
		const SplitText2 = splitText(UpdatedText2, "/")
		getListItems(SplitText2, 0, 0)
		const Dictionary1 = setValue(Dictionary, "datetime")
		setValue(Dictionary1, "filename", UpdatedText2)
		setValue(@ConvoDict)
		@ConvoDict
		@SortedKeys
	} else {
		base64Encode(@RepeatItem)
		setValue(@ImageDict, UpdatedText2)
		@ImageDict
	}
}
// Exit if there are no conversations

const Count = count(@ConvoDict)

if Count == 0 {
	show("There are no saved Gemini Pro conversations")
	stop()
}
const Count1 = count(@ImageDict)

if Count1 == 0 {
	@UseTBP = False
}
// Prepare menu of conversations to choose from


if @UseTBP ==  {
	const CurrentAppearance = getDeviceDetail("Current Appearance")
	if CurrentAppearance['Dark Mode Is On'] ==  {
	} else {
	}
	rawAction("com.alexhay.ToolboxProForShortcuts.CreateMenuIntent", {
		"bgTransparencyEmoji": 0.32798823714256287,
		"customIconType": "emoji",
		"defaultBGColour": "Pink",
		"defaultIcons": "delete",
		"defaultScale": "0.7",
		"emojiBG": "{BackgroundColor}",
		"emojiName": "❌",
		"field1": "Delete conversations",
		"title": "Delete conversation(s)"
	})
	@ChooseList
	for _ in @SortedKeys {
		const SplitText3 = splitText(@RepeatItem, " - ")
		getRandomItem(SplitText3)
		replaceText("{} - ", "", @RepeatItem)
		if @ImageDict contains ['filename'] {
			const DictionaryValue = getValue(@ImageDict, ['filename'])
			const Base64Encoded = base64Encode(DictionaryValue)
			const ResizedImage = resizeImageByLongestEdge(Base64Encoded, "123")
			rawAction("com.alexhay.ToolboxProForShortcuts.CreateMenuIntent", {
				"base64": "{DictionaryValue}",
				"customIcon": "ResizedImage",
				"customIconType": "customImage",
				"defaultScale": "0.7",
				"field1": "{@RepeatItem}",
				"field2": "{@RepeatIndex}",
				"subtitle": "{}",
				"title": "{}"
			})
		} else {
			rawAction("com.alexhay.ToolboxProForShortcuts.CreateMenuIntent", {
				"base64": "{DictionaryValue}",
				"bgTransparencyEmoji": 0.2794468091881793,
				"customIconType": "emoji",
				"defaultScale": "0.7",
				"emojiBG": "{BackgroundColor}",
				"emojiName": "💬",
				"field1": "{@RepeatItem}",
				"field2": "{@RepeatIndex}",
				"subtitle": "{}",
				"title": "{}"
			})
		}
		@ChooseList
		@DeleteList
	}
} else {
	@ChooseList += "❌ Delete conversation(s)"
	@ChooseList = @SortedKeys
	@DeleteList = @SortedKeys
}

repeat _ for Number {
	const ChosenItem = chooseFromList(@ChooseList, "Please select")
	if @UseTBP ==  {
		rawAction("com.alexhay.ToolboxProForShortcuts.GetMenuItemIntent", {
			"menuItem": "ChosenItem"
		})
	} else {
	}
	if ChosenItem1 contains "Delete conversation" {
		const ChosenItem2 = chooseFromList(@DeleteList, "Select conversations to delete", true)
		const ContentsOfFolder1 = getFolderContents()
		for _ in ChosenItem2 {
			if @UseTBP ==  {
				rawAction("com.alexhay.ToolboxProForShortcuts.GetMenuItemIntent", {
					"menuItem": "@RepeatItem2"
				})
			} else {
			}
			const DictionaryValue1 = getValue(@ConvoDict, DeleteItem)
			const DeleteFileName = DictionaryValue1['filename']
			for _ in ContentsOfFolder1 {
				if @RepeatItem3 contains DeleteFileName {
					@DeleteList = @RepeatItem3
				}
			}
		}
		deleteFiles(@DeleteList, true)
		runSelf()
		stop()
	}
	@ChosenConvo = @ConvoDict[ChosenItem1]
	const Messages = getValue(@ChosenConvo, "messages")
	if @UseTBP ==  {
	} else {
		replaceText(" ", " ", ChosenItem)
	}
	@ConvoStr = "{}"
	for _ in Messages {
		@ConvoStr = "{@ConvoStr}\n\n==========\n\n{@RepeatItem2['role']}:"
		const DictionaryValue2 = getValue(@RepeatItem2, "parts")
		for _ in DictionaryValue2 {
			@ConvoStr = "{@ConvoStr}\n{@RepeatItem3['text']}"
		}
		@ConvoStr = "{@ConvoStr}"
	}
	show(@ConvoStr)
	if @ImageDict contains @ChosenConvo['filename'] {
		const DictionaryValue3 = getValue(@ImageDict, @ChosenConvo['filename'])
		if DictionaryValue3 {
			@Image = DictionaryValue3
			if @ShowLargeImagePreview ==  {
				base64Encode(DictionaryValue3)
				show()
			}
		}
	}
	if @UseTBP ==  {
		rawAction("com.alexhay.ToolboxProForShortcuts.QuickMenu2Intent", {
			"text": "{}"
		})
		chooseFromList(MenuItems, "Select action")
		@UserChoice = ['title']
	} else {
		const List = list("Continue conversation", "Delete conversation", "Go back to conversation list")
		chooseFromList(List, "Select action")
		@UserChoice
	}
	if @UserChoice contains "Continue" {
		const Dictionary2 = {
			"datetime": "{['datetime']}",
			"repeat": "1"
		}
		if @Image {
			const Dictionary3 = setValue(Dictionary2, "image", @Image)
			run("Gemini via API", Dictionary3)
		} else {
			const Dictionary4 = setValue(Dictionary2, "messages", Messages)
			run("Gemini via API", Dictionary4)
		}
		stop()
	}
	if @UserChoice contains "Delete" {
		const CheckFilePath = @ChosenConvo['filename']
		const ContentsOfFolder2 = getFolderContents()
		@DeleteList
		for _ in ContentsOfFolder2 {
			if @RepeatItem2 contains CheckFilePath {
				@DeleteList = @RepeatItem2
			}
		}
		deleteFiles(@DeleteList, true)
		@NewChooseList
		for _ in @ChooseList {
			if @UseTBP ==  {
				rawAction("com.alexhay.ToolboxProForShortcuts.GetMenuItemIntent", {
					"menuItem": "@RepeatItem2"
				})
				if MenuItemDetail['field2'] != ['field2'] {
					@NewChooseList = @RepeatItem2
				}
			} else {
				if @RepeatItem2 != ChosenItem {
					@NewChooseList = @RepeatItem2
				}
			}
		}
		if @NewChooseList {
			@ChooseList = @NewChooseList
		} else {
			stop()
		}
	}
}
Декомпилировано с помощью cherri 2.3.0 (GPL-2.0). Перед компиляцией могут понадобиться небольшие исправления.

Оценки и отзывы

Написать отзыв
–
из 5
★★★★★
★★★★
★★★
★★
★
0 ratings

Пока нет отзывов. Поделись мнением первым!

Реклама

Ещё от twilsonco

См. все

Вам также может понравиться

См. все
Реклама