Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
Revert "Revert "chore: update dependency packages (#43)" (#44)"
Browse files Browse the repository at this point in the history
This reverts commit d4538fa.
  • Loading branch information
cachho authored Aug 29, 2023
1 parent d4538fa commit 7bf20e1
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 162 deletions.
13 changes: 5 additions & 8 deletions embedchain/embedchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import type { Collection } from 'chromadb';
import type { QueryResponse } from 'chromadb/dist/main/types';
import { Document } from 'langchain/document';
import type { ChatCompletionRequestMessage } from 'openai';
import { Configuration, OpenAIApi } from 'openai';
import OpenAI from 'openai';

import type { BaseChunker } from './chunkers';
import { PdfFileChunker, QnaPairChunker, WebPageChunker } from './chunkers';
Expand All @@ -20,10 +19,9 @@ import type {
import { ChromaDB } from './vectordb';
import type { BaseVectorDB } from './vectordb/BaseVectorDb';

const configuration = new Configuration({
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

class EmbedChain {
dbClient: any;
Expand Down Expand Up @@ -139,19 +137,18 @@ class EmbedChain {
}

static async getOpenAiAnswer(prompt: string) {
const messages: ChatCompletionRequestMessage[] = [
const messages: OpenAI.Chat.CreateChatCompletionRequestMessage[] = [
{ role: 'user', content: prompt },
];
const response = await openai.createChatCompletion({
const response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages,
temperature: 0,
max_tokens: 1000,
top_p: 1,
});
return (
response.data.choices[0].message?.content ??
'Response could not be processed.'
response.choices[0].message?.content ?? 'Response could not be processed.'
);
}

Expand Down
Loading

0 comments on commit 7bf20e1

Please sign in to comment.