Skip to content

Accessing Data in a Knowledge Base

You can Search or Query the Knowledge Base for information contained in your Data Sources. Search will return a natural language response while Query will return the individual entries. Use whichever one best fits your use case.

From the Cloud Console

You can explore your data with a natural language question on the Test tab of your Knowledge Base. Compare and contrast the results of Search vs. Query to understand which is correct for your application.

From the API

You can enact both Search and Query via the API by hitting their respective endpoints using a Griptape Cloud API Key and the Knowledge Base ID found on the Config tab of your Knowledge Base.

The following example commands will send the string "test question" and return the results from the Knowledge Base.

export GT_CLOUD_API_KEY=<your API key here>
export KNOWLEDGE_BASE_ID=<your knowledge base id here>
curl -H "Authorization: Bearer ${GT_CLOUD_API_KEY}" --json '{"query": "test question"}' https://cloud.griptape.ai/api/knowledge-bases/${KNOWLEDGE_BASE_ID}/search

Query

export GT_CLOUD_API_KEY=<your API key here>
export KNOWLEDGE_BASE_ID=<your knowledge base id here>
curl -H "Authorization: Bearer ${GT_CLOUD_API_KEY}" --json '{"query": "test question"}' https://cloud.griptape.ai/api/knowledge-bases/${KNOWLEDGE_BASE_ID}/query

Using the Griptape Framework

You can use the GriptapeCloudKnowledgeBaseVectorStoreDriver to query your Knowledge Base with Griptape and the GriptapeCloudKnowledgeBaseTool to search.