Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename #545

Merged
merged 162 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
c6684e6
do legacy pass on grammar
hellovai Apr 4, 2024
ef9ebf0
Working function type with errors
hellovai Apr 4, 2024
b5de746
Some code gen works
hellovai Apr 4, 2024
ce3e55d
adding work items
hellovai Apr 4, 2024
57bef58
Code generation
hellovai Apr 4, 2024
bfbd1a5
Add template string syntax
hellovai Apr 5, 2024
0a93714
feat: expose render_prompt to python
sxlijin Apr 5, 2024
1cb2bd6
strip out dead code
sxlijin Apr 5, 2024
52c5434
improve the pyo3 interface
sxlijin Apr 5, 2024
c190a01
set up maturin build steps
sxlijin Apr 6, 2024
6176b9e
add gh workflow
sxlijin Apr 6, 2024
9b692dd
fix workflow
sxlijin Apr 6, 2024
fb13d02
setup more release stuff
sxlijin Apr 6, 2024
8d33902
add an upload job
sxlijin Apr 6, 2024
2815d83
fix syntax
sxlijin Apr 6, 2024
ffd3432
fix publishing
sxlijin Apr 6, 2024
1448a04
allow oidc
sxlijin Apr 6, 2024
6379603
fix wheel file naming
sxlijin Apr 6, 2024
42e8021
clean up pyo3 version
sxlijin Apr 6, 2024
651de26
try again to fix workflow
sxlijin Apr 6, 2024
328afd0
try again
sxlijin Apr 6, 2024
8a99a65
once more
sxlijin Apr 6, 2024
787a7d3
try again
sxlijin Apr 6, 2024
ce0078a
try again...
sxlijin Apr 6, 2024
301a321
rename package
sxlijin Apr 6, 2024
a1833d7
fix clients/python
sxlijin Apr 6, 2024
fed0b20
Add static analysis function on jinja
hellovai Apr 7, 2024
d9d2c5b
Merge branch 'sam/maturin2' into rename
sxlijin Apr 7, 2024
9c4272d
Working JINJA static analyzer
hellovai Apr 8, 2024
db7615f
Handle all errors for template_strings too
hellovai Apr 8, 2024
dce7b14
fix gh workflow, add render_chat_prompt in python
sxlijin Apr 8, 2024
0c604a9
push up pyi changes
sxlijin Apr 8, 2024
12ecda1
fix pyi file
sxlijin Apr 8, 2024
2cf9982
remove indirection
sxlijin Apr 8, 2024
3ced139
get more stuff working
sxlijin Apr 8, 2024
80494f0
fix compile
sxlijin Apr 8, 2024
fd0c028
expose all types
sxlijin Apr 8, 2024
1144b33
more fixes
sxlijin Apr 8, 2024
b0967d9
Generate code
hellovai Apr 8, 2024
f072084
get the new rust python interface working
sxlijin Apr 8, 2024
b5bb444
remove indirect
sxlijin Apr 8, 2024
8e4d1ef
end2end working1
hellovai Apr 8, 2024
50f2ecf
renaming "default_config"
hellovai Apr 8, 2024
2cbe9af
add derives
hellovai Apr 8, 2024
3cc1f92
Add output_schema
hellovai Apr 8, 2024
e6dfd34
get globals working
sxlijin Apr 8, 2024
4a61285
make chat/completions splitting work
sxlijin Apr 8, 2024
498b5ef
works with playground
hellovai Apr 8, 2024
28a940a
implement chat splitting and dedenting
sxlijin Apr 9, 2024
9dcda5a
Add syntax highlighting
hellovai Apr 9, 2024
a25ac42
Make tests a warning when named incorrected.
hellovai Apr 9, 2024
6a37c5e
vscode preview works now!
sxlijin Apr 9, 2024
d630602
clean up the wasm_bindgen interface
sxlijin Apr 9, 2024
8fb63b6
fixes
hellovai Apr 9, 2024
84efcd1
react to tsx changes
sxlijin Apr 9, 2024
65ee762
change wasm_bindgen interface
sxlijin Apr 9, 2024
89bdc23
Fix TODO
hellovai Apr 9, 2024
5b79e0c
Better equality for Jinja
hellovai Apr 9, 2024
6285cb5
Fix errors for bad variables
hellovai Apr 9, 2024
e7aa4fe
fix a prompt rendering bug
sxlijin Apr 9, 2024
bdbc764
get output_schema working
sxlijin Apr 9, 2024
2e98f49
oops
sxlijin Apr 9, 2024
d1ec47c
output_schema does not work
sxlijin Apr 9, 2024
1b42bc7
ctx.output_schema kinda works now
sxlijin Apr 9, 2024
f66c16e
get ctx.output_schema working properly
sxlijin Apr 10, 2024
3e76f8c
make output schema work better
sxlijin Apr 10, 2024
58342e1
tweak enum format more for aaron
sxlijin Apr 10, 2024
b5820a4
add complex-v2 with AnalyzeProductReview tests
sxlijin Apr 10, 2024
00ec786
support output_schema in python
sxlijin Apr 10, 2024
1e15b0d
make it work
sxlijin Apr 10, 2024
7451d16
a little bit more pyo3
sxlijin Apr 10, 2024
1cbe10a
rip out js files in typescript/common/src
sxlijin Apr 10, 2024
c8d86ce
resolve fallback/round-robin in prompt preview
sxlijin Apr 11, 2024
4002487
expose the list of clients
sxlijin Apr 11, 2024
74e3a5c
fix build
sxlijin Apr 11, 2024
c779698
Merge branch 'canary' into rename
sxlijin Apr 11, 2024
9a75a5a
make implpanel work
sxlijin Apr 11, 2024
be37020
example projects wip
aaronvg Apr 11, 2024
95ce403
Example cards
aaronvg Apr 12, 2024
e3ac64c
test case auto-synthesis
sxlijin Apr 11, 2024
f288719
mvp impl of save and run is now working
sxlijin Apr 11, 2024
4e29bb1
still needs a lot of ui work
sxlijin Apr 12, 2024
cdaf7ef
Fixed typescript integration
hellovai Apr 12, 2024
f33c164
improve styling
aaronvg Apr 12, 2024
c4addb4
fix more sharing link bugs
aaronvg Apr 12, 2024
679b337
improve test case editor
sxlijin Apr 12, 2024
6ef4ca9
multi file editor
aaronvg Apr 12, 2024
c17935d
got token count working, then broke it
sxlijin Apr 13, 2024
54968de
implement token counting, clean up save and run
sxlijin Apr 13, 2024
33aa85e
fix some styles
aaronvg Apr 13, 2024
5381733
Add basic-ass linting
aaronvg Apr 13, 2024
255e5ee
use turbo
aaronvg Apr 13, 2024
b58e2ab
some prompt engineering fixes
aaronvg Apr 13, 2024
724e0f2
more prompt engineering
aaronvg Apr 14, 2024
b526389
more prompting
aaronvg Apr 14, 2024
80cf134
Add more prompts
aaronvg Apr 14, 2024
9027afe
update playground
aaronvg Apr 14, 2024
740e33c
adding linter
hellovai Apr 15, 2024
1cff60e
disable linter
hellovai Apr 15, 2024
cd36912
deactivate ai linter
aaronvg Apr 15, 2024
02e66d7
make class_schema work again
sxlijin Apr 15, 2024
c59600f
gitignore baml-schema-wasm web correctly
sxlijin Apr 15, 2024
084879a
some lezer updates
sxlijin Apr 15, 2024
368a752
Generate TS Code
hellovai Apr 15, 2024
3883132
Editable title
aaronvg Apr 15, 2024
c804c61
some more fixes
aaronvg Apr 15, 2024
bd2c83b
routing changes
aaronvg Apr 15, 2024
b9f29d7
clean up fiddle code
aaronvg Apr 15, 2024
263b059
fix rendering issue with the example project files
aaronvg Apr 15, 2024
1ab222b
Add test result to the project contents
aaronvg Apr 15, 2024
e4b1957
style tweak
aaronvg Apr 15, 2024
4a8e1cd
more grammar fixes for fiddle
sxlijin Apr 15, 2024
9a929bb
add jinja styling
sxlijin Apr 15, 2024
0b6a6e1
improve highlighting
sxlijin Apr 15, 2024
1c9bb8f
reset the url after running tests so user needs to generate a new one
aaronvg Apr 15, 2024
472ac5d
url resets
aaronvg Apr 15, 2024
147864f
fix vscode esbuild
sxlijin Apr 16, 2024
050efc7
new syntax works in TS!
hellovai Apr 16, 2024
7263b5d
rezisable panel change
aaronvg Apr 16, 2024
e39ee09
remove files
hellovai Apr 16, 2024
389e508
add symlinks
hellovai Apr 16, 2024
be02598
patch the status undefined
aaronvg Apr 16, 2024
217b550
Fixed with python again!
hellovai Apr 16, 2024
2c6519d
remove handle
aaronvg Apr 16, 2024
a69c1dc
tweaks
aaronvg Apr 16, 2024
1e01525
mostly finish syntax highlighting
sxlijin Apr 16, 2024
ca4fa85
unsaved changes
aaronvg Apr 16, 2024
b606684
fix bad use of hooks
aaronvg Apr 16, 2024
336ca32
fix linting error when switching files
aaronvg Apr 16, 2024
1058444
fix some highlights and add snippets
aaronvg Apr 16, 2024
d160cf0
add snippets
aaronvg Apr 16, 2024
8b124cf
reset the output logs, and add a newline spacing for now
aaronvg Apr 16, 2024
5b79f6e
Add linter gutter
aaronvg Apr 16, 2024
77b4a97
fix bug
aaronvg Apr 16, 2024
4003f5c
more fix
aaronvg Apr 16, 2024
c096617
merging
hellovai Apr 17, 2024
e2b3f46
add examples
sxlijin Apr 17, 2024
ec02d92
undo merge conflicts
sxlijin Apr 17, 2024
e6dabb2
fix merge conflicts again
sxlijin Apr 17, 2024
02dce46
add examples
sxlijin Apr 17, 2024
9dc1228
fix unable to name new test
aaronvg Apr 17, 2024
7ded33f
more fix
aaronvg Apr 17, 2024
8fd6347
minor comments
hellovai Apr 17, 2024
e6fa555
use tests as files
hellovai Apr 17, 2024
cb4139e
command w should not close the tab
aaronvg Apr 17, 2024
ed94301
Update listeners
hellovai Apr 17, 2024
070e732
add rendering
hellovai Apr 17, 2024
ea33839
update lock file
hellovai Apr 17, 2024
0ff10df
fix compiler errors
hellovai Apr 17, 2024
7e35c61
adding PYI file
hellovai Apr 17, 2024
086396f
ignore ffi errors python
hellovai Apr 17, 2024
b57fe4c
update ini
hellovai Apr 17, 2024
a650e2c
remove trailing comment
hellovai Apr 17, 2024
1575987
fix ini file
hellovai Apr 17, 2024
cd4d107
fix ruff
hellovai Apr 17, 2024
b16d11a
udpate workflow
hellovai Apr 17, 2024
0471d38
udpate workflow
hellovai Apr 17, 2024
64b756d
Make codemirror refresh and relint when files change
aaronvg Apr 17, 2024
c0d63f3
Some cleanup
aaronvg Apr 17, 2024
2140823
fixed tests
hellovai Apr 17, 2024
49c0dc7
Fix resizing performance issues, text overflow bugs, and test error o…
aaronvg Apr 17, 2024
18afcaa
fix stuff
aaronvg Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .github/workflows/client_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
poetry install --no-root
working-directory: clients/python

