autoAnalyzeObject throws error "No response from LLM while generating typespec!"
sweeetland opened this issue · comments
sweeetland commented
Following the example on the readme. My code looks like:
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const GPTLLMAdapter = LLMAdapters.getOpenAIAdapter(openai, {
model: "gpt-4",
});
const results = await autoAnalyzeObject(
data[0],
GPTLLMAdapter.callLLM,
"~/tmp",
);
I am receiving error error: No response from LLM while generating typespec!
which is coming from file auto-analyze.js
.
When I look at the code: https://github.com/hrishioa/wishful-search/blob/master/src/auto-analyze.ts#L190-L204 I can see:
if (!typespec) {
console.log('Generating typespec...');
if (!typespec)
throw new Error('No response from LLM while generating typespec!');
const extractedTypeSpecs = typespec.match(/```typescript([\s\S]*?)```/g);
if (extractedTypeSpecs?.length) {
typespec = extractedTypeSpecs[0]
.replace(/```typescript/g, '')
.replace(/```/g, '')
.trim();
}
}
This must be a bug, seems like we are forgetting to generate the typespec if it doesn't exist?
Hrishi Olickel commented
Good catch - fixed here! Reopen if it recurs or there's another issue.