Find answers from the community

Home
Members
Łukasz
Ł
Łukasz
Offline, last seen 3 months ago
Joined September 25, 2024
Hi, this is a more general question - does anyone care about typing in the python/AI world at all? As my app is getting more users, stability is becoming increasingly important to me. Yet, I see that most libraries do not bother to provide explicit type definitions, llama_index among them. This leaves me with the option to either stub the types for each library (plenty of work) or ignore them altogether. Am I alone in this? I come from a Java/Scala background and this lack of type strictness is driving me nuts. Typescript seems miles ahead in terms of enabling maintainable code. I'm looking for general recommendations on how to approach this
23 comments
L
Ł
s
I suppose this is a bug, just wanted to double check before reporting it
10 comments
Ł
L
Hi, I have a fairly simple use case - my dataset is small enough to always fit into a query, so I'm always preparing a single manual TextNode and creating a new index with that:

Plain Text
nodes = [TextNode(text=input)]
index = VectorStoreIndex(nodes=nodes, show_progress=True)
query_engine = index.as_query_engine()
prompt = get_prompt_from_promptlayer(name)
result = await query_engine.aquery(prompt)

I noticed that my llama_index is still creating embeddings for my query - why would it do that? How can I tell it to just use the nodes I have provided? Also, is there any direct benefit for using llama_index with such a use case?
6 comments
L
Ł
Hi, I'm looking to label nodes with keywords out of a specific set (up to 5). The keywords indicate whether a particular node contains a piece of information, like so:

  • contains_x
  • contains_y
Currently I'm doing with a CustomExtractor :

Plain Text
class CustomExtractor(MetadataFeatureExtractor):
    def class_name():
        return "CustomExtractor"

    def extract(self, nodes):
        metadata_list = [
            {
                "custom": (
                    node.metadata["contains_x"]
                    + "\n"
                    + node.metadata["contains_y"]
                    + "\n"
                    + node.metadata["contains_z"]
                )
            }
            for node in nodes
        ]
        return metadata_list


This yields good results, but I don't know how to combine this with querying. I'd like to convert (x,y,z) into keywords, and then filter out all nodes that don't match. So that's either;

  • using a KeywordTableIndex, however I can't supply a custom list of keywords, I'd probably need to write some totally custom index implementation
  • using a VectorIndex and filtering out by the metadata
What would be the best way forward to achieve this? Thanks a lot for your help
5 comments
Ł
r
T