Skip to main content

llama-index tools cogniswitch integration

Project description

Cogniswitch ToolSpec

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. Get started by interacting with your knowledge in just three simple steps

visit https://www.cogniswitch.ai/developer.

Registration:

  • Signup with your email and verify your registration
  • You will get a mail with a platform token and OAuth token for using the services.

Step 1: Instantiate the Cogniswitch ToolSpec:

  • Use your Cogniswitch token, openAI API key, OAuth token to instantiate the toolspec.

Step 2: Instantiate the Agent:

  • Instantiate the agent with the list of tools from the toolspec.

Step 3: Cogniswitch Store data:

  • Make the call to the agent by giving the file path or url to the agent input.
  • The agent will pick the tool and use the file/url and it will be processed and stored in your knowledge store.
  • You can check the status of document processing with a call to the agent. Alternatively you can also check in [cogniswitch console](- You can check the status of document processing with a call to the agent. Alternatively you can also check in cogniswitch console.

Step 4: Cogniswitch Answer:

  • Make the call to the agent by giving query as agent input.
  • You will get the answer from your knowledge as the response.

Import Required Libraries

import warnings

warnings.filterwarnings("ignore")
import os
from llama_index.tools.cogniswitch import CogniswitchToolSpec
from llama_index.core.agent import ReActAgent

Cogniswitch Credentials and OpenAI token

# os.environ["OPENAI_API_KEY"] = <your openai token>
# cs_token = <your cogniswitch platform token>
# oauth_token = <your cogniswitch apikey>

Instantiate the Tool Spec

toolspec = CogniswitchToolSpec(cs_token=cs_token, apiKey=oauth_token)

Get the list of tools

tool_lst = toolspec.to_tool_list()

Instantiate the agent with the tool list

agent = ReActAgent.from_tools(tool_lst)

Use the agent for storing data in cogniswitch with a single call

store_response = agent.chat(
    """
                            https://cogniswitch.ai/developer
                            this site is about cogniswitch website for developers.
                           """
)
print(store_response)
{'data': {'knowledgeSourceId': 43, 'sourceType': 'https://cogniswitch.ai/developer', 'sourceURL': None, 'sourceFileName': None, 'sourceName': 'Cogniswitch dev', 'sourceDescription': 'This is a cogniswitch website for developers.', 'status': 'UPLOADED'}, 'list': None, 'message': "We're processing your content & will send you an email on completion, hang tight!", 'statusCode': 1000}

Use the agent to know the document status with a single call

response = agent.chat("Tell me the status of Cogniswitch Developer Website")
print(response)
The document "Cogniswitch Developer Website" is currently being processed.

Use the agent for answering a query with a single call

answer_response = agent.chat("tell me about cogniswitch")
print(answer_response)
{'data': {'answer': 'CogniSwitch is a technology platform that enhances the reliability of Generative AI applications for enterprises. It does this by gathering and organizing knowledge from documented sources, eliminating hallucinations and bias in AI responses. The platform uses AI to automatically gather and organize knowledge, which can then be reviewed and curated by experts before being published. The CogniSwitch API enables Gen AI applications to access this knowledge as needed, ensuring reliability. It is specifically designed to complement Generative AI and offers customized solutions for different business functions within an enterprise.'}, 'list': None, 'message': None, 'statusCode': 1000}

The tool is designed to store data and retrieve answers based on the knowledge provided. check out the link for examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_cogniswitch-0.5.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_cogniswitch-0.5.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_cogniswitch-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_cogniswitch-0.5.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_cogniswitch-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0d07417536914b6f1dc33f888131d5cedd51e20425adb4ad309c2f3b22cd7173
MD5 4504a5b2de70b445840c695ad4d058b6
BLAKE2b-256 6ca78be88d06dab06e0d6851f9f86dc69f24ec1975a41429bf5ba1729a5338db

See more details on using hashes here.

File details

Details for the file llama_index_tools_cogniswitch-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_tools_cogniswitch-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_cogniswitch-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c16c1e8d5d4da8206fd3b06488931a1487ff915b086202110c40951c84b4c37
MD5 0b9ba6b7de1dbbc821ebc3927aa0fd71
BLAKE2b-256 64a691a1e757f92f12433724193da46969f013414fd47cb1ab837d65f6024c0d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page