Skip to content

Commit

Permalink
stabilyze poetry rerender
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFerLo committed Nov 8, 2023
1 parent e370a87 commit 7d36901
Show file tree
Hide file tree
Showing 7 changed files with 1,305 additions and 30 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ jobs:
- name: Extract tag name
id: tag
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Update version in setup.py
- name: Update version in pyproject.toml
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" pyproject.toml
- name: Build a binary wheel
run: >-
python setup.py sdist bdist_wheel
poetry build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
run: poetry publish
17 changes: 8 additions & 9 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Update version in setup.py
- name: Update version in pyproject.toml
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{'0.0.0'}}/g" setup.py
sed -i "s/{{VERSION_PLACEHOLDER}}/${{'0.0.0'}}/g" pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
python -m pip install --upgrade poetry
poetry add flake8 pytest
poetry install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
petry run pytest
1,237 changes: 1,237 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "synthetic-cognition"
version = "{{VERSION_PLACEHOLDER}}"
description = "LLM Agent Library"
authors = ["Carlos Fernandez <[email protected]>"]
license = "LICENSE"
readme = "README.md"
packages = [
{ include = "synthetic" }
]

[tool.poetry.dependencies]
python = "^3.10"
langchain = "^0.0.331"
pytest = "^7.4.3"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

14 changes: 0 additions & 14 deletions setup.py

This file was deleted.

36 changes: 36 additions & 0 deletions test/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ def evaluate (a) :
self.assertIsInstance(output, synthetic.AgentOutput)
self.assertEqual(output.generation, "[evaluate(1 + 1)->2]something")
self.assertEqual(output.raw, "add 1 + 1[evaluate(1 + 1)->2]something")

def test_agent_calls_function_with_multiline_function_signature (self):
llm = synthetic.llms.FakeLLM(responses=["Action: evaluate\nAction Input: 1 + 1\nObservation: chicken", "something"])
prompt_template = synthetic.PromptTemplate(template="{query}", input_variables=["query"])

@synthetic.function(name="evaluate", description="")
def evaluate (a) :
return str(eval(a))

agent = synthetic.Agent(llm, prompt_template, functions=[evaluate], signature="Action: {name}\nAction Input: {input}\nObservation: {output}\n")

output = agent.call(query="add 1 + 1 ")
self.assertIsInstance(output, synthetic.AgentOutput)
self.assertEqual(output.generation, "Action: evaluate\nAction Input: 1 + 1\nObservation: 2\nsomething")
self.assertEqual(output.raw, "add 1 + 1 Action: evaluate\nAction Input: 1 + 1\nObservation: 2\nsomething")

def test_agent_output_contains_function_calls_and_it_contains_a_function_call_data_structure (self) :
llm = synthetic.llms.FakeLLM(responses=["[evaluate(1 + 1)->more things", "something"])
Expand All @@ -122,6 +137,27 @@ def evaluate (a) :
self.assertEqual(output.function_calls[0].input, "1 + 1")
self.assertEqual(output.function_calls[0].output, "2")

def test_agent_output_contains_function_calls_and_it_contains_a_function_call_data_structure_for_multiline_signatures (self) :
llm = synthetic.llms.FakeLLM(responses=["Action: evaluate\nAction Input: 1 + 1\n Observation: chicken", "something"])
prompt_template = synthetic.PromptTemplate(template="{query}", input_variables=["query"])

@synthetic.function(name="evaluate", description="")
def evaluate (a):
return str(eval(a))

agent = synthetic.Agent(llm, prompt_template, functions=[evaluate], signature="Action: {name}\nAction Input: {input}\nObservation: {output}\n")

output = agent.call(query="add 1 + 1")
print(output)
print(agent.partial_signature_pattern.pattern)
print(agent.signature_pattern.pattern)
print(re.findall(agent.signature_pattern, output.raw))
self.assertIsInstance(output.function_calls[0], synthetic.FunctionCall)
self.assertEqual(output.function_calls[0].name, "evaluate")
self.assertEqual(output.function_calls[0].input, "1 + 1")
self.assertEqual(output.function_calls[0].output, "2")


def test_agent_can_be_init_with_optional_component_list_static_components_are_passed_to_the_prompt_template_and_dynamic_ones_stores_in_property (self) :
llm = synthetic.llms.FakeLLM(responses=[])
prompt_template = synthetic.PromptTemplate(template="<Component/>", input_variables=[])
Expand Down

0 comments on commit 7d36901

Please sign in to comment.