Skip to content

Commit

Permalink
Merge pull request #61 from lunary-ai/test
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Oct 22, 2024
2 parents 2359ba4 + 8178ea1 commit 8fc8ea7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions lunary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def get_parent_run_id(parent_run_id: str, run_type: str, app_id: str, run_id: st

parent_run = run_ctx.get()
if parent_run and parent_run != run_id:
run_ctx.set(None)
return str(create_uuid_from_string(str(parent_run) + str(app_id)))

parent_from_ctx = get_parent()
Expand Down Expand Up @@ -127,10 +126,10 @@ def track_event(
if not app_id:
return warnings.warn("LUNARY_PUBLIC_KEY is not set, not sending events")


parent_run_id = get_parent_run_id(
parent_run_id, run_type, app_id=app_id, run_id=run_id
)

# We need to generate a UUID that is unique by run_id / project_id pair in case of multiple concurrent callback handler use
run_id = str(create_uuid_from_string(str(run_id) + str(app_id)))

Expand Down Expand Up @@ -362,7 +361,7 @@ def wrap(
def sync_wrapper(*args, **kwargs):
output = None

parent_run_id = kwargs.pop("parent", None)
parent_run_id = kwargs.pop("parent", run_ctx.get())
run = run_manager.start_run(run_id, parent_run_id)

with run_context(run.id):
Expand Down Expand Up @@ -939,6 +938,8 @@ def on_llm_start(
**kwargs: Any,
) -> None:
try:
if parent_run_id is None:
parent_run_id = run_ctx.get()
run = run_manager.start_run(run_id, parent_run_id)

user_id = _get_user_id(metadata)
Expand Down Expand Up @@ -995,6 +996,8 @@ def on_chat_model_start(
**kwargs: Any,
) -> Any:
try:
if parent_run_id is None:
parent_run_id = run_ctx.get()
run = run_manager.start_run(run_id, parent_run_id)

user_id = _get_user_id(metadata)
Expand Down Expand Up @@ -1093,6 +1096,8 @@ def on_tool_start(
**kwargs: Any,
) -> None:
try:
if parent_run_id is None:
parent_run_id = run_ctx.get()
run = run_manager.start_run(run_id, parent_run_id)

user_id = _get_user_id(metadata)
Expand Down Expand Up @@ -1155,6 +1160,8 @@ def on_chain_start(
**kwargs: Any,
) -> Any:
try:
if parent_run_id is None:
parent_run_id = run_ctx.get()
run = run_manager.start_run(run_id, parent_run_id)

if name is None and serialized:
Expand Down Expand Up @@ -1336,6 +1343,8 @@ def on_retriever_start(
**kwargs: Any,
) -> None:
try:
if parent_run_id is None:
parent_run_id = run_ctx.get()
run = run_manager.start_run(run_id, parent_run_id)

user_id = _get_user_id(kwargs.get("metadata"))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "lunary"
version = "1.1.5"
version = "1.1.7"
description = "Observability, analytics and evaluations for AI agents and chatbots."
authors = ["lunary <[email protected]>"]
readme = "README.md"
Expand Down
Empty file removed test
Empty file.

0 comments on commit 8fc8ea7

Please sign in to comment.