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

chore: update dependency packages #43

Merged
merged 6 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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