Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
1 change: 1 addition & 0 deletions docs/.typedoc-plugin-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"versions":["v1.0.0-beta01"],"stable":"v1.0.0-beta01","dev":"v1.0.0-beta01"}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/dev
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta http-equiv="refresh" content="0; url=stable/"/>
1 change: 1 addition & 0 deletions docs/stable
1 change: 1 addition & 0 deletions docs/v1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":2232,"name":"applyTemplate","kind":64,"kindString":"Function","flags":{},"children":[],"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/applyTemplate.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/utils/prompt/applyTemplate.ts","line":25,"character":16,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/applyTemplate.ts#L25"}],"signatures":[{"id":2233,"name":"applyTemplate","kind":4096,"kindString":"Call signature","flags":{},"comment":{"summary":[{"kind":"text","text":"Replaces placeholders in a template string with provided values."}],"blockTags":[{"tag":"@returns","content":[{"kind":"text","text":"The template string with placeholders replaced by their corresponding values."}]},{"tag":"@example","content":[{"kind":"code","text":"```ts\nconst template = \"Hello, {{name}}!\";\nconst result = applyTemplate(template, { name: \"World\" });\nconsole.log(result); // Output: \"Hello, World!\"\n```"}]}]},"parameters":[{"id":2234,"name":"template","kind":32768,"kindString":"Parameter","flags":{},"comment":{"summary":[{"kind":"text","text":"The template string containing placeholders like {{key}}."}]},"type":{"type":"intrinsic","name":"string"},"text":{"comment":"<p>The template string containing placeholders like {{key}}.</p>\n"}},{"id":2235,"name":"replacements","kind":32768,"kindString":"Parameter","flags":{},"comment":{"summary":[{"kind":"text","text":"An object mapping placeholder keys to their replacement values."}]},"type":{"type":"reference","typeArguments":[{"type":"intrinsic","name":"string"},{"type":"intrinsic","name":"string"}],"name":"Record","qualifiedName":"Record","package":"typescript"},"text":{"comment":"<p>An object mapping placeholder keys to their replacement values.</p>\n"}}],"type":{"type":"intrinsic","name":"string"},"is":{"declaration":false},"location":{"query":"AIUtils.Function.applyTemplate","hash":"applyTemplate"},"text":{"comment":"<p>Replaces placeholders in a template string with provided values.</p>\n<h5>Returns:</h5><p>The template string with placeholders replaced by their corresponding values.</p>\n<h5>Example:</h5><pre><code class=\"language-ts\"><span class=\"pl-k\">const</span> <span class=\"pl-c1\">template</span> <span class=\"pl-k\">=</span> <span class=\"pl-s\"><span class=\"pl-pds\">\"</span>Hello, {{name}}!<span class=\"pl-pds\">\"</span></span>;\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">result</span> <span class=\"pl-k\">=</span> <span class=\"pl-en\">applyTemplate</span>(<span class=\"pl-smi\">template</span>, { name: <span class=\"pl-s\"><span class=\"pl-pds\">\"</span>World<span class=\"pl-pds\">\"</span></span> });\n<span class=\"pl-c1\">console</span>.<span class=\"pl-c1\">log</span>(<span class=\"pl-smi\">result</span>); <span class=\"pl-c\">// Output: \"Hello, World!\"</span>\n</code></pre>\n"},"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/applyTemplate.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/utils/prompt/applyTemplate.ts","line":25,"character":0,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/applyTemplate.ts#L25"}],"parentId":2232}],"is":{"declaration":true},"location":{"query":"AIUtils.Function.applyTemplate","hash":""},"text":{},"parentId":1452}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":2221,"name":"createPromptGenerator","kind":64,"kindString":"Function","flags":{},"children":[],"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/generator.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/utils/prompt/generator.ts","line":42,"character":16,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/generator.ts#L42"}],"signatures":[{"id":2222,"name":"createPromptGenerator","kind":4096,"kindString":"Call signature","flags":{},"comment":{"summary":[{"kind":"text","text":"Creates a reusable prompt generator function.\n\nThis higher-order function encapsulates common logic like token length checking,\nallowing specific prompt content generation to be handled by the provided "},{"kind":"code","text":"`contentGenerator`"},{"kind":"text","text":"."}],"blockTags":[{"tag":"@returns","content":[{"kind":"text","text":"A function that generates the full prompt string based on the input, or an empty string if it exceeds the token limit."}]},{"tag":"@example","content":[{"kind":"text","text":"const myPromptGenerator = createPromptGenerator(\n { maxTokenLength: 10000 },\n (userQuery: string) => "},{"kind":"code","text":"`Answer the following question: ${userQuery}`"},{"kind":"text","text":"\n);\nconst prompt = myPromptGenerator(\"What is the weather today?\");\nif (prompt) {\n // Use the prompt with an LLM API\n} else {\n console.error(\"Prompt was too long\");\n}"}]}]},"typeParameter":[{"id":2223,"name":"T","kind":131072,"kindString":"Type parameter","flags":{},"comment":{"summary":[{"kind":"text","text":"The type of the input parameter for the content generator function."}]}}],"parameters":[{"id":2224,"name":"config","kind":32768,"kindString":"Parameter","flags":{},"comment":{"summary":[{"kind":"text","text":"Configuration for the prompt generator, including maximum token length."}]},"type":{"type":"reference","id":2219,"name":"PromptConfig"},"text":{"comment":"<p>Configuration for the prompt generator, including maximum token length.</p>\n"}},{"id":2225,"name":"contentGenerator","kind":32768,"kindString":"Parameter","flags":{},"comment":{"summary":[{"kind":"text","text":"A function that takes the input and returns the core prompt content."}]},"type":{"type":"reflection","declaration":{"id":2226,"name":"__type","kind":65536,"kindString":"Type literal","flags":{},"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/generator.ts","line":44,"character":20,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/generator.ts#L44"}],"signatures":[{"id":2227,"name":"__type","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":2228,"name":"input","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","id":2223,"name":"T"}}],"type":{"type":"intrinsic","name":"string"}}]}},"text":{"comment":"<p>A function that takes the input and returns the core prompt content.</p>\n"}}],"type":{"type":"reflection","declaration":{"id":2229,"name":"createPromptGenerator","kind":65536,"kindString":"Type literal","flags":{},"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/generator.ts","line":45,"character":3,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/generator.ts#L45"}],"signatures":[{"id":2230,"name":"createPromptGenerator","kind":4096,"kindString":"Call signature","flags":{},"parameters":[{"id":2231,"name":"input","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","id":2223,"name":"T"},"text":{}}],"type":{"type":"intrinsic","name":"string"},"is":{"declaration":false},"location":{"query":"AIUtils.Function.createPromptGenerator","hash":"createPromptGenerator.__type"},"text":{},"parentId":2221}],"location":{"query":"AIUtils.Function.createPromptGenerator","hash":"createPromptGenerator"}}},"is":{"declaration":false},"location":{"query":"AIUtils.Function.createPromptGenerator","hash":"createPromptGenerator"},"text":{"comment":"<p>Creates a reusable prompt generator function.</p>\n<p>This higher-order function encapsulates common logic like token length checking,\nallowing specific prompt content generation to be handled by the provided <code>contentGenerator</code>.</p>\n<h5>Returns:</h5><p>A function that generates the full prompt string based on the input, or an empty string if it exceeds the token limit.</p>\n<h5>Example:</h5><p>const myPromptGenerator = createPromptGenerator(\n { maxTokenLength: 10000 },\n (userQuery: string) =&gt; <code>Answer the following question: ${userQuery}</code>\n);\nconst prompt = myPromptGenerator(&quot;What is the weather today?&quot;);\nif (prompt) {\n // Use the prompt with an LLM API\n} else {\n console.error(&quot;Prompt was too long&quot;);\n}</p>\n"},"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/generator.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/utils/prompt/generator.ts","line":42,"character":0,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/generator.ts#L42"}],"parentId":2221}],"is":{"declaration":true},"location":{"query":"AIUtils.Function.createPromptGenerator","hash":""},"text":{},"parentId":1452}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":2214,"name":"estimateTokenLength","kind":64,"kindString":"Function","flags":{},"children":[],"sources":[{"fileName":"packages/ai-utils/src/llm/prompts/token.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/llm/prompts/token.ts","line":45,"character":16,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/llm/prompts/token.ts#L45"}],"signatures":[{"id":2215,"name":"estimateTokenLength","kind":4096,"kindString":"Call signature","flags":{},"comment":{"summary":[],"blockTags":[{"tag":"@function","content":[{"kind":"text","text":"estimateTokenLength"}]},{"tag":"@description","content":[{"kind":"text","text":"估算字符串中的token数量。A simple heuristic to estimate the number of tokens in a string using character-based approximation for various language models."}]},{"tag":"@returns","content":[{"kind":"text","text":"估算的token数量。The estimated number of tokens (rough approximation)"}]},{"tag":"@example","content":[{"kind":"code","text":"```ts\n// Estimate tokens for English text\nconst englishTokens = estimateTokenLength('Hello, how are you today?');\nconsole.log(englishTokens); // Approximately 6-8 tokens\n```"}]},{"tag":"@example","content":[{"kind":"code","text":"```ts\n// Estimate tokens for Chinese text\nconst chineseTokens = estimateTokenLength('你好,今天怎么样?');\nconsole.log(chineseTokens); // Approximately 8-10 tokens\n```"}]},{"tag":"@example","content":[{"kind":"code","text":"```ts\n// Estimate tokens for code\nconst codeTokens = estimateTokenLength('function hello() { return \"world\"; }');\nconsole.log(codeTokens); // Approximately 8-12 tokens\n```"}]},{"tag":"@example","content":[{"kind":"code","text":"```ts\n// Check if prompt fits within model limits\nconst prompt = 'Generate a summary of this article...';\nconst tokens = estimateTokenLength(prompt);\nconst maxTokens = 4096;\nif (tokens > maxTokens * 0.8) {\n console.warn('Prompt may be too long for model');\n}\n```"}]},{"tag":"@see","content":[{"kind":"inline-tag","tag":"@link","text":"https://www.npmjs.com/package/tiktoken","target":"https://www.npmjs.com/package/tiktoken"},{"kind":"text","text":" - For precise OpenAI token counting"}]}]},"parameters":[{"id":2216,"name":"input","kind":32768,"kindString":"Parameter","flags":{},"comment":{"summary":[{"kind":"text","text":"需要估算token数量的字符串。The string to estimate token length for (supports multilingual text)"}]},"type":{"type":"intrinsic","name":"string"},"text":{"comment":"<p>需要估算token数量的字符串。The string to estimate token length for (supports multilingual text)</p>\n"}}],"type":{"type":"intrinsic","name":"number"},"is":{"declaration":false},"location":{"query":"AIUtils.Function.estimateTokenLength","hash":"estimateTokenLength"},"text":{"comment":"<h5>Function:</h5><p>estimateTokenLength</p>\n<h5>Description:</h5><p>估算字符串中的token数量。A simple heuristic to estimate the number of tokens in a string using character-based approximation for various language models.</p>\n<h5>Returns:</h5><p>估算的token数量。The estimated number of tokens (rough approximation)</p>\n<h5>Example:</h5><pre><code class=\"language-ts\"><span class=\"pl-c\">// Estimate tokens for English text</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">englishTokens</span> <span class=\"pl-k\">=</span> <span class=\"pl-en\">estimateTokenLength</span>(<span class=\"pl-s\"><span class=\"pl-pds\">'</span>Hello, how are you today?<span class=\"pl-pds\">'</span></span>);\n<span class=\"pl-c1\">console</span>.<span class=\"pl-c1\">log</span>(<span class=\"pl-smi\">englishTokens</span>); <span class=\"pl-c\">// Approximately 6-8 tokens</span>\n</code></pre>\n<h5>Example:</h5><pre><code class=\"language-ts\"><span class=\"pl-c\">// Estimate tokens for Chinese text</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">chineseTokens</span> <span class=\"pl-k\">=</span> <span class=\"pl-en\">estimateTokenLength</span>(<span class=\"pl-s\"><span class=\"pl-pds\">'</span>你好,今天怎么样?<span class=\"pl-pds\">'</span></span>);\n<span class=\"pl-c1\">console</span>.<span class=\"pl-c1\">log</span>(<span class=\"pl-smi\">chineseTokens</span>); <span class=\"pl-c\">// Approximately 8-10 tokens</span>\n</code></pre>\n<h5>Example:</h5><pre><code class=\"language-ts\"><span class=\"pl-c\">// Estimate tokens for code</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">codeTokens</span> <span class=\"pl-k\">=</span> <span class=\"pl-en\">estimateTokenLength</span>(<span class=\"pl-s\"><span class=\"pl-pds\">'</span>function hello() { return \"world\"; }<span class=\"pl-pds\">'</span></span>);\n<span class=\"pl-c1\">console</span>.<span class=\"pl-c1\">log</span>(<span class=\"pl-smi\">codeTokens</span>); <span class=\"pl-c\">// Approximately 8-12 tokens</span>\n</code></pre>\n<h5>Example:</h5><pre><code class=\"language-ts\"><span class=\"pl-c\">// Check if prompt fits within model limits</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">prompt</span> <span class=\"pl-k\">=</span> <span class=\"pl-s\"><span class=\"pl-pds\">'</span>Generate a summary of this article...<span class=\"pl-pds\">'</span></span>;\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">tokens</span> <span class=\"pl-k\">=</span> <span class=\"pl-en\">estimateTokenLength</span>(<span class=\"pl-smi\">prompt</span>);\n<span class=\"pl-k\">const</span> <span class=\"pl-c1\">maxTokens</span> <span class=\"pl-k\">=</span> <span class=\"pl-c1\">4096</span>;\n<span class=\"pl-k\">if</span> (<span class=\"pl-smi\">tokens</span> <span class=\"pl-k\">></span> <span class=\"pl-smi\">maxTokens</span> <span class=\"pl-k\">*</span> <span class=\"pl-c1\">0.8</span>) {\n <span class=\"pl-c1\">console</span>.<span class=\"pl-c1\">warn</span>(<span class=\"pl-s\"><span class=\"pl-pds\">'</span>Prompt may be too long for model<span class=\"pl-pds\">'</span></span>);\n}\n</code></pre>\n<h5>See:</h5><p><a href=\"https://www.npmjs.com/package/tiktoken\">https://www.npmjs.com/package/tiktoken</a> - For precise OpenAI token counting</p>\n"},"sources":[{"fileName":"packages/ai-utils/src/llm/prompts/token.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/llm/prompts/token.ts","line":45,"character":0,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/llm/prompts/token.ts#L45"}],"parentId":2214}],"is":{"declaration":true},"location":{"query":"AIUtils.Function.estimateTokenLength","hash":""},"text":{},"parentId":1452}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":2183,"name":"genCodeReviewPrompt","kind":64,"kindString":"Function","flags":{},"children":[],"sources":[{"fileName":"packages/ai-utils/src/applications/codeReview.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/applications/codeReview.ts","line":71,"character":13,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/applications/codeReview.ts#L71"}],"signatures":[{"id":2184,"name":"genCodeReviewPrompt","kind":4096,"kindString":"Call signature","flags":{},"comment":{"summary":[],"blockTags":[{"tag":"@function","content":[{"kind":"text","text":"genCodeReviewPrompt"}]},{"tag":"@description","content":[{"kind":"text","text":"生成用于代码审查的Prompt"}]},{"tag":"@returns","content":[{"kind":"text","text":"符合要求的Prompt文本,如果超过长度限制则返回空字符串"}]}]},"parameters":[{"id":2185,"name":"input","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"},"text":{}}],"type":{"type":"intrinsic","name":"string"},"is":{"declaration":false},"location":{"query":"AIUtils.Function.genCodeReviewPrompt","hash":"genCodeReviewPrompt"},"text":{"comment":"<h5>Function:</h5><p>genCodeReviewPrompt</p>\n<h5>Description:</h5><p>生成用于代码审查的Prompt</p>\n<h5>Returns:</h5><p>符合要求的Prompt文本,如果超过长度限制则返回空字符串</p>\n"},"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/generator.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/utils/prompt/generator.ts","line":45,"character":3,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/generator.ts#L45"}],"parentId":2183}],"is":{"declaration":true},"location":{"query":"AIUtils.Function.genCodeReviewPrompt","hash":""},"text":{},"parentId":1452}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":2197,"name":"genCreateReactComponentPrompt","kind":64,"kindString":"Function","flags":{},"children":[],"sources":[{"fileName":"packages/ai-utils/src/applications/createReactComponent.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/applications/createReactComponent.ts","line":76,"character":13,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/applications/createReactComponent.ts#L76"}],"signatures":[{"id":2198,"name":"genCreateReactComponentPrompt","kind":4096,"kindString":"Call signature","flags":{},"comment":{"summary":[],"blockTags":[{"tag":"@function","content":[{"kind":"text","text":"genCreateReactComponentPrompt"}]},{"tag":"@description","content":[{"kind":"text","text":"生成用于创建React组件的Prompt"}]},{"tag":"@returns","content":[{"kind":"text","text":"符合要求的Prompt文本,如果超过长度限制则返回空字符串"}]}]},"parameters":[{"id":2199,"name":"input","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"intrinsic","name":"string"},"text":{}}],"type":{"type":"intrinsic","name":"string"},"is":{"declaration":false},"location":{"query":"AIUtils.Function.genCreateReactComponentPrompt","hash":"genCreateReactComponentPrompt"},"text":{"comment":"<h5>Function:</h5><p>genCreateReactComponentPrompt</p>\n<h5>Description:</h5><p>生成用于创建React组件的Prompt</p>\n<h5>Returns:</h5><p>符合要求的Prompt文本,如果超过长度限制则返回空字符串</p>\n"},"sources":[{"fileName":"packages/ai-utils/src/utils/prompt/generator.ts","fullFileName":"/home/runner/work/fe-tools/fe-tools/utils/packages/ai-utils/src/utils/prompt/generator.ts","line":45,"character":3,"url":"https://github.com/MichealWayne/fe-tools/blob/d7e292c/utils/packages/ai-utils/src/utils/prompt/generator.ts#L45"}],"parentId":2197}],"is":{"declaration":true},"location":{"query":"AIUtils.Function.genCreateReactComponentPrompt","hash":""},"text":{},"parentId":1452}
Loading