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 endpoint not returning data with Milvus #61

Open
nkeilar opened this issue Mar 26, 2023 · 11 comments
Open

query endpoint not returning data with Milvus #61

nkeilar opened this issue Mar 26, 2023 · 11 comments

Comments

@nkeilar
Copy link

nkeilar commented Mar 26, 2023

I've setup the project locally, inserted the example zip file using the Milvus datastore.

When I run a query command in Postman I'm not getting any results. Am I missing something?

Starting application

$ poetry run start
INFO:     Will watch for changes in these directories: ['/home/nathank/workspace/chatgpt-retrieval-plugin']
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [284968] using StatReload
INFO:     Started server process [285005]
INFO:     Waiting for application startup.
Attempting creation of Milvus default index
Creation of Milvus default index succesful
INFO:     Application startup complete.

process_zip

$ python process_zip.py --filepath '/home/XXX/Downloads/example.zip' 
Attempting creation of Milvus default index
Creation of Milvus default index succesful
Processed 0 documents
Error processing dump/__MACOSX/example/._document.pdf: EOF marker not found
Processed 0 documents
Error processing dump/__MACOSX/example/._Untitled presentation.pptx: File is not a zip file
Processed 0 documents
Error processing dump/__MACOSX/example/._document.txt: 'utf-8' codec can't decode byte 0xc8 in position 99: invalid continuation byte
Processed 0 documents
Error processing dump/__MACOSX/example/._document.docx: File is not a zip file
Processed 0 documents
extracted_text from dump/example/document.md
extracted_text from dump/example/document.docx
extracted_text from dump/example/Untitled presentation.pptx
extracted_text from dump/example/document.pdf
extracted_text from dump/example/document.txt
Upserting batch of 5 documents, batch 0
documents:  [Document(id='e238e070-7b0a-4db4-bf29-b06f0e4dff8b', text='This is an example markdown document\n', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.md', url=None, created_at=None, author=None)), Document(id='396342ec-078d-435c-87a1-6abde4587326', text='This is a test word document', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.docx', url=None, created_at=None, author=None)), Document(id='6c873341-dcc9-46a1-9412-5041f6dcf23f', text='This is an example Powerpoint \n', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='Untitled presentation.pptx', url=None, created_at=None, author=None)), Document(id='f5bf06ad-8a86-470b-a7ac-23243c339efe', text='T h i s\ni s\na\nt e s t\nP D F\nd o c u m e n t', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.pdf', url=None, created_at=None, author=None)), Document(id='e3b4677c-e1ca-4479-9122-8e8ec1ccf108', text='\ufeffThis is a test plaintext document', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.txt', url=None, created_at=None, author=None))]
Upserting batch of size 5
Upserted batch successfully
Skipped 4 files due to errors or PII detection
dump/__MACOSX/example/._document.pdf
dump/__MACOSX/example/._Untitled presentation.pptx
dump/__MACOSX/example/._document.txt
dump/__MACOSX/example/._document.docx
(chatgpt-retrieval-plugin-py3.10) (base) 

Query

image

@nkeilar
Copy link
Author

nkeilar commented Mar 26, 2023

This could be related with #51

@CyberAmyntas
Copy link
Contributor

Could you add a filter to the query and try again?

{
  "queries": [
    {
      "query": "string,
      "filter": {
        "source": "file"
      },
      "top_k": 3
    }
  ]
}

Also, check the zip and extracted docs are adding the right source type, like #32

1 similar comment
@CyberAmyntas
Copy link
Contributor

Could you add a filter to the query and try again?

{
  "queries": [
    {
      "query": "string,
      "filter": {
        "source": "file"
      },
      "top_k": 3
    }
  ]
}

Also, check the zip and extracted docs are adding the right source type, like #32

@nkeilar
Copy link
Author

nkeilar commented Mar 28, 2023

Pulled latest changes and retested, not working as I would expect (no results). I tried changing the query string to all sorts of things like "This is an example markdown document", "example" etc. No dice. Not getting any results.

Import process

