mirror of
https://github.com/MadcowD/ell.git
synced 2024-09-22 16:14:36 +03:00
add dynamic versioning
This commit is contained in:
10
Makefile
10
Makefile
@@ -1,6 +1,14 @@
|
||||
.PHONY: install npm-install npm-build
|
||||
|
||||
install: npm-install npm-build
|
||||
install: npm-install npm-build python-install
|
||||
|
||||
python-install:
|
||||
poetry self add poetry-dynamic-versioning
|
||||
pip uninstall -y ell
|
||||
poetry install
|
||||
poetry build
|
||||
cd dist && pip install *.whl
|
||||
rm -rf build
|
||||
|
||||
npm-install:
|
||||
@echo "Running npm install"
|
||||
|
||||
@@ -214,4 +214,4 @@ You can then visualize your promtps by visiting the frontend on `http://localhos
|
||||
- [ ] Force stores ot use the pydantic data types and dont use model dumping by default.
|
||||
- [ ] Update the serializer so that we prefer stringliterals when serialziing globals
|
||||
|
||||
- [x] Update stores to use schema type hints and serialize to model dump in Flask (or consider switching to FastAPI)
|
||||
- [x] Update stores to use schema type hints and serialize to model dump in Flask (or consider switching to FastAPI)
|
||||
|
||||
@@ -81,4 +81,4 @@ if __name__ == "__main__":
|
||||
print(f"MIDI file created: {midi_file}")
|
||||
|
||||
print("Playing chord progression...")
|
||||
play_midi_file(midi_file)
|
||||
play_midi_file(midi_file)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[tool.poetry]
|
||||
name = "ell"
|
||||
version = "0.0.1"
|
||||
description = "ell - a functional language model programming framework"
|
||||
version = "0.0.3"
|
||||
description = "mll - a functional language model programming framework"
|
||||
authors = ["William Guss <will@lrsys.xyz>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
@@ -18,7 +18,10 @@ classifiers = [
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9"
|
||||
]
|
||||
include = ["ell.studio/static/*", "ell.studio/static/**/*"]
|
||||
include = [
|
||||
{ path = "src/ell/studio/static", format = ["sdist", "wheel"] },
|
||||
{ path = "src/ell/studio/static/**/*", format = ["sdist", "wheel"] }
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9,<=3.12"
|
||||
@@ -38,10 +41,11 @@ typing-extensions = "^4.12.2"
|
||||
pytest = "^8.3.2"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
requires = ["poetry-core>=1.0.0", "setuptools", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
|
||||
build-backend = "poetry_dynamic_versioning.backend"
|
||||
|
||||
[tool.poetry.plugins.build]
|
||||
backend = "build:CustomBuildBackend"
|
||||
|
||||
|
||||
[tool.poetry.scripts]
|
||||
@@ -54,3 +58,6 @@ npm_build = ["invoke"]
|
||||
[tool.poetry.dev-dependencies]
|
||||
invoke = "^1.6.0"
|
||||
|
||||
|
||||
[tool.poetry-dynamic-versioning]
|
||||
enable = true
|
||||
|
||||
86
setup.py
86
setup.py
@@ -1,86 +0,0 @@
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import sys
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools.command.develop import develop
|
||||
from setuptools.command.install import install
|
||||
|
||||
class NPMInstall(object):
|
||||
def run_npm_install(self):
|
||||
print("Running npm install")
|
||||
if sys.platform == "win32":
|
||||
subprocess.check_call('npm install', cwd='ell-studio', shell=True)
|
||||
else:
|
||||
subprocess.check_call(['npm', 'install'], cwd='ell-studio')
|
||||
|
||||
class NPMBuild(object):
|
||||
def run_npm_build(self):
|
||||
print("Running npm build")
|
||||
if sys.platform == "win32":
|
||||
subprocess.check_call('npm run build', cwd='ell-studio', shell=True)
|
||||
else:
|
||||
subprocess.check_call(['npm', 'run', 'build'], cwd='ell-studio')
|
||||
|
||||
def copy_static_files(self):
|
||||
source_dir = os.path.join('ell-studio', 'build')
|
||||
target_dir = os.path.join('src', 'ell', 'studio', 'static')
|
||||
if os.path.exists(target_dir):
|
||||
shutil.rmtree(target_dir)
|
||||
shutil.copytree(source_dir, target_dir)
|
||||
print(f"Copied static files from {source_dir} to {target_dir}")
|
||||
|
||||
class CustomDevelop(develop, NPMInstall):
|
||||
def run(self):
|
||||
self.run_npm_install()
|
||||
develop.run(self)
|
||||
|
||||
class CustomInstall(install, NPMBuild):
|
||||
def run(self):
|
||||
self.run_npm_build()
|
||||
self.copy_static_files()
|
||||
install.run(self)
|
||||
|
||||
def read(fname):
|
||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||
|
||||
def read_requirements():
|
||||
with open('requirements.txt') as f:
|
||||
return [line.strip() for line in f if line.strip() and not line.startswith('#')]
|
||||
|
||||
setup(
|
||||
name="ell",
|
||||
version="0.0.1",
|
||||
author="William Guss",
|
||||
author_email="will@lrsys.xyz",
|
||||
description="ell - a functional language model programming framework",
|
||||
long_description=read('README.md'),
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/MadcowD/ell-studio",
|
||||
packages=find_packages(where='src'),
|
||||
package_dir={'': 'src'},
|
||||
include_package_data=True,
|
||||
package_data={
|
||||
'ell.studio': ['static/*', 'static/**/*'],
|
||||
},
|
||||
install_requires=read_requirements(),
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"ell-studio=ell.studio.__main__:main",
|
||||
],
|
||||
},
|
||||
cmdclass={
|
||||
'develop': CustomDevelop,
|
||||
'install': CustomInstall,
|
||||
},
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
],
|
||||
python_requires=">=3.7",
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
from ell.decorators.lm import lm
|
||||
from ell.types import Message
|
||||
from ell.__version__ import __version__
|
||||
|
||||
# registers all of the mdoels.
|
||||
import ell.models
|
||||
@@ -45,4 +46,4 @@ def assistant(content: str) -> Message:
|
||||
return Message(role="assistant", content=content)
|
||||
|
||||
|
||||
__all__ = ["lm", "system", "user", "assistant", "config"]
|
||||
__all__ = ["lm", "system", "user", "assistant", "config", "__version__"]
|
||||
|
||||
6
src/ell/__version__.py
Normal file
6
src/ell/__version__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
except ImportError:
|
||||
from importlib_metadata import version
|
||||
|
||||
__version__ = version("ell")
|
||||
@@ -5,8 +5,9 @@ from fastapi import FastAPI, Query, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import os
|
||||
|
||||
|
||||
def create_app(storage_dir: Optional[str] = None):
|
||||
storage_path = storage_dir or os.environ.get('ELL_STORAGE_DIR') or os.getcwd()
|
||||
storage_path = storage_dir or os.environ.get("ELL_STORAGE_DIR") or os.getcwd()
|
||||
assert storage_path, "ELL_STORAGE_DIR must be set"
|
||||
serializer = SQLiteStore(storage_path)
|
||||
app = FastAPI()
|
||||
@@ -20,61 +21,60 @@ def create_app(storage_dir: Optional[str] = None):
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
@app.get('/api/lmps')
|
||||
@app.get("/api/lmps")
|
||||
def get_lmps():
|
||||
lmps = serializer.get_lmps()
|
||||
return lmps
|
||||
|
||||
|
||||
@app.get('/api/lmps/{name:path}')
|
||||
@app.get("/api/lmps/{name:path}")
|
||||
def get_lmp(name: str):
|
||||
# Remove any leading slash if present
|
||||
name = name.lstrip('/')
|
||||
|
||||
name = name.lstrip("/")
|
||||
|
||||
# First, try to get by name
|
||||
lmps_by_name = serializer.get_lmps(name=name)
|
||||
if lmps_by_name:
|
||||
return list(lmps_by_name)
|
||||
return list(lmps_by_name)
|
||||
# If not found by name, check if the last part of the path is a valid lmp_id
|
||||
name_parts = name.split('/')
|
||||
name_parts = name.split("/")
|
||||
if len(name_parts) > 1:
|
||||
potential_lmp_id = name_parts[-1]
|
||||
potential_name = '/'.join(name_parts[:-1])
|
||||
potential_name = "/".join(name_parts[:-1])
|
||||
lmps = serializer.get_lmps(name=potential_name, lmp_id=potential_lmp_id)
|
||||
if lmps:
|
||||
return list(lmps)
|
||||
|
||||
raise HTTPException(status_code=404, detail="LMP not found")
|
||||
|
||||
@app.get('/api/invocations')
|
||||
@app.get('/api/invocations/{name:path}')
|
||||
|
||||
@app.get("/api/invocations")
|
||||
@app.get("/api/invocations/{name:path}")
|
||||
def get_invocations(name: Optional[str] = None):
|
||||
lmp_filters = {}
|
||||
if name:
|
||||
name = name.lstrip('/')
|
||||
name_parts = name.split('/')
|
||||
name = name.lstrip("/")
|
||||
name_parts = name.split("/")
|
||||
|
||||
lmp_filters["name"] = name_parts[0]
|
||||
if len(name_parts) > 1:
|
||||
if len(name_parts) > 1:
|
||||
potential_lmp_id = name_parts[-1]
|
||||
lmp_filters["lmp_id"] = potential_lmp_id
|
||||
|
||||
|
||||
invocations = serializer.get_invocations(lmp_filters=lmp_filters)
|
||||
return invocations
|
||||
|
||||
@app.post('/api/invocations/search')
|
||||
@app.post("/api/invocations/search")
|
||||
def search_invocations(q: str = Query(...)):
|
||||
invocations = serializer.search_invocations(q)
|
||||
return invocations
|
||||
|
||||
@app.get('/api/traces')
|
||||
|
||||
@app.get("/api/traces")
|
||||
def get_consumption_graph():
|
||||
traces = serializer.get_traces()
|
||||
return traces
|
||||
|
||||
|
||||
@app.get('/api/traces/{invocation_id}')
|
||||
@app.get("/api/traces/{invocation_id}")
|
||||
def get_all_traces_leading_to(invocation_id: str):
|
||||
traces = serializer.get_all_traces_leading_to(invocation_id)
|
||||
return traces
|
||||
return app
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user