Find answers from the community

S
SeaCat
Offline, last seen 3 months ago
Joined September 25, 2024
S
SeaCat
·

Index

Hi, I wonder if indexing can be done using the Claude models? If so, which model should I use? Thanks!
4 comments
t
S
L
Hi, I have a very simple question that I can't find an answer to, though. When talking about chunk size, which units do you mean? Tokens? Words? Characters? Bytes? Thanks!
2 comments
S
L
S
SeaCat
·

Chat engine

Hello! When I'm trying to use an agent with QueryEngineTool to look for answer in the context, there is an exception and I see some inconsistence.
Despite the method is called "chat" for the agent, it doesn't accept engine created with "as_chat_engine" method:

Plain Text
query_engine = index.as_chat_engine(chat_mode='condense_plus_context', 
                                                similarity_top_k=similarity_top_k, 
                                                llm=llm_engine,
                                                system_prompt=prepared_system_prompt)

query_tool =  QueryEngineTool(
            query_engine=query_engine,
            metadata=ToolMetadata(
                name="query_tool",
                description=self.query_description,
            ),
        )
tools.append(query_tool)
agent = OpenAIAgent.from_tools(
            tools, llm=llm_engine, 
            verbose=True, 
            system_prompt=self.system_prompt
        )
response = agent.chat(query_text, chat_history=chat_history) # <====== Exception

The exception is "Got output: Error: 'CondensePlusContextChatEngine' object has no attribute 'query'"
15 comments
S
L
Hi, how to pass the chunk size and embed model if ServiceContext is not in use anymore? My code:

Plain Text
    vector_store = storage_service.get_vector_store(collection_name, db_name)
    embed_model = OpenAIEmbedding(mode='similarity', embed_batch_size=2000, api_key=api_Key)
    service_context = ServiceContext.from_defaults(chunk_size=project_chunk_size, embed_model=embed_model,
                                                    llm=None,
                                                    callback_manager=token_counter_callback_manager)
    node_parser = SimpleNodeParser.from_defaults(chunk_size=project_chunk_size, chunk_overlap=20)
    index = VectorStoreIndex.from_vector_store(vector_store=vector_store, service_context=service_context)

The StorageContext doesn't have those parameters. Thanks!
11 comments
L
S
W
Hi, how to stop an agent from making up a "nice" answer and returning just a rough response from the tool? For example, if I use the Image generator tool, it gives the right output but the anwer is always verbose:

Plain Text
from llama_index.agent.openai import OpenAIAgentWorker, OpenAIAgent
# Import and initialize our tool spec
from .image_tool_spec import TextToImageToolSpec

text_to_image_spec = TextToImageToolSpec()
tools = text_to_image_spec.to_tool_list()
# Create the Agent with our tools
agent = OpenAIAgent.from_tools(tools, verbose=False)
print(agent.chat("show an of a beautiful beach with a palm tree at sunset"))

Thanks!
8 comments
L
S
Hi, I'm trying to implement an OpeAIAgent on my custom data but can't figure out how to pass the retriever and service context. LlamaIndex v 0.9.46. I'm not sure if I have to create a separate tool for it. Thanks

Plain Text
# My current approach
chatmemory = ChatMemoryBuffer.from_defaults(token_limit=(history_limit + context_limit))
retriever = index.as_retriever(verbose=True, chat_mode="context", similarity_top_k=similarity_top_k)
custom_chat_engine = CustomContext.from_defaults( # Inherits ContextChatEngine and slightly changes it
                                    retriever=retriever,
                                    memory=chatmemory, 
                                    context_template=generate_context_template(),
                                    system_prompt=prepared_system_prompt,
                                    node_postprocessors=[CustomPostprocessor(
                                            context_limit, query_text + prepared_system_prompt, project.db_name, include_threshold)],
                                    service_context=service_context)
response = custom_chat_engine.chat(query_text, chat_history=chat_history)


Plain Text
OpenAIAgent.from_tools(??)
51 comments
S
L
TokenCounter doesn't count tokens.
At some moment, it stopped working. Here is the code:
Plain Text
token_counter = TokenCountingHandler(
            tokenizer=tiktoken.encoding_for_model(model_name).encode,
            verbose=False  
        )
callback_manager = CallbackManager([token_counter])
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, chunk_size=project_chunk_size, 
                                                        callback_manager=callback_manager)
