Skip to content

Commit

Permalink
feat: optimize prompts (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
luckrnx09 authored Jul 5, 2024
1 parent 4df3527 commit 3a8a46a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luckrnx09/abook",
"version": "1.0.1",
"version": "1.0.2",
"description": "<h1 align=\"center\">⚡ abook⚡</h1> <p align=\"center\"> An AI powered command-line tool for generating any books from scratch</p>",
"bin": {
"abook": "dist/index.js"
Expand Down Expand Up @@ -58,8 +58,8 @@
},
"dependencies": {
"@inquirer/prompts": "^5.0.4",
"@langchain/core": "^0.2.0",
"@langchain/openai": "^0.0.33",
"@langchain/core": "^0.2.13",
"@langchain/openai": "^0.2.1",
"commander": "^12.1.0",
"console-table-printer": "^2.12.0",
"dotenv-cli": "^7.4.2",
Expand Down
6 changes: 4 additions & 2 deletions src/bot/generation/task/prompt/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ You're a meticulous book writer. You can write articles based on the information
- Requirements: ${book.prompt?.length ? book.prompt : 'N/A'}
### Skill 2: Output Article Iteratively
- Conceptualize and make sure that the full article should have 2,000 to 10,000 words.
- Conceptualize and make sure that the full article should have TWO THOUSAND to TEN THOUSAND words.
- Write rationally, use precise, concise, logical and refer more examples. Don't use vague expressions, and do not stretch and over-elaborate.
- Iteratively write until complete:
- Send me a special text "DONE" in English if you've completed writing the full article.
- Coherently write the next paragraph if I send you "Continue writing" in English.
- Each paragraph should stick to the title but that doesn't mean it always starts with text from the title. You need to write vivid, appropriate paragraph text in context.
- Continuing from what already written in vivid, appropriate paragraph text.
- Use the Pyramid Principle to organize each paragraph without omitting and repeating content.
- If you don't have a good idea for some paragraph, please don't feel free to write about it, and leave a placeholder and replace TOPIC in format \`<TOPIC should be here>\` to prompt the writer to manually fill in whatever is here.
- Don't iterate more than 5 times.
- Every response both the special text and article paragraph should enclosed within the <RESPONSE></RESPONSE> tags.
- Never write any headings in markdown.
Expand Down
4 changes: 2 additions & 2 deletions src/bot/idea/prompt/book-schemer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ You are a book schemer who can skillfully utilize the given book idea to craft a
### Skill 2: Create a book outline
- Based on the interpreted information, craft a logical and compelling book outline.
- Following the MECE principle, enhance the outline by supplementing with additional insightful points.
- Ensure that the book outline is in \`OutlineSchema\` format and the outline must contain at least *12 chapters*, each of chapter should contain *3 to 6 articles*.
- Following the Pyramid Principle, enhance the outline by supplementing with additional insightful points.
- Ensure that the book outline is in \`OutlineSchema\` format and the outline must contain at least TWELVE chapters, each of chapter should contain THREE to SIX articles.
- No serial number required for chapter and article titles.
### Skill 2: Learn the \`OutlineSchema\`
Expand Down
58 changes: 56 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@langchain/core@>0.1.0 <0.3.0", "@langchain/core@>0.1.56 <0.3.0", "@langchain/core@^0.2.0", "@langchain/core@~0.2.0":
"@langchain/core@>0.1.0 <0.3.0", "@langchain/core@>0.1.56 <0.3.0", "@langchain/core@~0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@langchain/core/-/core-0.2.0.tgz#19c6374a5ad80daf8e14cb58582bc988109a1403"
integrity sha512-UbCJUp9eh2JXd9AW/vhPbTgtZoMgTqJgSan5Wf/EP27X8JM65lWdCOpJW+gHyBXvabbyrZz3/EGaptTUL5gutw==
Expand All @@ -385,7 +385,36 @@
zod "^3.22.4"
zod-to-json-schema "^3.22.3"

"@langchain/openai@^0.0.33", "@langchain/openai@~0.0.28":
"@langchain/core@>=0.2.8 <0.3.0", "@langchain/core@^0.2.13":
version "0.2.13"
resolved "https://registry.yarnpkg.com/@langchain/core/-/core-0.2.13.tgz#5bf1fb66b1ea436ef7b6450309c6a9f3a8c767bb"
integrity sha512-inMx0o4bvv2/wgztHQs013gKkN51cli7XwbVSn/6PVRz7FEZK2dKi4807gZaez2NMiHTuxjwDUMrliWZTtXWNw==
dependencies:
ansi-styles "^5.0.0"
camelcase "6"
decamelize "1.2.0"
js-tiktoken "^1.0.12"
langsmith "~0.1.30"
ml-distance "^4.0.0"
mustache "^4.2.0"
p-queue "^6.6.2"
p-retry "4"
uuid "^9.0.0"
zod "^3.22.4"
zod-to-json-schema "^3.22.3"

"@langchain/openai@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@langchain/openai/-/openai-0.2.1.tgz#2c0c2cb6bd7839d8ce342c97099c6e35f2dde40d"
integrity sha512-Ti3C6ZIUPaueIPAfMljMnLu3GSGNq5KmrlHeWkIbrLShOBlzj4xj7mRfR73oWgAC0qivfxdkfbB0e+WCY+oRJw==
dependencies:
"@langchain/core" ">=0.2.8 <0.3.0"
js-tiktoken "^1.0.12"
openai "^4.49.1"
zod "^3.22.4"
zod-to-json-schema "^3.22.3"

"@langchain/openai@~0.0.28":
version "0.0.33"
resolved "https://registry.yarnpkg.com/@langchain/openai/-/openai-0.0.33.tgz#af88d815ff0095018c879d3a1a5a32b2795b5c69"
integrity sha512-hTBo9y9bHtFvMT5ySBW7TrmKhLSA91iNahigeqAFBVrLmBDz+6rzzLFc1mpq6JEAR3fZKdaUXqso3nB23jIpTw==
Expand Down Expand Up @@ -1847,6 +1876,17 @@ langchainhub@~0.0.8:
resolved "https://registry.yarnpkg.com/langchainhub/-/langchainhub-0.0.10.tgz#7579440a3255d67571b7046f3910593c5664f064"
integrity sha512-mOVso7TGTMSlvTTUR1b4zUIMtu8zgie/pcwRm1SeooWwuHYMQovoNXjT6gEjvWEZ6cjt4gVH+1lu2tp1/phyIQ==

langsmith@~0.1.30:
version "0.1.36"
resolved "https://registry.yarnpkg.com/langsmith/-/langsmith-0.1.36.tgz#5f21b9c6bcd4ea9c0e943f83e304a53e5232297d"
integrity sha512-D5hhkFl31uxFdffx0lA6pin0lt8Pv2dpHFZYpSgEzvQ26PQ/Y/tnniQ+aCNokIXuLhMa7uqLtb6tfwjfiZXgdg==
dependencies:
"@types/uuid" "^9.0.1"
commander "^10.0.1"
p-queue "^6.6.2"
p-retry "4"
uuid "^9.0.0"

langsmith@~0.1.7:
version "0.1.25"
resolved "https://registry.yarnpkg.com/langsmith/-/langsmith-0.1.25.tgz#3d06b6fc62abb1a6fc16540d40ddb48bd795f128"
Expand Down Expand Up @@ -2211,6 +2251,20 @@ openai@^4.41.1:
node-fetch "^2.6.7"
web-streams-polyfill "^3.2.1"

openai@^4.49.1:
version "4.52.3"
resolved "https://registry.yarnpkg.com/openai/-/openai-4.52.3.tgz#3c6459dfd65e2bf9671729f25879a5b4224dca70"
integrity sha512-IyQLYKGYoEEkUCEm2frPzwHDJ3Ym663KtivnY6pWCzuoi6/HgSIMMxpcuTRS81GH6tiULPYGmTxIvzXdmPIWOw==
dependencies:
"@types/node" "^18.11.18"
"@types/node-fetch" "^2.6.4"
abort-controller "^3.0.0"
agentkeepalive "^4.2.1"
form-data-encoder "1.7.2"
formdata-node "^4.3.2"
node-fetch "^2.6.7"
web-streams-polyfill "^3.2.1"

openapi-types@^12.1.3:
version "12.1.3"
resolved "https://registry.yarnpkg.com/openapi-types/-/openapi-types-12.1.3.tgz#471995eb26c4b97b7bd356aacf7b91b73e777dd3"
Expand Down

0 comments on commit 3a8a46a

Please sign in to comment.