Skip to content

Commit

Permalink
Merge pull request #9 from debuggerone/do_documentation
Browse files Browse the repository at this point in the history
Do documentation
  • Loading branch information
debuggerone authored Sep 21, 2024
2 parents f0cc5a4 + b9936c3 commit f61ca57
Show file tree
Hide file tree
Showing 34 changed files with 1,012 additions and 153 deletions.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
28 changes: 28 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'agentm-py'
copyright = '2024, Steven Ickman, Jochen Schultz'
author = 'Steven Ickman, Jochen Schultz'
release = '0.1'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = []

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']
17 changes: 17 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. agentm-py documentation master file, created by
sphinx-quickstart on Sat Sep 21 01:49:41 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
agentm-py documentation
=======================

Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.


.. toctree::
:maxdepth: 2
:caption: Contents:

15 changes: 10 additions & 5 deletions examples/binary_classify_list_example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import asyncio
from core.binary_classify_list_agent import BinaryClassifyListAgent
from core.binary_classify_list_agent import BinaryClassifyListAgent, BinaryClassifyListInput

async def run_binary_classify_list_example():
items_to_classify = ['Apple', 'Chocolate', 'Carrot']
criteria = 'Classify each item as either healthy (true) or unhealthy (false)'
agent = BinaryClassifyListAgent(list_to_classify=items_to_classify, criteria=criteria)
input_data = BinaryClassifyListInput(
list_to_classify=['Apple', 'Chocolate', 'Carrot'],
criteria='Classify each item as either healthy (true) or unhealthy (false)',
max_tokens=1000,
temperature=0.0
)

agent = BinaryClassifyListAgent(input_data)
classified_items = await agent.classify_list()

print("Original list:", items_to_classify)
print("Original list:", input_data.list_to_classify)
print("Binary classified results:", classified_items)

if __name__ == "__main__":
Expand Down
13 changes: 9 additions & 4 deletions examples/chain_of_thought_example.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import asyncio
from core.chain_of_thought_agent import ChainOfThoughtAgent
from core.chain_of_thought_agent import ChainOfThoughtAgent, ChainOfThoughtInput

async def run_chain_of_thought_example():
question = 'What is the square root of 144?'
agent = ChainOfThoughtAgent(question=question)
input_data = ChainOfThoughtInput(
question='What is the square root of 144?',
max_tokens=1000,
temperature=0.0
)

agent = ChainOfThoughtAgent(input_data)
result = await agent.chain_of_thought()

print("Question:", question)
print("Question:", input_data.question)
print("Chain of Thought Reasoning:", result)

if __name__ == "__main__":
Expand Down
20 changes: 12 additions & 8 deletions examples/classify_list_example.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import asyncio
from core.classify_list_agent import ClassifyListAgent
from core.classify_list_agent import ClassifyListAgent, ClassifyListInput

async def run_classify_list_example():
items_to_classify = ['Apple', 'Chocolate', 'Carrot']
classification_criteria = 'Classify each item as healthy or unhealthy snack'
agent = ClassifyListAgent(list_to_classify=items_to_classify, classification_criteria=classification_criteria)
classified_items = await agent.classify_list()
input_data = ClassifyListInput(
list_to_classify=["Apple", "Banana", "Carrot"],
classification_criteria="Classify each item as a fruit or vegetable.",
max_tokens=1000
)

agent = ClassifyListAgent(input_data)
classifications = await agent.classify_list()

print("Original list:", items_to_classify)
print("Classified results:", classified_items)
print("Original list:", input_data.list_to_classify)
print("Classified results:", classifications)

if __name__ == "__main__":
asyncio.run(run_classify_list_example())
asyncio.run(run_classify_list_example())
30 changes: 17 additions & 13 deletions examples/filter_list_example.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import asyncio
from core.filter_list_agent import FilterListAgent
from core.filter_list_agent import FilterListAgent, FilterListInput

async def run_filter_list_example():
goal = "Remove items that are unhealthy snacks."
items_to_filter = [
"Apple",
"Chocolate bar",
"Carrot",
"Chips",
"Orange"
]

agent = FilterListAgent(goal=goal, items_to_filter=items_to_filter)
input_data = FilterListInput(
goal="Remove items that are unhealthy snacks.",
items_to_filter=[
"Apple",
"Chocolate bar",
"Carrot",
"Chips",
"Orange"
],
max_tokens=500,
temperature=0.0
)

agent = FilterListAgent(input_data)
filtered_results = await agent.filter()

print("Original list:", items_to_filter)
print("Original list:", input_data.items_to_filter)
print("Filtered results:")
for result in filtered_results:
print(result)

if __name__ == "__main__":
asyncio.run(run_filter_list_example())
asyncio.run(run_filter_list_example())
14 changes: 9 additions & 5 deletions examples/generate_object_example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import asyncio
from core.generate_object_agent import GenerateObjectAgent
from core.generate_object_agent import GenerateObjectAgent, ObjectGenerationInput

async def run_generate_object_example():
description = "A machine that can sort fruits."
goal = "Generate a high-level design of the machine."
agent = GenerateObjectAgent(object_description=description, goal=goal)
input_data = ObjectGenerationInput(
object_description="A machine that can sort fruits.",
goal="Generate a high-level design of the machine.",
max_tokens=1000
)

