Skip to content

Commit f45e235

Browse files
committed
Initial commit
0 parents  commit f45e235

21 files changed

+1676
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
.idea/

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Robert DiBiano
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Conversational Programming / Agent Functions
2+
3+
## Overview
4+
5+
This repository introduces a new paradigm for conversational programming using **agent functions**, which leverage GPT-based reasoning to perform semi-autonomous tasks. These functions enable flexible and intuitive operations that surpass traditional functions, especially in scenarios requiring fuzzy logic, intuition, or handling of incomplete/bad input data.
6+
7+
---
8+
9+
## Key Concepts
10+
11+
### **1. New Data Type: `conversation_fragment`**
12+
A `conversation_fragment` represents a segment of a GPT-powered conversation, either as input (query) or output (response).
13+
- Further categorization into **query** and **response** types.
14+
- Investigate inline tags governing conversation flow (noted by Supratik and Richard).
15+
16+
### **2. New Class: `agent_function`**
17+
An **`agent_function`** is a GPT-powered function designed to perform a well-defined task autonomously, with minimal code and high flexibility.
18+
19+
#### **Capabilities:**
20+
- Accepts `conversation_fragment` as input (alongside other data types).
21+
- Parses input types to construct the final query dynamically.
22+
- Produces output in the form of `conversation_fragment` or specific structured responses.
23+
- Supports **Chain of Thought** reasoning, breaking down complex problems into manageable subtasks.
24+
- Automatically logs reasoning processes for debugging and review.
25+
26+
---
27+
28+
## Features & Design Principles
29+
30+
### **Agent Function Behavior**
31+
- **Flexible Input Handling**
32+
Other input types can be parsed together at the function's start to form a structured query.
33+
- **Structured Output Formatting**
34+
Queries can specify output formats, e.g.:
35+
```plaintext
36+
"The output should be an integer in brackets, e.g., '[2]', '[0]', etc."
37+
```
38+
The function then parses the structured response accordingly.
39+
40+
### **Chain of Thought Reasoning**
41+
- Enables step-by-step problem-solving.
42+
- Automatically decomposes complex tasks into subtasks.
43+
- Summarizes reasoning and decisions for logging and debugging.
44+
- If parsing fails, retries with an extended query before throwing an exception.
45+
- Explicit handling of queries that are too long and get truncated:
46+
- Attempt to process truncated results.
47+
- Issue a follow-up query for a more concise response.
48+
- Modify the base query to request shorter responses if truncation happens frequently.
49+
- Special **failure assessment agent functions** can be created for critical tasks.
50+
- Cross-validation across multiple LLMs for comparison.
51+
52+
### **Retrieval-Augmented Generation (RAG)**
53+
- Built-in support for both **web retrieval** and **user-defined databases**.
54+
55+
### **Failure Rate Analysis & Statistics**
56+
- Failure rate tracking built into `agent_function` class.
57+
- Automatic failure categorization (potentially GPT-assisted).
58+
- GPT-based auto-correction of queries based on failure rate and type.
59+
- Versioned statistics—failure rates are tracked separately for different function versions.
60+
61+
### **LLM-Agnostic Design**
62+
- **Agent functions should generalize across multiple LLMs** without requiring code duplication.
63+
64+
### **Decision-Making Agent Functions**
65+
Agent functions can:
66+
1. **Process data and generate results**
67+
2. **Make branching decisions to determine program flow**
68+
69+
---
70+
71+
## Built-in Standard Workflows
72+
73+
### **Basic Tasks**
74+
- **Pick an item from a small list** (single-step decision-making)
75+
- **Correct grammatical or formatting errors**
76+
77+
### **Advanced Chain of Thought**
78+
1. **Reasoning step before decision-making** (standardized `conversation_fragment` structure)
79+
2. **Error correction with optional reasoning** (asks for clarification if ambiguous)
80+
3. **Simple True/False decision-making** (with reasoning)
81+
4. **Pick an item from a list with reasoning**
82+
5. **Process a large dataset item-by-item with reasoning**, including:
83+
- Categorization
84+
- Summarization
85+
- Other forms of processing
86+
87+
### **Retrieval-Augmented Generation (RAG)**
88+
- Intelligent selection of retrieval sources based on short previews.
89+
- Summarization and compression of retrieved content for more efficient use.
90+
91+
---
92+
93+
## TODO List
94+
95+
### **New Features to Implement**
96+
- **`BranchingConversation` class** for managing multi-step agent-driven dialogues.
97+
- **Versioning system** for conversation fragments and agent functions:
98+
- Every function using conversation fragments should be versioned.
99+
- Support calling specific function versions.
100+
- Ability to compare performance across multiple versions.
101+
- Reduce code duplication while integrating versioning across multiple functions.
102+
- **Integrate system messages into generated prompts**.
103+
- **Add notes/history fields** to conversations/fragments:
104+
- Track edits, transformations, agent interactions, and lineage.
105+
106+
---
107+
108+
## Existing Technologies & References
109+
110+
- **OpenAI Function Calling & Assistants API**
111+
[Everything You Need to Know](https://medium.com/the-modern-scientist/everything-you-need-to-know-about-openai-function-calling-and-assistants-api-55c02570a21c)
112+
- **Agenta: Open-Source LLMOps Platform**
113+
[https://agenta.ai/](https://agenta.ai/)
114+
- **Pezzo: Open-Source AI Developer Platform**
115+
[https://github.com/pezzolabs/pezzo](https://github.com/pezzolabs/pezzo)

agent_functions/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# expose (a.k.a. re-export) your main classes so users can do something like
2+
# from agent_functions import ConversationFragment without needing to know the exact file structure.
3+
from .conversation_fragment import ConversationFragment, Conversation
4+
from .agent_function import AgentFunction
5+
6+
__all__ = ["ConversationFragment", "Conversation", "AgentFunction"]

0 commit comments

Comments
 (0)