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

Few mistakes in the documentation codes #5

Open
milahlurhahs opened this issue Nov 13, 2024 · 2 comments
Open

Few mistakes in the documentation codes #5

milahlurhahs opened this issue Nov 13, 2024 · 2 comments

Comments

@milahlurhahs
Copy link

1. For full search API response:

// Step 2. Executing a simple search query
const response = await tvly.search("Who is Leo Messi?");

Comment: await gives error since it's not async

2. For RAG Application context:

// Step 2. Executing a context search query
const context = tvly.searchContext("What happened during the Burning Man floods?");

// Step 3. That's it! You now have a context string that you can feed directly into your RAG Application
console.log(response);

Comment: Should be console.log(context) instead. Wrong const.

By the way, I've tried all three (corrected) codes in the documentation and always got this printed in the CLI:
Promise { <pending> }
before the script ends.
Is there something that I missed? Sorry, I'm still new with JavaScript because I often use Python and Python API for Tavily works great.

P/S: My system is Windows 10 and I installed it using npm install @tavily/core on my Windows Terminal. I simply copy-paste the 3 codes from the documentation in three separate .js file that I ran separately using node filename.js

Hoping for a reply,
Milah

@aurelius-coffee
Copy link

aurelius-coffee commented Jan 8, 2025

I received a strange error (json_decode_error), and thanks to your issue I figured out you're right. I'm surprised it's in the docs, it's common knowledge you can't do that in js. Anyway, here's one quick solution:

return fetch(url, options)
       .then(response => response.text())

Thanks for taking the time to raise the issue @milahlurhahs 👍

@milahlurhahs
Copy link
Author

I received a strange error (json_decode_error), and thanks to your issue I figured out you're right. I'm surprised it's in the docs, it's common knowledge you can't do that in js. Anyway, here's one quick solution:

return fetch(url, options)
       .then(response => response.text())

Thanks for taking the time to raise the issue @milahlurhahs 👍

This is for searching within a set of given URLs, right? I received this Promise { <pending> } as the only output when running this to search the internet:


// Step 1. Instantiating your Tavily client
const tvly = tavily({ apiKey: APIKEY }); //[REDACTED]

// Step 2. Executing a Q&A search query
const answer = tvly.searchQNA("Who is Leo Messi?");

// Step 3. That's it! Your question has been answered!
console.log(answer);```

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