index = VectorStoreIndex.from_vector_store(vector_store, service_context)
retriever = index.as_retriever(verbose=True, chat_mode="context", similarity_top_k=similarity_top_k)
custom_chat_engine = CustomContext.from_defaults(
                                    retriever=retriever,
                                    memory=chatmemory, 
                                    context_template=generate_context_template(),
                                    system_prompt=prepared_system_prompt,
                                    node_postprocessors=[CustomPostprocessor(
                                            context_limit, query_text + prepared_system_prompt, project.db_name, None)])
response = custom_chat_engine.chat(query_text, chat_history=chat_history)
tokens_used = token_counter.total_llm_token_count # <----- ALWAYS ZERO

Thanks!
9 comments
S
L
Memory leak?

Hi, I found that when I index multiple-page documents, my server stops working at some point. After investigation, I found that this code is consuming memory what probably causes a huge memory leak and falling down the server, as a result (THE LAST LINE):
Plain Text
    vector_store = storage_service.get_vector_store(collection_name, db_name)
    storage_context = StorageContext.from_defaults(vector_store=vector_store)
    embed_model = OpenAIEmbedding(mode='similarity', embed_batch_size=2000, api_key=user_settings_data.item.get('openai_key'))

    service_context = ServiceContext.from_defaults(chunk_size=chunk_size, embed_model=embed_model,
                                                    llm=None,
                                                    callback_manager=token_counter_callback_manager)
    node_parser = SimpleNodeParser.from_defaults(chunk_size=chunk_size, chunk_overlap=20)
    VectorStoreIndex(nodes, storage_context=storage_context, service_context=service_context) # <== THIS

I was thinking may be I can create a vectore store index just once, just add nodes to it but it's not working:

Plain Text
index = VectorStoreIndex.from_vector_store(vector_store=vector_store, service_context=service_context)
index._add_nodes_to_index(nodes=content_nodes) # <== EXCEPTION: index structure is not provided

Please help, thanks!
26 comments
L
S
n
Hi, with ContextChatEngine is there any reliable way to get answers only from the context? Pretty often, I face the situation when it can't find the relevant data in the context and takes it from its generic knowledge what is usually pretty wrong. Thanks.
Plain Text
retriever = index.as_retriever(verbose=True, chat_mode="context", similarity_top_k=similarity_top_k)
# CustomContext inherits the ContextChatEngine, and just has a small changes for the best results.
custom_chat_engine = CustomContext.from_defaults(
                                    retriever=retriever,
                                    memory=chatmemory, 
                                    context_template=generate_context_template(),
                                    system_prompt=prepared_system_prompt,
                                    node_postprocessors=[CustomPostprocessor(
                                            context_limit, query_text + prepared_system_prompt, project.db_name, None)])
response = custom_chat_engine.chat(query_text, chat_history=chat_history)
2 comments
S
a
Any thoughts?
7 comments
L
S
S
SeaCat
·

Nodes

Hello!
After updating LlamaIndex I face the problem that get_nodes_from_documents doesn't return NodesWithEmbeddings but just TextNodes. How can I create a VectoreStoreIndex without them? Thanks

Plain Text
        node_parser = SimpleNodeParser.from_defaults(chunk_size=chunk_size, chunk_overlap=20)
        content_nodes = node_parser.get_nodes_from_documents([document]) 
        index = VectorStoreIndex(content_nodes, storage_context=storage_context, service_context=service_context)
15 comments
S
L
One more question, this time about prompts. How can I see the eventual prompt that is being sent to OpenAI? I have very strange results with some questions, and I'm pretty sure the context data is okay but the result is just weird. I'd like to see which exact prompt is generated and sent to OpenAI. Thanks!
2 comments
S
L
Hi, after updating LlamaIndex to the latest I see the exception "'openai' has no attribute 'error'" fired here "site-packages\langchain\chat_models\openai.py", line 77" but not sure how to fix it. Thanks!
20 comments
S
L
S
SeaCat
·

Images

Hi, I heard ChatGPT-4 now can recognize images. But when I'm trying to pass a link to an image, it responds " I'm sorry, but I don't have the ability to recognize or interpret images. I can only assist with text-based information." I was using gpt-4 model. Should I do something specific to make it work, or use a different model? Thanks!
4 comments
S
L
S
SeaCat
·

