Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
152 lines (105 loc) · 4.19 KB

File metadata and controls

152 lines (105 loc) · 4.19 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

Listing and Searching Documents

---
depth: 2
local: true
backlinks: none
---

Implementing the Method

  • Edit the RetrievalAugmentedGeneration/examples/simple_rag_api_catalog/chains.py file and add the following statements after the import statements.

    • Replace the document_search method with the following code:

      :language: python
      :start-after: start-document-search-method
      :end-before: end-document-search-method
      
    • Replace the get_documents method with the following code:

      :language: python
      :start-after: start-get-documents-method
      :end-before: end-get-documents-method
      
    • Replace the delete_documents method with the following code:

      :language: python
      :start-after: start-delete-documents-method
      :end-before: end-delete-documents-method
      

Building and Running with Docker Compose

Using the containers has one additional step this time: exporting your NVIDIA API key as an environment variable.

  1. Build the container for the Chain Server:

    $ docker compose --env-file deploy/compose/compose.env -f deploy/compose/simple-rag-api-catalog.yaml build chain-server
  2. Export your NVIDIA API key in an environment variable:

    $ export NVIDIA_API_KEY=nvapi-...
  3. Run the containers:

    $ docker compose --env-file deploy/compose/compose.env -f deploy/compose/simple-rag-api-catalog.yaml up -d

Verify the Ingest Docs Method Using Curl

You can access the Chain Server with a URL like http://localhost:8081.

  • Upload the README from the repository:

    $ curl http://localhost:8081/documents -F "file=@README.md"

    Example Output

    :language: json
    
  • List the ingested documents:

    $ curl -X GET http://localhost:8081/documents

    Example Output

    :language: json
    
  • Submit a query to search the documents:

    $ curl -H "Content-Type: application/json" \
        http://localhost:8081/search \
        -d '{"query":"Does NVIDIA have sample RAG code?", "top_k":1}'

    Example Output

    :language: json
    
  • Confirm that the search returns relevant documents:

    $ curl -H "Content-Type: application/json" \
        http://localhost:8081/search \
        -d '{"query":"Is vanilla ice cream better than chocolate ice cream?", "top_k":1}'

    Example Output

    :language: json
    
  • Confirm the delete method works:

    $ curl -X DELETE http://localhost:8081/documents\?filename\=README.md

    Example Output

    :language: json
    

Next Steps

  • You can stop the containers by running the docker compose -f deploy/compose/simple-rag-api-catalog.yaml down command.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.