You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const model = new OpenAI({
openAIApiKey: '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',
modelName: 'text-davinci-003',
temperature: 0,
maxTokens: 1000,
cache: true,
callbacks: [
{
handleLLMStart: async () => {
console.log('API CALL :', ++count);
},
},
], /// bargav sir's
});
/* Split the text into chunks */
const textSplitter = new RecursiveCharacterTextSplitter({
chunkSize: 1000,
});
const docs = await textSplitter.createDocuments([text]);
/* Create the vectorstore */
const vectorstore = await HNSWLib.fromDocuments(
docs,
new OpenAIEmbeddings({
openAIApiKey: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx,
}),
);
/* Create the chain */
const chain = ConversationalRetrievalQAChain.fromLLM(
model,
vectorstore.asRetriever(),
);
/* Ask it a question */
// const question = 'Summarize this documents in 500 words';
// const question =
// 'What is the discussion going about in all the transcript? Write in 500 words. Summarize the discussion';
const question =
'Highlight the problem statement being discussed in the given transcript in 500 words';
const res = await chain.call({ question, chat_history: [] });
const configuration = new Configuration({
apiKey: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxx',
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createCompletion({
model: 'text-davinci-003',
prompt: `Share the most relevant industry case study that matches to this problem statement in 300 words. ${res.text}
Also share the url of the relavent case study`,
max_tokens: 1000,
temperature: 1,
});
return {
discussion: res.text,
case_study: completion.data.choices[0].text,
};``
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Beta Was this translation helpful? Give feedback.
All reactions