LLM extensions framework
Project description
GalaxyBrain
Turning LLMs into mighty shape rotators!
Goals
- Reduce surprises when it comes to working with LLMs.
- Focus on production use cases and CI/CD compatibility.
- Avoid bloat and keep base primitives simple.
Getting Started
First, install the library:
pip install galaxybrain
Currently, GalaxyBrain only supports OpenAI APIs, so you'll need to get an API key. You can then either keep it on your path as OPENAI_API_KEY
or pass it to the completion object manually:
api_key = ...
OpenAiCompletion(api_key)
Here is an example of some of GalaxyBrain's functionality:
from galaxybrain.completions import OpenAiCompletion
from galaxybrain.memory import Memory
from galaxybrain.prompts import Prompt
import galaxybrain.rules.json as json_rules
from galaxybrain.completions import Validator
completion = OpenAiCompletion(api_key, temperature=0.9, user="demo")
memory = Memory()
rules = [
json_rules.return_valid_json(),
json_rules.put_answer_in_field("Names"),
Rule("only use information from fantasy novels")
]
completion.complete(
Prompt("Give me ideas for two names from the same universe", memory=memory, rules=rules)
)
# Output:
# {
# "Names": ["Frodo Baggins", "Gandalf the Grey"]
# }
result = completion.complete(
Prompt("Give me 3 more from another universe", memory=memory)
)
# Output:
# {
# "Names": ["Dumbledore", "Luna Lovegood", "Harry Potter"]
# }
You can also validate results against your rules:
validator = Validator(result, rules)
if validator.validate():
print("Rule validations passed")
else:
print("Rule validations failed")
print(validator.failed_rules())
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
galaxybrain-0.0.2.tar.gz
(10.7 kB
view details)
File details
Details for the file galaxybrain-0.0.2.tar.gz
.
File metadata
- Download URL: galaxybrain-0.0.2.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 400f1b6e6fbdb8aedaecc8d28212cca676cebe375adaa23e1a8b996b30573c17 |
|
MD5 | 139b261d79a21c351312ef5fe9338234 |
|
BLAKE2b-256 | 37009a9f8dc583a6b76322950d4e8c6accdc97a11473397bed49aba46cbef8b3 |