- name: Build FFI
run: |
./tools/build clients/python
working-directory: ./

- name: Lint Python Client
run: |
poetry run mypy .
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/release_python_ffi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release clients/python-ffi

on:
push:
branches:
- sam/maturin2

permissions:
contents: read
id-token: write

jobs:
build:
strategy:
matrix:
_:
- runs_on: ubuntu-latest
target: x86_64
name: x86_64-unknown-linux-gnu

- runs_on: ubuntu-latest
target: aarch64
name: aarch64-unknown-linux-gnu

- runs_on: macos-latest
target: x86_64
name: x86_64-apple-darwin

- runs_on: macos-latest
target: aarch64
name: aarch64-apple-darwin

- runs_on: windows-latest
target: x64
name: x86_64-pc-windows-msvc

runs-on: ${{ matrix._.runs_on }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
architecture: ${{ matrix._.runs_on == 'windows-latest' && 'x64' || null }}

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix._.target }}
command: build
args: --release --out dist --manifest-path clients/python-ffi/Cargo.toml
sccache: "true"
manylinux: ${{ matrix._.runs_on == 'ubuntu-latest' && 'auto' || null }}

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix._.name }}
path: dist

publish:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/download-artifact@v4

- run: mkdir dist && mv wheels-*/* dist

# authz is managed via OIDC configured at https://pypi.org/manage/project/baml-core-ffi/settings/publishing/
# it is pinned to this filename, so renaming this file is not safe!!: release_python_ffi.yaml
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This file is generated by the BAML compiler.
# Do not edit this file directly.
# Instead, edit the BAML files and recompile.

# ruff: noqa: E501,F401
# flake8: noqa: E501,F401
# pylint: disable=unused-import,line-too-long
# fmt: off

from ..types.classes.cls_reviewanalysis import ReviewAnalysis
from ..types.enums.enm_reviewhelpfulness import ReviewHelpfulness
from ..types.enums.enm_reviewsentiment import ReviewSentiment
from ..types.partial.classes.cls_reviewanalysis import PartialReviewAnalysis
from baml_core.stream import AsyncStream
from baml_lib._impl.functions import BaseBAMLFunction
from typing import AsyncIterator, Callable, Protocol, runtime_checkable


IAnalyzeProductReviewOutput = ReviewAnalysis

@runtime_checkable
class IAnalyzeProductReview(Protocol):
"""
This is the interface for a function.

Args:
product_review: str

Returns:
ReviewAnalysis
"""

async def __call__(self, *, product_review: str) -> ReviewAnalysis:
...



@runtime_checkable
class IAnalyzeProductReviewStream(Protocol):
"""
This is the interface for a stream function.

Args:
product_review: str

Returns:
AsyncStream[ReviewAnalysis, PartialReviewAnalysis]
"""

def __call__(self, *, product_review: str
) -> AsyncStream[ReviewAnalysis, PartialReviewAnalysis]:
...
class IBAMLAnalyzeProductReview(BaseBAMLFunction[ReviewAnalysis, PartialReviewAnalysis]):
def __init__(self) -> None:
super().__init__(
"AnalyzeProductReview",
IAnalyzeProductReview,
["default_config"],
)

async def __call__(self, *args, **kwargs) -> ReviewAnalysis:
return await self.get_impl("").run(*args, **kwargs)

def stream(self, *args, **kwargs) -> AsyncStream[ReviewAnalysis, PartialReviewAnalysis]:
res = self.get_impl("").stream(*args, **kwargs)
return res

BAMLAnalyzeProductReview = IBAMLAnalyzeProductReview()

__all__ = [ "BAMLAnalyzeProductReview" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# This file is generated by the BAML compiler.
# Do not edit this file directly.
# Instead, edit the BAML files and recompile.

# ruff: noqa: E501,F401
# flake8: noqa: E501,F401
# pylint: disable=unused-import,line-too-long
# fmt: off

from ..types.classes.cls_reviewanalysis import ReviewAnalysis
from ..types.enums.enm_reviewhelpfulness import ReviewHelpfulness
from ..types.enums.enm_reviewsentiment import ReviewSentiment
from ..types.partial.classes.cls_reviewanalysis import PartialReviewAnalysis
from baml_core.stream import AsyncStream
from typing import Callable, Protocol, runtime_checkable


import typing

import pytest
from contextlib import contextmanager
from unittest import mock

ImplName = typing.Literal["default_config"]

T = typing.TypeVar("T", bound=typing.Callable[..., typing.Any])
CLS = typing.TypeVar("CLS", bound=type)


IAnalyzeProductReviewOutput = ReviewAnalysis

@runtime_checkable
class IAnalyzeProductReview(Protocol):
"""
This is the interface for a function.

Args:
product_review: str

Returns:
ReviewAnalysis
"""

async def __call__(self, *, product_review: str) -> ReviewAnalysis:
...



@runtime_checkable
class IAnalyzeProductReviewStream(Protocol):
"""
This is the interface for a stream function.

Args:
product_review: str

Returns:
AsyncStream[ReviewAnalysis, PartialReviewAnalysis]
"""

def __call__(self, *, product_review: str
) -> AsyncStream[ReviewAnalysis, PartialReviewAnalysis]:
...
class BAMLAnalyzeProductReviewImpl:
async def run(self, *, product_review: str) -> ReviewAnalysis:
...

def stream(self, *, product_review: str
) -> AsyncStream[ReviewAnalysis, PartialReviewAnalysis]:
...

class IBAMLAnalyzeProductReview:
def register_impl(
self, name: ImplName
) -> typing.Callable[[IAnalyzeProductReview, IAnalyzeProductReviewStream], None]:
...

async def __call__(self, *, product_review: str) -> ReviewAnalysis:
...

def stream(self, *, product_review: str
) -> AsyncStream[ReviewAnalysis, PartialReviewAnalysis]:
...

def get_impl(self, name: ImplName) -> BAMLAnalyzeProductReviewImpl:
...

@contextmanager
def mock(self) -> typing.Generator[mock.AsyncMock, None, None]:
"""
Utility for mocking the AnalyzeProductReviewInterface.

Usage:
```python
# All implementations are mocked.

async def test_logic() -> None:
with baml.AnalyzeProductReview.mock() as mocked:
mocked.return_value = ...
result = await AnalyzeProductReviewImpl(...)
assert mocked.called
```
"""
...

@typing.overload
def test(self, test_function: T) -> T:
"""
Provides a pytest.mark.parametrize decorator to facilitate testing different implementations of
the AnalyzeProductReviewInterface.

Args:
test_function : T
The test function to be decorated.

Usage:
```python
# All implementations will be tested.

@baml.AnalyzeProductReview.test
async def test_logic(AnalyzeProductReviewImpl: IAnalyzeProductReview) -> None:
result = await AnalyzeProductReviewImpl(...)
```
"""
...

@typing.overload
def test(self, *, exclude_impl: typing.Iterable[ImplName] = [], stream: bool = False) -> pytest.MarkDecorator:
"""
Provides a pytest.mark.parametrize decorator to facilitate testing different implementations of
the AnalyzeProductReviewInterface.

Args:
exclude_impl : Iterable[ImplName]
The names of the implementations to exclude from testing.
stream: bool
If set, will return a streamable version of the test function.

Usage:
```python
# All implementations except the given impl will be tested.

@baml.AnalyzeProductReview.test(exclude_impl=["implname"])
async def test_logic(AnalyzeProductReviewImpl: IAnalyzeProductReview) -> None:
result = await AnalyzeProductReviewImpl(...)
```

```python
# Streamable version of the test function.

@baml.AnalyzeProductReview.test(stream=True)
async def test_logic(AnalyzeProductReviewImpl: IAnalyzeProductReviewStream) -> None:
async for result in AnalyzeProductReviewImpl(...):
...
```
"""
...

@typing.overload
def test(self, test_class: typing.Type[CLS]) -> typing.Type[CLS]:
"""
Provides a pytest.mark.parametrize decorator to facilitate testing different implementations of
the AnalyzeProductReviewInterface.

Args:
test_class : Type[CLS]
The test class to be decorated.

Usage:
```python
# All implementations will be tested in every test method.

@baml.AnalyzeProductReview.test
class TestClass:
def test_a(self, AnalyzeProductReviewImpl: IAnalyzeProductReview) -> None:
...
def test_b(self, AnalyzeProductReviewImpl: IAnalyzeProductReview) -> None:
...
```
"""
...

BAMLAnalyzeProductReview: IBAMLAnalyzeProductReview
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class IClassifyTool(Protocol):
This is the interface for a function.

Args:
query: str
context: str
query: str

Returns:
ClassifyResponse
"""

async def __call__(self, *, query: str, context: str) -> ClassifyResponse:
async def __call__(self, *, context: str, query: str) -> ClassifyResponse:
...


Expand All @@ -41,14 +41,14 @@ class IClassifyToolStream(Protocol):
This is the interface for a stream function.

Args:
query: str
context: str
query: str

Returns:
AsyncStream[ClassifyResponse, PartialClassifyResponse]
"""

def __call__(self, *, query: str, context: str
def __call__(self, *, context: str, query: str
) -> AsyncStream[ClassifyResponse, PartialClassifyResponse]:
...
class IBAMLClassifyTool(BaseBAMLFunction[ClassifyResponse, PartialClassifyResponse]):
Expand Down
Loading
Loading