Find answers from the community

Home
Members
praveenks30#120294
p
praveenks30#120294
Offline, last seen 3 months ago
Joined September 25, 2024
@kapa.ai how can I pass system and user messages to ReAct agent ?
15 comments
p
k
@kapa.ai How to use PromptTemplate to pass input as variables with ReActAgent ?
4 comments
k
p
@kapa.ai how to generate output in the json format ?
3 comments
k
I am trying to query custom documents using LlamaIndex and using MongoDB altas for backend. below is the code for the same. The code is working fine even I can see the documents are created successfully in MongoDB in default_collection under default_db but I am getting None on the response of my query. Could you please let me know what is missing and what needs to be added to get the response .

import pymongo import openai import os from llama_index import VectorStoreIndex, StorageContext, SimpleDirectoryReader from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch from llama_index.storage.storage_context import StorageContext openai.api_key = os.getenv("OPENAI_API_KEY") # setup mongo connection mongo_uri = os.environ(mongo_uri) # setup client mongodb_client = pymongo.MongoClient(mongo_uri) if mongodb_client : print("Connection is successful!") else: print("Connection is not successful!") # setup store store = MongoDBAtlasVectorSearch(mongodb_client) # print(store) # setup storage context storage_context = StorageContext.from_defaults( vector_store= store ) documents = SimpleDirectoryReader("input/text").load_data() index = VectorStoreIndex.from_documents(documents, storage_context= storage_context) print(index) # ask query query_engine = index.as_query_engine() response = query_engine.query("What did author work on after college?") print(response)
16 comments
a
L
p
W
I am trying to use PineconeVectorStore to save and query index but getting below error. It looks something from library (pinecone.py ) . Already upgraded llama_index and langchain to latest version.

Code :

#initialize pinecone client pinecone.init(api_key=api_key, environment="us-west1-gcp-free") pinecone_index = pinecone.Index("pi-starter-index") #load document documents = SimpleDirectoryReader('input/text').load_data() # create vector store vector_store = PineconeVectorStore( pinecone_index=pinecone_index ) storage_context = StorageContext.from_defaults(vector_store=vector_store) index = VectorStoreIndex.from_documents(documents, storage_context=storage_context) query_engine = index.as_query_engine() response = query_engine.query("What did the author do growing up?") print(response)

Error:

Traceback (most recent call last): File "c:\MyStuffs\Code\llama_index\vector db\basic_pinecone_db.py", line 30, in <module> vector_store = PineconeVectorStore( File "C:\Python39\lib\site-packages\llama_index\vector_stores\pinecone.py", line 169, in __init__ tokenizer = get_default_tokenizer() File "C:\Python39\lib\site-packages\llama_index\vector_stores\pinecone.py", line 82, in get_default_tokenizer ** from transformers import BertTokenizerFast ModuleNotFoundError: No module named 'transformers' **
3 comments
L
p
Is there any best practices to encounter Hallucination scenarios ? How can I make sure the response is always going to come from ingested documents and should be relevant to the ask ? From where should I start ? Please suggest. Any documentation link ?
1 comment
L
@kapa.ai What is FunctionCallingAgentWorker and how different is it from ReAct Agent ?
30 comments
k
p
@kapa.ai What is the significance of context_window ?
21 comments
k
p
@kapa.ai how to get the list of all possible models used in OpenAI() ?
5 comments
k
p
@kapa.ai how to get the source of the LLM response while quering over the text files ?
2 comments
k
@kapa.ai How does smaller chunk size help ? Why is it required to chunk the data into smaller size ?
2 comments
k
@kapa.ai How can I pass pydantic class in PromptTemplate to get structued output ?
12 comments
k
p
@kapa.ai I am trying to use this : gpt_4o = OpenAIMultiModal(model="gpt-4o", max_new_tokens=4096) but getting below error :

ValueError: Invalid model gpt-4o. Available models are: ['gpt-4-vision-preview']
4 comments
p
L
k
Do we have Text to SQL generation for NoSql databases (MongoDB etc..) as well or is it only for relational databases ?
1 comment
L
@kapa.ai is there any text to sql generator for No Sql databases ?
2 comments
k
@kapa.ai Is there a way to call AzureOpenAI in async way ? Currently, I am using AzureOpenAI from llama_index.llms.azure.openai
9 comments
p
k
@kapa.ai does it mean OpenAI Agent can't be used with open source models like llama3 as it is specific to openai models ?
2 comments
k
@kapa.ai What's the difference between ReAct Agent and OpenAI Agent?
3 comments
k
I am trying to use Groq with llama_index. Below is the code for the same. But, while executing code , I am getting : openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Invalid API Key'

My concern is not related to openai invalid api key. It's more of why it is even referring the openai key when I am not using it anywhere. My ideas was to have the application built on the open source model.
Does llama index needs to refer the openai for its internal working even though we mention open source models ? Please suggest @Logan M

#pip install llama-index-llms-groq
from llama_index.llms.groq import Groq
#pip install python-dotenv
from dotenv import load_dotenv
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
from llama_index.core import PromptTemplate, Settings
from llama_index.core.embeddings import resolve_embed_model

def groq_ingest_load(query):
# only load PDFs files
required_exts = [".pdf"]

# load documents
loader = SimpleDirectoryReader(
"data",
required_exts= required_exts
)

documents = loader.load_data()

# create embeddings using HuggingFace model
embed_model = resolve_embed_model("local:BAAI/bge-small-en-v1.5")

prompt = PromptTemplate(template = template)

# define llms
llm = Groq(model="llama3-8b-8192", request_timeout= 3000)

# setting up llm and output tokens
Settings.llm = llm
Settings.num_output = 250

# define index
index = VectorStoreIndex.from_documents(documents)

# define query engine
query_engine = index.as_query_engine()

# Ask query and get response
response = query_engine.query(query)

print(response)
2 comments
p
L
Yes. I am trying to use the same. As mentioned in the documentation and code trying to initialize loader by passing :
loader = S3Reader(bucket = "value" , aws_access_id ="value", aws_secret_access = "value", s3_endpoint_url = "value")
but, it keeps giving error : TypeError : object,init() takes exaclty one argument (the instance to initialize) (in llamahub_modules/s3/base.py)
@Logan M
2 comments
p
L
I have upgraded llama_index to latest version : 0.6.20 and trying to run below code :

from llama_index import SimpleDirectoryReader

documents = SimpleDirectoryReader("./data", filename_as_id=True).load_data()

But, getting below error :
documents = SimpleDirectoryReader("input/multi", filename_as_id=True).load_data()
TypeError: init() got an unexpected keyword argument 'filename_as_id'
6 comments
p
L
E
I need to scan over 100 of word documents placed in a folder and querying over it. What would be the best practice to do it ? I think I can still do it using the basic code but not sure whether it is advisable ? Do I need to go for any other kind of indexes ? Do I need to persist the vector in some vector database and ask queries on top of it ?

documents = SimpleDirectoryReader('pdf').load_data()
index = GPTVectorStoreIndex.from_documents(documents)

query_engine = index.as_query_engine()
response = query_engine.query("Explain the concept of encoders and decoders")
print(response)
1 comment
L