agent = GenerateObjectAgent(input_data)
generated_object = await agent.generate_object()

print("Object description:", description)
print("Object description:", input_data.object_description)
print("Generated object:", generated_object)

if __name__ == "__main__":
Expand Down
22 changes: 13 additions & 9 deletions examples/grounded_answer_example.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import asyncio
from core.grounded_answer_agent import GroundedAnswerAgent
from core.grounded_answer_agent import GroundedAnswerAgent, GroundedAnswerInput

async def run_grounded_answer_example():
question = "What is the capital of France?"
context = "France is a country in Western Europe. Paris is its capital and largest city."
instructions = "Ensure the answer is grounded only in the provided context."
agent = GroundedAnswerAgent(question=question, context=context, instructions=instructions)
result = await agent.answer()
input_data = GroundedAnswerInput(
question="What is the capital of France?",
context="France is a country in Western Europe known for its wine and cuisine. The capital is a major global center for art, fashion, and culture.",
instructions="",
max_tokens=1000
)

agent = GroundedAnswerAgent(input_data)
answer = await agent.answer()

print("Question:", question)
print("Result:", result)
print("Question:", input_data.question)
print("Answer:", answer)

if __name__ == "__main__":
asyncio.run(run_grounded_answer_example())
asyncio.run(run_grounded_answer_example())
14 changes: 9 additions & 5 deletions examples/map_list_example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import asyncio
from core.map_list_agent import MapListAgent
from core.map_list_agent import MapListAgent, MapListInput

async def run_map_list_example():
items_to_map = ['Apple', 'Banana', 'Carrot']
transformation = 'Convert all items to uppercase'
agent = MapListAgent(list_to_map=items_to_map, transformation=transformation)
input_data = MapListInput(
list_to_map=['Apple', 'Banana', 'Carrot'],
transformation='Convert all items to uppercase',
max_tokens=1000
)

agent = MapListAgent(input_data)
transformed_items = await agent.map_list()

print("Original list:", items_to_map)
print("Original list:", input_data.list_to_map)
print("Transformed list:", transformed_items)

if __name__ == "__main__":
Expand Down
14 changes: 9 additions & 5 deletions examples/project_list_example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import asyncio
from core.project_list_agent import ProjectListAgent
from core.project_list_agent import ProjectListAgent, ProjectListInput

async def run_project_list_example():
items_to_project = ['Apple', 'Banana', 'Carrot']
projection_rule = 'Project these items as their vitamin content'
agent = ProjectListAgent(list_to_project=items_to_project, projection_rule=projection_rule)
input_data = ProjectListInput(
list_to_project=['Apple', 'Banana', 'Carrot'],
projection_rule='Project these items as their vitamin content',
max_tokens=1000
)

agent = ProjectListAgent(input_data)
projected_items = await agent.project_list()

print("Original list:", items_to_project)
print("Original list:", input_data.list_to_project)
print("Projected results:", projected_items)

if __name__ == "__main__":
Expand Down
16 changes: 10 additions & 6 deletions examples/reduce_list_example.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import asyncio
from core.reduce_list_agent import ReduceListAgent
from core.reduce_list_agent import ReduceListAgent, ReduceListInput

async def run_reduce_list_example():
items_to_reduce = ['Banana', 'Apple', 'Carrot']
reduction_goal = 'Reduce these items to a single word representing their nutritional value'
agent = ReduceListAgent(list_to_reduce=items_to_reduce, reduction_goal=reduction_goal)
input_data = ReduceListInput(
list_to_reduce=["Apple", "Banana", "Carrot"],
reduction_goal="Reduce each item to its first letter.",
max_tokens=1000
)

agent = ReduceListAgent(input_data)
reduced_items = await agent.reduce_list()

print("Original list:", items_to_reduce)
print("Original list:", input_data.list_to_reduce)
print("Reduced results:", reduced_items)

if __name__ == "__main__":
asyncio.run(run_reduce_list_example())
asyncio.run(run_reduce_list_example())
15 changes: 11 additions & 4 deletions examples/summarize_list_example.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import asyncio
from core.summarize_list_agent import SummarizeListAgent
from core.summarize_list_agent import SummarizeListAgent, SummarizeListInput

async def run_summarize_list_example():
items_to_summarize = ['The quick brown fox jumps over the lazy dog.', 'Python is a popular programming language.']
agent = SummarizeListAgent(list_to_summarize=items_to_summarize)
input_data = SummarizeListInput(
list_to_summarize=[
'The quick brown fox jumps over the lazy dog.',
'Python is a popular programming language.'
],
max_tokens=1000
)

agent = SummarizeListAgent(input_data)
summaries = await agent.summarize_list()

print("Original list:", items_to_summarize)
print("Original list:", input_data.list_to_summarize)
print("Summarized results:", summaries)

if __name__ == "__main__":
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ anyio
trio
openai
jsonschema
sphinx
sphinx-rtd-theme
myst-parser
pydantic
Loading

0 comments on commit f61ca57

Please sign in to comment.