Skip to content

Commit

Permalink
feat: prompt를 개선하여 None을 보다 적절하게 뱉도록 개선- #209
Browse files Browse the repository at this point in the history
  • Loading branch information
hou27 committed Nov 16, 2023
1 parent 9e08583 commit 258d92a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/contents/contents.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ export class CategoryService {

// Join all lines together into a single string
const question = questionLines.join(' ');
console.log(question);

const response = await this.openaiService.createChatCompletion({
question,
Expand Down Expand Up @@ -905,17 +906,19 @@ export class CategoryService {
const content = await this.contentUtil.getLinkContent(link);

let questionLines = [
"You are now auto categorizing machine. You can only answer a single category name or None. Here is the article's information:",
"You are a machine tasked with auto-categorizing articles based on information obtained through web scraping. You can only answer a single category name. Here is the article's information:",
];

if (title) {
questionLines.push(`The title is "${title.trim()}"`);
questionLines.push(
`The article in question is titled "${title.trim()}"`,
);
}

if (content) {
const contentLength = content.length / 2;
questionLines.push(
`The opening 150 characters of the article read, "${content
`The 150 characters of the article is, "${content
.replace(/\s/g, '')
.slice(contentLength - 150, contentLength + 150)
.trim()}"`,
Expand All @@ -932,9 +935,9 @@ export class CategoryService {

// Add the category options to the end of the list
questionLines.push(
`Please tell me the most appropriate category among the following. If none are suitable, return None. Here is Category options: [${categories.join(
`Please provide the most suitable category among the following. Here is Category options: [${categories.join(
', ',
)}]`,
)}, None]`,
);

// Join all lines together into a single string
Expand Down
2 changes: 1 addition & 1 deletion src/openai/openai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class OpenaiService {
content: question,
},
],
temperature: temperature || 0.9,
temperature: temperature || 0.1,
});

return data;
Expand Down

0 comments on commit 258d92a

Please sign in to comment.