Skip to main content

A canvas langchain integration

Project description

Canvas langchain document loader

Features:

Indexes Canvas Modules, Pages, Announcements, Assignments and Files

The following file types are supported: md htm html docx xls xlsx pptx pdf rtf txt

(doc support would require libreoffice, so has not been implemented in this library)

Running locally (development)

You can build/run the provided Dockerfile, or install dependencies as described below

Docker

Edit canvas-test.py, fill in the correct api_url, api_key, and course_id.

Run (this also builds docker):

docker run -it $(docker build -q .)

Install Dependencies

pip install -r requirements.txt

Usage example:

from canvas_langchain.canvas import CanvasLoader

loader = CanvasLoader(
	api_url = "https://CANVAS_API_URL_GOES_HERE",
	course_id = CANVAS_ID_GOES_HERE,
	api_key = "API_KEY_GOES_HERE"
)

try:
	documents = loader.load()

	print("\nDocuments:\n")
	print(documents)

	print("\nInvalid files:\n")
	print(loader.invalid_files)
	print("")

	print("\nErrors:\n")
	print(loader.errors)
	print("")

	print("\nIndexed:\n")
	print(loader.indexed_items)
	print("")

	print("\nProgress:\n")
	print(loader.get_details('DEBUG'))
	print("")
except Exception:
	details = loader.get_details('DEBUG')

If errors are present, loader.errors will contain one list element per error. It will consist of an error message (key named message) and if the error pertains to a specific item within canvas, it will list the entity_type and the entity_id of the resource where the exception occurred.

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

canvas_langchain-0.9.17.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

canvas_langchain-0.9.17-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file canvas_langchain-0.9.17.tar.gz.

File metadata

  • Download URL: canvas_langchain-0.9.17.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for canvas_langchain-0.9.17.tar.gz
Algorithm Hash digest
SHA256 103a0ff716ef1104140ac61003e8e6725133c0ad272381dd6bb223d7f95b75a8
MD5 6bc76df57ff7a30173d27144f01824cc
BLAKE2b-256 43010d203700c73c5b9ca56461d2b35c91b68ae7902e70a32e5a84334573e84a

See more details on using hashes here.

File details

Details for the file canvas_langchain-0.9.17-py3-none-any.whl.

File metadata

File hashes

Hashes for canvas_langchain-0.9.17-py3-none-any.whl
Algorithm Hash digest
SHA256 ae97c18c2197a2634d795ca3bd4d24a4637991b4d71283bd935098fc8cd13fe1
MD5 f028cf2ec92a8bbfe92230ea6cfd6d12
BLAKE2b-256 af301da851fca00bc436ce1b31571b3fdab2ad5f2ee96a440528421ea465075c

See more details on using hashes here.

Supported by

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