Skip to content

Commit

Permalink
🐛 fix: Fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Mar 30, 2024
1 parent 4196369 commit d4bc39c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class TranslateMarkdown {
if (existsSync(targetFilename)) continue;
const mode = this.getMode(file, md);
const { data, content } = matter(md);
consola.info(`📄 To ${locale}: ${chalk.yellow(file)}`);
consola.info(`📄 To ${locale}: ${chalk.yellow(targetFilename)}`);
this.query.push({
filename: targetFilename,
from: config.entryLocale,
Expand Down
1 change: 1 addition & 0 deletions packages/lobe-seo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Some additional configurations are provided in this project, set using environme
| tagStringify | | `boolean` | `false` | Stringify the tags array |
| modelName | | `string` | `gpt-3.5-turbo` | Model used |
| temperature | | `number` | `0` | Sampling temperature used |
| reference | | `string` | - | Provide some rule for more accurate seo |
| concurrency | | `number` | `5` | Number of concurrently pending promises returned |
| experimental | | `experimental` | `{}` | Experimental features, see below |

Expand Down
1 change: 1 addition & 0 deletions packages/lobe-seo/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ $ lobe-seo -c './custom-config.js' # or use the full flag --config
| tagStringify | | `boolean` | `false` | 将 tags 字符串化 |
| modelName | | `string` | `gpt-3.5-turbo` | 使用的模型 |
| temperature | | `number` | `0` | 使用的采样温度 |
| reference | | `string` | - | 自定义 SEO 规则 prompt |
| concurrency | | `number` | `5` | 同时并发的队列请求数量 |
| experimental | | `experimental` | `{}` | 实验性功能,见下文 |

Expand Down
2 changes: 1 addition & 1 deletion packages/lobe-seo/src/core/SeoMdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SeoMdx {
openAIApiKey,
temperature: config.temperature,
});
this.prompt = promptSeo();
this.prompt = promptSeo(this.config.reference);
this.isJsonMode = Boolean(this.config?.experimental?.jsonMode);
}
async run(content: string): Promise<PostSEO | any> {
Expand Down
46 changes: 25 additions & 21 deletions packages/lobe-seo/src/prompts/seo.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import { ChatPromptTemplate } from '@langchain/core/prompts';

export const promptSeo = () => {
return ChatPromptTemplate.fromMessages<{
content: string;
}>([
[
'system',
`# Role: Markdown SEO Expert
## Profile
As a Markdown SEO expert, I specialize in converting Markdown-formatted article content into JSON format matter data optimized for SEO. My goal is to enhance articles' online visibility and search engine rankings through carefully crafted Titles, Descriptions, and Tags, ensuring each article achieves optimal SEO performance.
## Expertise:
1. **Analyzing Markdown Articles**: Understanding and analyzing the content of Markdown-formatted articles to extract key information.
2. **Creating SEO-friendly Titles**: Crafting titles that include target keywords and are enticing enough to generate user clicks, based on the article content.
3. **Writing Compelling Descriptions**: Writing descriptions that include keywords, are concise, and based on the article's theme.
4. **Selecting Appropriate Tags**: Choosing tags that are highly relevant to the article's theme and content.
const DEFAULT_RULE = `
## Rules
1. **Maintain Content Relevance**: Ensure the generated titles, descriptions, and tags are highly relevant to the article content.
2. **Avoid Keyword Stuffing**: Use keywords naturally in titles, descriptions, and tags, avoiding over-optimization.
3. **Length of Titles and Descriptions**: Descriptions are recommended to be around 50-60 characters, and descriptions should be around 155 characters.
3. **Length of Titles and Descriptions**: Descriptions are recommended to be around 30-40 characters, and descriptions should be around 100 characters.
### Title (Title)
- **Include Keywords**: Ensure the title contains target keywords but avoids keyword stuffing.
- **Uniqueness**: Write a unique title for each page.
- **Length Optimization**: Keep the title length moderate, usually recommended to be between 50-60 characters.
- **Length Optimization**: Keep the title length moderate, usually recommended to be between 30-40 characters.
- **Written for Humans**: While the title needs to be search engine friendly, it ultimately needs to attract human users.
- **Consider Format**: Titles with clear formats are easier to understand and click.
- **Similarity to H1 Tag**: Ensure the title is similar to the page's H1 tag for consistency.
Expand All @@ -35,12 +18,33 @@ As a Markdown SEO expert, I specialize in converting Markdown-formatted article
- **Include Keywords**: Include target keywords in the description, ensuring it flows naturally.
- **Clear Value**: The description should clearly articulate the page's value and what it offers.
- **Click-Worthy**: Write descriptions that are compelling and enticing enough to generate clicks, concise yet attractive.
- **Length Control**: Keep the description length around 155 characters.
- **Length Control**: Keep the description length around 100 characters.
### Tags (Tags)
- **Keyword Relevance**: Tags should be highly relevant to the content, including target keywords.
- **Avoid Over-Optimization**: Avoid using keywords excessively for SEO, keeping tags natural and relevant.
- **Diversity**: Use a variety of tags to cover a broader range of potential search queries.
`;

export const promptSeo = (reference?: string) => {
return ChatPromptTemplate.fromMessages<{
content: string;
}>([
[
'system',
`# Role: Markdown SEO Expert
## Profile
As a Markdown SEO expert, I specialize in converting Markdown-formatted article content into JSON format matter data optimized for SEO. My goal is to enhance articles' online visibility and search engine rankings through carefully crafted Titles, Descriptions, and Tags, ensuring each article achieves optimal SEO performance.
## Expertise:
1. **Analyzing Markdown Articles**: Understanding and analyzing the content of Markdown-formatted articles to extract key information.
2. **Creating SEO-friendly Titles**: Crafting titles that include target keywords and are enticing enough to generate user clicks, based on the article content.
3. **Writing Compelling Descriptions**: Writing descriptions that include keywords, are concise, and based on the article's theme.
4. **Selecting Appropriate Tags**: Choosing tags that are highly relevant to the article's theme and content.
${reference || DEFAULT_RULE}
## The structure for generating SEO JSON format matter is as follows:
Expand Down
4 changes: 4 additions & 0 deletions packages/lobe-seo/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface SeoConfig {
* @description ChatGPT model name to use
*/
modelName?: LanguageModel;
/**
* @description Provide some context for a more accurate translation
*/
reference?: string;
/**
* @description Stringify the tags array
*/
Expand Down

0 comments on commit d4bc39c

Please sign in to comment.