Files
wehub-resource-sync a0c8464e58
Build Package / build (ubuntu-latest) (push) Failing after 1s
CodeQL / Analyze (python) (push) Failing after 1s
Core Typecheck / core-typecheck (push) Failing after 1s
Linting / lint (push) Failing after 1s
llama-dev tests / test-llama-dev (push) Failing after 1s
Publish Sub-Package to PyPI if Needed / publish_subpackage_if_needed (push) Has been skipped
Sync Docs to Developer Hub / sync-docs (push) Failing after 0s
Build Package / build (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:26:52 +08:00

139 lines
4.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "d19fac66",
"metadata": {},
"source": [
"## CogniswitchQueryEngine\n",
"\n",
"**Use CogniSwitch to build production ready applications that can consume, organize and retrieve knowledge flawlessly. Using the framework of your choice, in this case LlamaIndex, CogniSwitch helps alleviate the stress of decision making when it comes to choosing the right storage and retrieval formats. It also eradicates reliability issues and hallucinations when it comes to responses that are generated. Start interacting with your knowledge in 3 simple steps!**\n",
"\n",
"Visit [https://www.cogniswitch.ai/developer](https://www.cogniswitch.ai/developer?utm_source=llamaindex&utm_medium=llamaindexbuild&utm_id=dev).<br>\n",
"\n",
"**Registration:**\n",
"- Signup with your email and verify your registration\n",
"- You will get a mail with a platform token and oauth token for using the services.\n",
"\n",
"**Upload Knowledge:**\n",
"- There are two ways to add your knowledge into Cogniswitch.\n",
"1. You can sign-in to Cogniswitch website and upload your document files or submit a url from the Document Upload page.<br>\n",
"2. You can use the CogniswitchToolSpec in llama-hub tools to add document or a url in Cogniswitch.<br> \n",
"\n",
"**CogniswitchQueryEngine:**<br>\n",
"- Instantiate the cogniswitchQueryEngine with the tokens and API keys.\n",
"- Use query_knowledge function in the Query Engine and input your query. <br>\n",
"- You will get the answer from your knowledge as the response. <br>\n"
]
},
{
"cell_type": "markdown",
"id": "ce6a1c44",
"metadata": {},
"source": [
"### Import Required Libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eaeca557",
"metadata": {},
"outputs": [],
"source": [
"import warnings\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"from llama_index.core.query_engine import CogniswitchQueryEngine"
]
},
{
"cell_type": "markdown",
"id": "eecaa97a",
"metadata": {},
"source": [
"### Cogniswitch Credentials and OpenAI token"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "67ddc803",
"metadata": {},
"outputs": [],
"source": [
"# cs_token = <your cogniswitch platform token>\n",
"# OAI_token = <your openai token>\n",
"# oauth_token = <your cogniswitch apikey>"
]
},
{
"cell_type": "markdown",
"id": "7a6db5a6",
"metadata": {},
"source": [
"### Instantiate the Query Engine"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "38c9c80a",
"metadata": {},
"outputs": [],
"source": [
"query_engine = CogniswitchQueryEngine(\n",
" cs_token=cs_token, OAI_token=OAI_token, apiKey=oauth_token\n",
")"
]
},
{
"cell_type": "markdown",
"id": "52ddf809",
"metadata": {},
"source": [
"### Use the query_engine to chat with your knowledge"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2544cdc9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CogniSwitch is a platform that offers a range of features to users. It helps users organize, explore, and manage data in an intuitive way. The platform visualizes complex ideas, simplifies them, and fine-tunes knowledge. Users can also consume knowledge on-demand through the CogniSwitch API. Furthermore, CogniSwitch provides data storage management capabilities.\n"
]
}
],
"source": [
"answer_response = query_engine.query_knowledge(\"tell me about cogniswitch\")\n",
"print(answer_response)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "llama_index_env",
"language": "python",
"name": "llama_index_env"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}