Skip to content

Commit

Permalink
Feat: openai ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghyun421 committed May 10, 2024
1 parent 2827777 commit b83522b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/Editor/Components/AiGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const AiGenerator = ({ githubAddress, openAiKey, formList }: GenerateKeyType) =>
const [openAiToken, setOpenAiToken] = useState("");
const [responseData, setResponseData] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const [aboutRepo, setAboutRepo] = useState([]);
const prevResponseData = useRef();
const { setTab } = useTab();

Expand All @@ -25,6 +26,12 @@ const AiGenerator = ({ githubAddress, openAiKey, formList }: GenerateKeyType) =>
}
}, [githubAddress, openAiKey]);

useEffect(() => {
if (formList) {
setAboutRepo(formList);
}
}, [formList]);

useEffect(() => {
if (prevResponseData.current !== responseData && responseData) {
prevResponseData.current = responseData; // Update the ref with the new responseData
Expand Down Expand Up @@ -79,7 +86,9 @@ const AiGenerator = ({ githubAddress, openAiKey, formList }: GenerateKeyType) =>
dangerouslyAllowBrowser: true,
});

const prompt = `Generate a README for the repository at ${data.html_url}`;
const prompt = `Generate a README for the repository at ${data.html_url}
${aboutRepo.map(item => `${item.title}: ${item.value}`).join("\n")}
`;
try {
const response = await openai.completions.create({
model: "gpt-3.5-turbo-instruct",
Expand Down

0 comments on commit b83522b

Please sign in to comment.