a library for speaking with large langauge models using object orientated generation
Project description
Welcome
Welcome to funkyprompt. This is a lightweight library for building agent systems by the principle of Object Orientated Generation. This is a simple idea that says that we only need to focus on objects to build agentic systems.
There are actually only two abstractions that are important for working with large language models.
- The messages stack, a collection of messages with specific roles. The system message may be considered special in some models
- The function stack, a list of functions often descripted in Json Schema, that can be called.
In funkyprompt both of these stacks are always treated as dynamic inside a Runner's execution loop. Reasoning is carried out by starting with a system prompt that is always rendered as clean Markdown and then following the trail of function calls until completion. It should be possible to activate and recruit new functions during the execution loop.
Objects are represents by Pydantic or Markdown and their is invertible mapping between these two representations. OOG requires three things;
- Top level metadata or doc string for the system level prompt
- Fields with descriptions that managed structured output
- Class methods or auxillary API methods defined for the type
Here is a trivially simple example
from pydantic import Field
class TestObject(AbstractModel):
"""You are a simple agent that answers the users question with the help of functions.
Please respond in a structured format with fenced json. Using the response format provided"""
person: str = Field(description="A person that is of interest to the user")
color: str = Field(description="A color that the person likes")
object_of_color: str = Field(description="An object that is the color of the persons favorite color")
@classmethod
def favorite_color(cls, person:str):
"""
For three people Bob, Henrik and Ursula, you can ask for the favorite color and get an answer
Args:
person: the name of the person
"""
return {
"bob": "green",
"henrik": "yellow",
"ursula": "red"
}.get(person.lower())
@classmethod
def objects_of_color(cls, color:str):
"""
For a given color, get an object of this color
Args:
color: the color
"""
return {
"green": "turtle",
"yellow": "cup",
"red": "car"
}.get(color.lower())
agent = Runner(TestObject)
#use GPT by default or other models like claude or gemini
Markdown(agent("Tell me about henrik",
CallingContext(model='claude-3-5-sonnet-20240620')
))
This example illustrates that Agents are always described as pydantic objects including holding callable functions. Not shown here, the configuration can add references to external functions i.e. OpenAPI endpoints.
Installation
Funkyprompt is a poetry library that you can clone or install locally. Its also installable via PyPi
pip install funkyprompt
...TODO
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file funkyprompt-0.5.21.tar.gz
.
File metadata
- Download URL: funkyprompt-0.5.21.tar.gz
- Upload date:
- Size: 85.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.10 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bff16268d1ceacacafb8b98803c1770a3b9bd0d373eec77d05aa48658fe5094a |
|
MD5 | a73a9dbc601b75ed2b6518d9f5514f20 |
|
BLAKE2b-256 | d9481e8bf45824ce5c2252c643eacff6a4845183e9ce9144581bf8659e926df4 |
File details
Details for the file funkyprompt-0.5.21-py3-none-any.whl
.
File metadata
- Download URL: funkyprompt-0.5.21-py3-none-any.whl
- Upload date:
- Size: 107.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.10 Darwin/22.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f66dd4f44ff66a51acfdf5c266e77a54e63c39dc9d766bfdaeb10d4f8d04222e |
|
MD5 | 9a8fa9dbc48eb0dbf31ea9fd217438f3 |
|
BLAKE2b-256 | 6497c99504c7932d6e62e19cfb448c26adff8ad80196db9da2895d4621ae6404 |