$ python process_zip.py --filepath example.zip --screen_for_pii False --extract_metadata True
Attempting creation of Milvus default index
Creation of Milvus default index successful
Processed 0 documents
Error processing dump/__MACOSX/example/._document.pdf: EOF marker not found
Processed 0 documents
Error processing dump/__MACOSX/example/._Untitled presentation.pptx: File is not a zip file
Processed 0 documents
Error processing dump/__MACOSX/example/._document.txt: 'utf-8' codec can't decode byte 0xc8 in position 99: invalid continuation byte
Processed 0 documents
Error processing dump/__MACOSX/example/._document.docx: File is not a zip file
Processed 0 documents
extracted_text from dump/example/document.md
Completion: False.
Completion: {
  "source": "file"
}
completion: {
  "source": "file"
}
extracted_text from dump/example/document.docx
Completion: False
Completion: {
  "source": "file",
  "source_id": "document.docx"
}
completion: {
  "source": "file",
  "source_id": "document.docx"
}
extracted_text from dump/example/Untitled presentation.pptx
Completion: False.
Completion: {
  "source": "file",
  "source_id": "Untitled presentation.pptx"
}
completion: {
  "source": "file",
  "source_id": "Untitled presentation.pptx"
}
extracted_text from dump/example/document.pdf
Completion: False.
Completion: {
  "source": "file",
  "source_id": "document.pdf"
}
completion: {
  "source": "file",
  "source_id": "document.pdf"
}
extracted_text from dump/example/document.txt
Completion: False
Completion: {
  "source": "file",
  "source_id": "document.txt"
}
completion: {
  "source": "file",
  "source_id": "document.txt"
}
Upserting batch of 5 documents, batch 0
documents:  [Document(id='c43736b3-bc20-4bdd-af07-bcb4475fe246', text='This is an example markdown document\n', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id=None, url=None, created_at=None, author=None)), Document(id='8f413ca9-2bfe-4d82-90b1-cf51d52da048', text='This is a test word document', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.docx', url=None, created_at=None, author=None)), Document(id='7bfbaf13-6004-43d0-9725-1176e0590578', text='This is an example Powerpoint \n', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='Untitled presentation.pptx', url=None, created_at=None, author=None)), Document(id='47249c96-2e69-4e5a-94e2-d26d45901f1b', text='T h i s\ni s\na\nt e s t\nP D F\nd o c u m e n t', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.pdf', url=None, created_at=None, author=None)), Document(id='7af3a67a-ba93-4884-81eb-011e9321cb45', text='\ufeffThis is a test plaintext document', metadata=DocumentMetadata(source=<Source.file: 'file'>, source_id='document.txt', url=None, created_at=None, author=None))]
Upserting batch of size 5
Upserted batch successfully
Skipped 4 files due to errors or PII detection
dump/__MACOSX/example/._document.pdf
dump/__MACOSX/example/._Untitled presentation.pptx
dump/__MACOSX/example/._document.txt
dump/__MACOSX/example/._document.docx

Query, with no results
image

Server running

INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [721802] using StatReload
INFO:     Started server process [721838]
INFO:     Waiting for application startup.
Attempting creation of Milvus default index
Creation of Milvus default index successful
INFO:     Application startup complete.
INFO:     127.0.0.1:56862 - "POST /query HTTP/1.1" 200 OK
INFO:     127.0.0.1:48144 - "POST /query HTTP/1.1" 200 OK
INFO:     127.0.0.1:39730 - "POST /query HTTP/1.1" 200 OK
INFO:     127.0.0.1:52404 - "POST /query HTTP/1.1" 200 OK

@nkeilar
Copy link
Author

nkeilar commented Mar 28, 2023

@filip-halt Are you able to comment on this? How did you verify it working locally?

@filip-halt
Copy link
Contributor

@nkeilar Did you set the environment variable MILVUS_COLLECTION? The script directly connects to the vector store, it doesn't use the poetry server. I just tested it and it worked. If the collection isn't set, the server will run on its own uuid named collection and the script will push data into another uuid named collection.

@nkeilar
Copy link
Author

nkeilar commented Mar 28, 2023

@filip-halt thank you! That was indeed the issue. I can confirm after setting MILVUS_COLLECTION=somevalue for poetry server and also scripts/process_zip/process_zip.py it works as expected.

Recommendation: That we improve the documentation, as it appears to be an optional argument, which while may be true for the server, if not specified when importing data then data is imported somewhere random. Perhaps instead of a random UUID the defaults could be set to be the same for the script and server when using milvus.

I'm happy to make the change. Will just leave the comment here for a couple of days in case anyone has an opinion on best way to avoid others falling into this trap.

image

@filip-halt
Copy link
Contributor

Recommendation: That we improve the documentation, as it appears to be an optional argument, which while may be true for the server, if not specified when importing data then data is imported somewhere random. Perhaps instead of a random UUID the defaults could be set to be the same for the script and server when using milvus.

I set the name to be randomly generated as running the server twice or running two separate instances of retrieval on the same milvus server would result in shared data. I think a better route would be to have the scripts use the poetry server instead of creating their own DataStore instance. What do you think @isafulf ?

@lastrei
Copy link

lastrei commented Mar 31, 2023

oh man, i have the same trouble like you , when i post a document and query it , it's return well, when i restart the api , nothing return you notice me,

MILVUS_COLLECTION Optional Milvus collection name, defaults to a random UUID

when i restart the api , the uuid has changes
so,you must set MILVUS_COLLECTION on env

@filip-halt
Copy link
Contributor

@lastrei Ill see if I can add something into the documentation. I picked this route due to it being a lesser of two evils. If I hardcoded a value, then the information stores could clash if people share the Milvus server or if wanting to use two separate retrieval services.

@lastrei
Copy link

lastrei commented Apr 1, 2023

@lastrei Ill see if I can add something into the documentation. I picked this route due to it being a lesser of two evils. If I hardcoded a value, then the information stores could clash if people share the Milvus server or if wanting to use two separate retrieval services.

you are right ,hard code may cause these problems , but the code must save the connection name .. i write them in to a json file with connection name and Description

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

4 participants