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 framework (e.g., vLLM) are compatible with OpenAI client library, you can refer to their docs to know how 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, r3])

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.4.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.4-py3-none-any.whl (84.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: brainary-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 57421b5306d444e61af34cc7877341aa4d1bd5a0b309163b537e7748fed878ea
MD5 5e2765e46928b07158db719e08b622aa
BLAKE2b-256 04a5e2e4323150bc78df343b9e2be1fb24df19ffc38153508681325f8c459521

See more details on using hashes here.

File details

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

File metadata

  • Download URL: brainary-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9a88f60572b201a452fca1d706b6f471505481e2dc5048abbbee3429f9e7f6a5
MD5 34088c0ae41ee3ab118d7ae8e1f44876
BLAKE2b-256 ae81a4e35d0cb5f5eea8613d85dbc3124234a49fbffcf17b763d626640922934

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