Skip to main content

A cognitive architecture framework integrating LLMs, capabilities, and self-regulation.

Project description

Brainary

Brainary is a Python framework for building cognitive architectures that integrate LLMs, self-regulation, and multiple capabilities such as reasoning, planning, and evaluation.

Installation

pip install brainary

Usage

Create a configure file llm.yml to specify the API key or Base Url for OpenAI client creation. Note that, many LLM services (e.g., DeepSeek) or serving frameworks (e.g., vLLM) are compatible with OpenAI client library, you can refer to their docs to configure the API key or Base Url.

# llm.yml
api-key: sk-proj-...

# base-url: http://...

An example:

from typing import List
import brainary
from brainary.util.logging_util import init_logging

init_logging()

brainary.install_vm("gpt-4o-mini")

Review = brainary.define_type(
    type_name="Review",
    text={"type": str, "desc": "review content"},
    author={"type": str, "desc": "reviewer name"}
)
Movie = brainary.define_type(
    type_name="Movie",
    name={"type": str, "desc": ""},
    year={"type": int, "desc": "release year"},
    reviews={"type": List[Review], "desc": "reviews of the movie"}
)
r1 = Review(text="When this came out, I was living with a roommate. He went out and saw it, came home and said, \"Dude, you have to go see The Matrix.\" So we left and he sat through it a second time. This movie is splendidly done. The mystery about what the Matrix is, unravels and you see a dystopian future unlike any we as a race would want. I have watched this over and over and never tire of it. Everyone does a great job acting in this, the special effects are above par and the story is engaging.", author="acedj")
r2 = Review(text="This was a real change in filmmaking. Like watching it again in 2020, i.e. after 21 years and it still feels fresh. Iconic scenes are still having benchmarks setting up.\n\nIf we say it sci-fi at its best, it won't be wrong. The hype was real, it is still not easy to match the level of Matrix where we experience the connection of humans and science, that too with amazing action fight and chase scenes, not just normal scenes they were, multiple exposures, slow motion 3D moves, Oh My God, and it's understandable as well like what are the characters up to and what storyline they are entering into. The script was very well written and executed otherwise it could have been a mess. A special appreciation in managing the theme with those black color costumes and a scientific zone with unimaginable equipment and props doing unbelievable things in the two worlds created. No spoilers, but the action scenes in the climax where the protagonist goes to save someone from agents are really breathtaking. The technology used at its best.\n\nA salute to Wachowski Brothers and the team for creating this masterpiece. It will be a great competition and motivation as well for many films coming in the future.", author="suryanmukul")
m = Movie(name="Matrix", year=1999, reviews=[r1, r2])

if brainary.examine("The sentiment of the review is negative.", review=r1):
    print("===== Negative Review =====")

summarize = brainary.define_action("Summarize the movie reviews.", "movie", attentions=["sentiment", "character"], output_constraints={"tone": "grandiloquent"})
summarize(movie=m)

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

brainary-0.0.9.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

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

brainary-0.0.9-py3-none-any.whl (86.4 kB view details)

Uploaded Python 3

File details

Details for the file brainary-0.0.9.tar.gz.

File metadata

  • Download URL: brainary-0.0.9.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for brainary-0.0.9.tar.gz
Algorithm Hash digest
SHA256 ee7a60f2d1a76ae77354b7a6f0cc72b5d9308bf0e24da4bfe387fe46a4c7e355
MD5 1ff555a0d86b56989efe49a0b596bb42
BLAKE2b-256 135906309877d05a84544eabe0c34592d6f7a6f55c9b15e14642f0734ec1644b

See more details on using hashes here.

File details

Details for the file brainary-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: brainary-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 86.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for brainary-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e924db1dd6bed8007bfd552220e0f1078e4bf8ae0daf5f22f2490994a4a793a9
MD5 6ecc8c1f3b150fa9d00c85bc1f518282
BLAKE2b-256 82fb5d0d17571cb3c81a4b756e6a4e201dd6b296c0a6b020f51a01855c0ddb39

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