Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query not a function #20

Closed
converseKarl opened this issue Apr 21, 2024 · 3 comments
Closed

query not a function #20

converseKarl opened this issue Apr 21, 2024 · 3 comments
Assignees

Comments

@converseKarl
Copy link

converseKarl commented Apr 21, 2024

import express from 'express';
import fs from 'fs';
import path from 'path';
import {RAGApplicationBuilder, RAGApplication,
PdfLoader, YoutubeSearchLoader, SitemapLoader, WebLoader, TextLoader } from '@llm-tools/embedjs';
import {LanceDb} from '@llm-tools/embedjs/vectorDb/lance';
import { OpenAI } from "openai";
let key = process.env.OPENAI_API_KEY; // Replace with your OpenAI API key

const openai = new OpenAI({
apiKey: key
});

router.get('/test', async (req, res) => {
const ragApplication = await new RAGApplicationBuilder()
.addLoader(new WebLoader({ url: 'https://en.wikipedia.org/wiki/Tesla,_Inc.' }))
.setVectorDb(new LanceDb({ path: './db' }));
res.status(200).send(await ragApplication.query('Tell me about the history of Tesla?'));

})

TypeError: ragApplication.query is not a function
Failed to build RAG application: TypeError: Cannot read properties of undefined (reading 'query')

However query is failing what imports do i need to specify for this?

Notice youtube issue's a fetch warning "experimental". I'm using node v18, moving to v20 soon.

@converseKarl
Copy link
Author

converseKarl commented Apr 22, 2024

resolved. Just make sure you don't import openai, or set any openai parameters or keys. Simply set your ENV var as per the docs.

It wil then use the default openai model gpt 3.5 turbo

@adhityan
Copy link
Collaborator

Glad it worked. I am a little curious, did you see the error by just referencing / importing from the OpenAI package? Also, do you mind sharing why you are using OpenAI directly with this package - any use case that this library does not cover?

@converseKarl
Copy link
Author

You have to keep your script clear of any openai imports or openai variable declarations. So no referencing in the script. I had like an openai import from openai, and i had a openai var declaration passing in the key. You see this a lot in these types of scripts but its not required for your library. All is needed is the env open ai entry you specify in docs and its key nothing more. Your lib does the rest. Once i did that everything worked thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants