Open LuoTuxiu opened 1 year ago
@LuoTuxiu I also ran into this issue and managed to work around it. There seems to be two problems causing it, first is that the prompt
flag seems to have been renamed to completionPrompt
and secondly it seems the result shape from open AI has changed. I updated the demo script to use completionPrompt
and the getCodemodTransformResult
from:
function getCodemodTransformResult(
codemod: AICompletionCodemod | AIChatCodemod,
response: CreateChatCompletionResponse
): CodemodResult<unknown> {
if (codemod.extractTransformationFromCompletion) {
return codemod.extractTransformationFromCompletion(response);
}
return defaultExtractResultFromCompletion(response.choices[0].message?.content);
}
to:
function getCodemodTransformResult(
codemod: AICompletionCodemod | AIChatCodemod,
response: CreateChatCompletionResponse
): CodemodResult<unknown> {
if (codemod.extractTransformationFromCompletion) {
return codemod.extractTransformationFromCompletion(response);
}
// @ts-ignore
return defaultExtractResultFromCompletion(response.choices[0].text);
}
Then I was able to run the demo, given that I provided the proper OPENAI_API_KEY
and OPENAI_ORG_ID
env variables
Was playing around with this and ran into the same issue. I'm assuming this is more of an experiment, but wondering if a CR could be made with this fix if it might get accepted.
I had already fixed this on a branch a couple weeks ago, and saw this thread, so decided to push it up in case anyone needs it.
Hi, i am trying to run
yarn demo:ai
in this repo, but i get this error:Could you give me any idea to fix it?