Hi

Hi,
when indexing text, how can I pass the OpenAI key to it? It can't be read from the environment variable, only passed. It varies from user to user, we store it as encrypted string.
My code:
Plain Text
embed_model = OpenAIEmbedding(mode='similarity', embed_batch_size=2000)
service_context = ServiceContext.from_defaults(chunk_size=chunk_size, embed_model=embed_model,
                                                        callback_manager=token_counter_callback_manager)
node_parser = SimpleNodeParser.from_defaults(chunk_size=chunk_size, chunk_overlap=20)
index = VectorStoreIndex(nodes, storage_context=storage_context, service_context=service_context)

Thank you!
28 comments
S
L
S
SeaCat
·

Hi

Hi!
I have a problem. When indexing documents with Cyrillic text, it takes ages and creates and incredible amount of documents. It would be fine (because of the nature of unicode-encoded text) but probably there is some timeout error or so. When digesting just 130 not-too-big documents, it never ends. Is there any solution to this problem? Thanks!
5 comments
S
L
S
SeaCat
·

Top k

Hi! Is there any way to see how big text nodes that will be sent as context? I need to know in advance because in some cases, when similarity_top_k is 5, I don't want the exception to be thrown because text nodes are too big, then I would prefer to search with similarity_top_k 4 or 3.
25 comments
L
S
S
SeaCat
·

Hello

Hello!
A very quick question.
I'm using a chat engine, here is my code:
Plain Text
query_engine = index.as_chat_engine(verbose=True,chat_mode="context",
                system_prompt=system_prompt)
response = query_engine.chat(query_text, chat_history=chat_history)

The question is - how big the prompt can be here? Are there any limitations to its length, or some numbers when a chatbot stops "thinking" properly, or there is nothing like that?
Thanks! You created a great product!🥰
6 comments
S
L
S
SeaCat
·

Nodes

Hi!
When creating a new index based on documents, how can I check the nodes it creates? I found a strange problem when nodes getting from Qdrant collection doesn't have the information it should have and show the information that the collection doesn't have. As a result, the querying doesn't return a correct result. So, firstly I'd like to check the nodes when creating index. Thanks!
5 comments
S
L
S
SeaCat
·

Context

Hi, is it possible to ask ChatGPT without the context? In my case, sometimes there is no data provided but I still want to hear a reasonable answer (like greeting etc.). But when no node is found query_engine.query always returns the response object which is None, how to work around it? Thanks!
26 comments
L
S
W
Hi, I see a very strange problem when parsing a text of ~60,000 symbols - this code (the from_documents function) never ends, I can't figure out why, it worked very well till today (even with much bigger documents):
Plain Text
document = Document(text)
document.doc_id = data_source_id
service_context = ServiceContext.from_defaults(chunk_size=chunk_size)#1024)
vector_store = QdrantVectorStore(client=get_qrant_client(), collection_name=project_id)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
    [document], storage_context=storage_context, service_context=service_context
)

If I go into the function from_documents, this code is hanging:
Plain Text
            return cls(
                nodes=nodes,
                storage_context=storage_context,
                service_context=service_context,
                **kwargs,
            )
18 comments
S
L
Hi, sometimes I see the following problem: even although Nodes that are in the query have the proper found text information, ChatGPT can't find the answer. What could be the reason and how it could be solved? Thanks! (In the example below, it can't find the answer to the second question although the nodes have the proper found text):

How can I pay?You can pay using various methods such as PayPal Friends & Family, bank card payments, bank transfers, Apple Pay, and Google Pay. Please note that availability may vary depending on your country.Can I pay with paypal?I apologize but I don't know the answer.
2 comments
S
W
Hi, is it possible to know which document/link was used? Say, I have several documents, when the answer was found in a specific one, how to know which document was it? Thanks!
6 comments
S
L
Hi, I found a strange problem. If a question is asked in a launguage different from English, the response somtimes is cut in the middle of word if it's not very short. For example, I ask a question and response is cut, its length is 251 symbols. Not sure why is that and how to fix it. Thanks!
2 comments
S
L
Hi, how can I change the response if the answer is not found? Right now I have the following text "There is no information provided in the context about where employees will use this for internal needs." Is it possible to answer something like "I'm sorry I don't know where employees will use this for internal needs." ? Thanks!
7 comments
S
L