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.6.tar.gz (57.8 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.6-py3-none-any.whl (84.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: brainary-0.0.6.tar.gz
  • Upload date:
  • Size: 57.8 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.6.tar.gz
Algorithm Hash digest
SHA256 42595a8dfa614049b6c04442bc12014d02b9887434b0a9b27e4efe49fe1b9c85
MD5 58698eee8ea25334583c04731c3120aa
BLAKE2b-256 fe723b53db55c89efae2bc845f8874301565e6f45f4c0dab1f4514fcdcd463bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: brainary-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 84.1 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ae0148aeda155cbb84fd0f316f4ac93f69ecb0312feac9ab8cd15ec4bd315fac
MD5 44ae819f5f1cd3ee6993985b353a3385
BLAKE2b-256 215f3f354ca57c2843c0a422185f54b5564c4dd879665eab654345d29df84688

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