You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many of the APIs are generated with help of ChatGTP 3.5 from the AppleScript dictionary of DEVONthink 3.
23
+
Many of the APIs are generated by ChatGTP from the DEVONthink's AppleScript dictionary.
24
24
25
25
The Applescript bridging part is inspired by [py-applescript](https://github.com/rdhyee/py-applescript).
26
26
27
+
Notes used as examples are imported from [The Blue Book](https://github.com/lyz-code/blue-book), a personal wiki shared by [lyz-code](https://github.com/lyz-code).
28
+
27
29
## Installation
28
30
29
31
```bash
@@ -60,6 +62,32 @@ record = dtp3.create_record_with({
60
62
}, inbox)
61
63
```
62
64
65
+
## Work With ChatGTP
66
+
67
+
### Add Tags to Selected Records Using ChatGTP
68
+
69
+
Put the script into `~/Library/Application Scripts/com.devon-technologies.think3/Contextual Menu` and run it from contextual menu in DEVONthink (The record must be in selected state).
And voilà, the tags are added based on contents automatically.
74
+
75
+

76
+
77
+
Note: You are required to have an [API key](https://platform.openai.com/account/api-keys) from OpenAI. The first time you run the script, a prompt will ask you to enter key.
78
+
79
+

80
+
81
+
The key will be store in Incoming group for DEVONthink (usually `Inbox`). You can see the file `__openai_api_key__` generated there. You can move it to other opened database but don't change it's name.
82
+
83
+
### Auto Writing / Summarizing Using ChatGTP
84
+
85
+
This script lets you to insert `<<TOKEN>>` into your text and then generate the text based on the token.
86
+
87
+

88
+
89
+

90
+
63
91
## Documentation
64
92
65
93
Unlike many other API wrapper projects, PyDT3 is well documented thanks to the detailed AppleScript dictionary by DEVONthink team and the code generation ability of ChatGTP.
response=dtp.display_dialog("Please enter your OpenAI API key", "")
17
+
api_key=response["textReturned"]
18
+
dtp.create_record_with({
19
+
"name": "__openai_api_key__",
20
+
"type": "txt",
21
+
"plain text": api_key,
22
+
})
23
+
24
+
returnapi_key
25
+
26
+
defgenerate_tags(content) ->list[str]:
27
+
completion=openai.ChatCompletion.create(
28
+
model="gpt-3.5-turbo",
29
+
messages=[
30
+
{"role": "user", "content": f"Generate the tags for the following content. Tags should be concise and accurate and no more than 10. output the tags directly seperateted by ',':\n{content}"},
response=dtp.display_dialog("Please enter your OpenAI API key", "")
17
+
api_key=response["textReturned"]
18
+
dtp.create_record_with({
19
+
"name": "__openai_api_key__",
20
+
"type": "txt",
21
+
"plain text": api_key,
22
+
})
23
+
24
+
returnapi_key
25
+
26
+
27
+
defexpand_content(content) ->str:
28
+
system='''You are a skillful writer. Replace the angle brackets you see with the content you generated. Outputs should follow the hints in angle brackets. \n
29
+
30
+
eg.
31
+
32
+
User: "Today I watched a famous British movie <<Movie Name>>. Its's written by <<Author>>. It's about <<Plot>>. I like it very much.
33
+
34
+
AI: {"Movie Name": "The Godfather.", "Author": "Mario Puzo", "Plot": "a mafia family"}
35
+
"'''
36
+
37
+
completion=openai.ChatCompletion.create(
38
+
model="gpt-3.5-turbo",
39
+
messages=[
40
+
{"role": "user", "content": system,},
41
+
{"role": "user", "content": content,},
42
+
{"role": "assistant", "content": "Okay, I'll gie the answer in json format.",},
0 commit comments