From 43304204d13e0e042f453f6f6a6f5c874490ebec Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Thu, 10 Oct 2024 18:17:26 -0400 Subject: [PATCH 01/13] stashing changes --- README.md | 28 +++++++++++ justfile | 4 ++ packages/exchange/pyproject.toml | 9 +--- packages/exchange/src/exchange/exchange.py | 2 +- .../src/exchange}/langfuse_wrapper.py | 0 .../src/exchange/providers/anthropic.py | 2 +- .../src/exchange/providers/bedrock.py | 2 +- .../src/exchange/providers/databricks.py | 2 +- .../exchange/src/exchange/providers/google.py | 2 +- .../exchange/src/exchange/providers/openai.py | 2 +- .../tests/test_langfuse_wrapper_observe.py} | 2 +- packages/langfuse-wrapper/.ruff.toml | 2 - packages/langfuse-wrapper/README.md | 28 ----------- .../langfuse-wrapper/env/.env.langfuse.local | 16 ------- packages/langfuse-wrapper/pyproject.toml | 28 ----------- .../src/langfuse_wrapper/__init__.py | 3 -- pyproject.toml | 3 +- scripts/langfuse-docker-compose.yaml | 46 +++++++++++++++++++ .../scripts => scripts}/setup_langfuse.sh | 10 ++-- src/goose/cli/session.py | 1 - 20 files changed, 92 insertions(+), 100 deletions(-) rename packages/{langfuse-wrapper/src/langfuse_wrapper => exchange/src/exchange}/langfuse_wrapper.py (100%) rename packages/{langfuse-wrapper/tests/test_observe.py => exchange/tests/test_langfuse_wrapper_observe.py} (96%) delete mode 100644 packages/langfuse-wrapper/.ruff.toml delete mode 100644 packages/langfuse-wrapper/README.md delete mode 100644 packages/langfuse-wrapper/env/.env.langfuse.local delete mode 100644 packages/langfuse-wrapper/pyproject.toml delete mode 100644 packages/langfuse-wrapper/src/langfuse_wrapper/__init__.py create mode 100644 scripts/langfuse-docker-compose.yaml rename {packages/langfuse-wrapper/scripts => scripts}/setup_langfuse.sh (94%) diff --git a/README.md b/README.md index 6f980ff7..610916aa 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,34 @@ goose session resume To see more documentation on the CLI commands currently available to Goose check out the documentation [here][cli]. If you’d like to develop your own CLI commands for Goose, check out the [Contributing document][contributing]. +### Tracing with Langfuse + +The exchange package provides a [Langfuse](https://langfuse.com/) wrapper module. The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators. + +**Note: This Langfuse integration is experimental and we don't currently have integration tests for it.** + +#### Start your local Langfuse server + +Run `just langfuse-server` to start your local Langfuse server. It requires Docker. + +Read more about local Langfuse deployments [here](https://langfuse.com/docs/deployment/local). + +#### Exchange and Goose integration + +Import `from langfuse_wrapper.langfuse_wrapper import observe_wrapper` and use the `observe_wrapper()` decorator on functions you wish to enable tracing for. `observe_wrapper` functions the same way as Langfuse's observe decorator. + +Read more about Langfuse's decorator-based tracing [here](https://langfuse.com/docs/sdk/python/decorators). + +In Goose, initialization requires certain environment variables to be present: + +- `LANGFUSE_PUBLIC_KEY`: Your Langfuse public key +- `LANGFUSE_SECRET_KEY`: Your Langfuse secret key +- `LANGFUSE_BASE_URL`: The base URL of your Langfuse instance + +By default your local deployment and Goose will use the values in `.env.langfuse.local`. + + + ### Next steps Learn how to modify your Goose profiles.yaml file to add and remove functionality (toolkits) and providing context to get the most out of Goose in our [Getting Started Guide][getting-started]. diff --git a/justfile b/justfile index 8b2ca233..e6465f2e 100644 --- a/justfile +++ b/justfile @@ -70,3 +70,7 @@ tag: tag-push: just tag git push origin tag v$(just tag_version) + + +langfuse-server: + ./scripts/setup_langfuse.sh diff --git a/packages/exchange/pyproject.toml b/packages/exchange/pyproject.toml index caadef97..1f5e2590 100644 --- a/packages/exchange/pyproject.toml +++ b/packages/exchange/pyproject.toml @@ -14,7 +14,7 @@ dependencies = [ "httpx>=0.27.0", "tenacity>=9.0.0", "python-dotenv>=1.0.1", - "langfuse-wrapper" + "langfuse>=2.38.2" ] [tool.hatch.build.targets.wheel] @@ -49,10 +49,3 @@ ai-exchange = "exchange:module_name" markers = [ "integration: marks tests that need to authenticate (deselect with '-m \"not integration\"')", ] - -[tool.uv.sources] -langfuse-wrapper = { workspace = true} - -[tool.uv.workspace] -members = ["../langfuse-wrapper"] - diff --git a/packages/exchange/src/exchange/exchange.py b/packages/exchange/src/exchange/exchange.py index 31acaf2c..aa92dbac 100644 --- a/packages/exchange/src/exchange/exchange.py +++ b/packages/exchange/src/exchange/exchange.py @@ -14,7 +14,7 @@ from exchange.providers import Provider, Usage from exchange.tool import Tool from exchange.token_usage_collector import _token_usage_collector -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper def validate_tool_output(output: str) -> None: diff --git a/packages/langfuse-wrapper/src/langfuse_wrapper/langfuse_wrapper.py b/packages/exchange/src/exchange/langfuse_wrapper.py similarity index 100% rename from packages/langfuse-wrapper/src/langfuse_wrapper/langfuse_wrapper.py rename to packages/exchange/src/exchange/langfuse_wrapper.py diff --git a/packages/exchange/src/exchange/providers/anthropic.py b/packages/exchange/src/exchange/providers/anthropic.py index b6c0df71..5992a3eb 100644 --- a/packages/exchange/src/exchange/providers/anthropic.py +++ b/packages/exchange/src/exchange/providers/anthropic.py @@ -8,7 +8,7 @@ from exchange.providers.base import Provider, Usage from tenacity import retry, wait_fixed, stop_after_attempt from exchange.providers.utils import retry_if_status, raise_for_status -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper ANTHROPIC_HOST = "https://api.anthropic.com/v1/messages" diff --git a/packages/exchange/src/exchange/providers/bedrock.py b/packages/exchange/src/exchange/providers/bedrock.py index ad573426..7b04ba19 100644 --- a/packages/exchange/src/exchange/providers/bedrock.py +++ b/packages/exchange/src/exchange/providers/bedrock.py @@ -15,7 +15,7 @@ from tenacity import retry, wait_fixed, stop_after_attempt from exchange.providers.utils import raise_for_status, retry_if_status from exchange.tool import Tool -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper SERVICE = "bedrock-runtime" UTC = timezone.utc diff --git a/packages/exchange/src/exchange/providers/databricks.py b/packages/exchange/src/exchange/providers/databricks.py index 56d41ee0..6a56e04d 100644 --- a/packages/exchange/src/exchange/providers/databricks.py +++ b/packages/exchange/src/exchange/providers/databricks.py @@ -13,7 +13,7 @@ tools_to_openai_spec, ) from exchange.tool import Tool -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper retry_procedure = retry( wait=wait_fixed(2), diff --git a/packages/exchange/src/exchange/providers/google.py b/packages/exchange/src/exchange/providers/google.py index 388b0be0..4fb52862 100644 --- a/packages/exchange/src/exchange/providers/google.py +++ b/packages/exchange/src/exchange/providers/google.py @@ -8,7 +8,7 @@ from exchange.providers.base import Provider, Usage from tenacity import retry, wait_fixed, stop_after_attempt from exchange.providers.utils import raise_for_status, retry_if_status -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper GOOGLE_HOST = "https://generativelanguage.googleapis.com/v1beta" diff --git a/packages/exchange/src/exchange/providers/openai.py b/packages/exchange/src/exchange/providers/openai.py index 6bf02d01..6c878f95 100644 --- a/packages/exchange/src/exchange/providers/openai.py +++ b/packages/exchange/src/exchange/providers/openai.py @@ -15,7 +15,7 @@ from exchange.tool import Tool from tenacity import retry, wait_fixed, stop_after_attempt from exchange.providers.utils import retry_if_status -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper OPENAI_HOST = "https://api.openai.com/" diff --git a/packages/langfuse-wrapper/tests/test_observe.py b/packages/exchange/tests/test_langfuse_wrapper_observe.py similarity index 96% rename from packages/langfuse-wrapper/tests/test_observe.py rename to packages/exchange/tests/test_langfuse_wrapper_observe.py index 752719ea..4690a8d1 100644 --- a/packages/langfuse-wrapper/tests/test_observe.py +++ b/packages/exchange/tests/test_langfuse_wrapper_observe.py @@ -1,6 +1,6 @@ import pytest from unittest.mock import patch, MagicMock -from langfuse_wrapper.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper @pytest.fixture diff --git a/packages/langfuse-wrapper/.ruff.toml b/packages/langfuse-wrapper/.ruff.toml deleted file mode 100644 index 9accb3c3..00000000 --- a/packages/langfuse-wrapper/.ruff.toml +++ /dev/null @@ -1,2 +0,0 @@ -lint.select = ["E", "W", "F", "N"] -line-length = 120 diff --git a/packages/langfuse-wrapper/README.md b/packages/langfuse-wrapper/README.md deleted file mode 100644 index ae28c871..00000000 --- a/packages/langfuse-wrapper/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Langfuse Wrapper - -This package provides a wrapper for [Langfuse](https://langfuse.com/). The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators. - -**Note: This Langfuse integration is experimental and we don't currently have integration tests for it.** - - -## Usage - -### Start your local Langfuse server - -Run `setup_langfuse.sh` to start your local Langfuse server. It requires Docker. - -Read more about local Langfuse deployments [here](https://langfuse.com/docs/deployment/local). - -### Exchange and Goose integration - -Import `from langfuse_wrapper.langfuse_wrapper import observe_wrapper` and use the `observe_wrapper()` decorator on functions you wish to enable tracing for. `observe_wrapper` functions the same way as Langfuse's observe decorator. - -Read more about Langfuse's decorator-based tracing [here](https://langfuse.com/docs/sdk/python/decorators). - -In Goose, initialization requires certain environment variables to be present: - -- `LANGFUSE_PUBLIC_KEY`: Your Langfuse public key -- `LANGFUSE_SECRET_KEY`: Your Langfuse secret key -- `LANGFUSE_BASE_URL`: The base URL of your Langfuse instance - -By default your local deployment and Goose will use the values in `env/.env.langfuse.local`. diff --git a/packages/langfuse-wrapper/env/.env.langfuse.local b/packages/langfuse-wrapper/env/.env.langfuse.local deleted file mode 100644 index 98056309..00000000 --- a/packages/langfuse-wrapper/env/.env.langfuse.local +++ /dev/null @@ -1,16 +0,0 @@ -# These variables are default initialization variables for the Langfuse server -LANGFUSE_INIT_PROJECT_NAME=goose-local -LANGFUSE_INIT_PROJECT_PUBLIC_KEY=publickey-local -LANGFUSE_INIT_PROJECT_SECRET_KEY=secretkey-local -LANGFUSE_INIT_USER_EMAIL=local@block.xyz -LANGFUSE_INIT_USER_NAME=localdev -LANGFUSE_INIT_USER_PASSWORD=localpwd - -LANGFUSE_INIT_ORG_ID=local-id -LANGFUSE_INIT_ORG_NAME=local-org -LANGFUSE_INIT_PROJECT_ID=goose - -# These variables are used by Goose -LANGFUSE_PUBLIC_KEY=publickey-local -LANGFUSE_SECRET_KEY=secretkey-local -LANGFUSE_HOST=http://localhost:3000 diff --git a/packages/langfuse-wrapper/pyproject.toml b/packages/langfuse-wrapper/pyproject.toml deleted file mode 100644 index 7fda9f4e..00000000 --- a/packages/langfuse-wrapper/pyproject.toml +++ /dev/null @@ -1,28 +0,0 @@ -[project] -name = "langfuse-wrapper" -version = "0.1.0" -description = "A wrapper for Langfuse integration" -readme = "README.md" -requires-python = ">=3.10" -author = [{ name = "Block", email = "ai-oss-tools@block.xyz" }] -packages = [{ include = "langfuse_wrapper", from = "src" }] - -dependencies = [ - "langfuse>=2.38.2", - "python-dotenv>=1.0.1" -] - -[tool.hatch.build.targets.wheel] -packages = ["src/langfuse_wrapper"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv] -dev-dependencies = ["pytest>=8.3.2"] - -[tool.pytest.ini_options] -markers = [ - "integration: marks tests that need to authenticate (deselect with '-m \"not integration\"')", -] diff --git a/packages/langfuse-wrapper/src/langfuse_wrapper/__init__.py b/packages/langfuse-wrapper/src/langfuse_wrapper/__init__.py deleted file mode 100644 index f0816138..00000000 --- a/packages/langfuse-wrapper/src/langfuse_wrapper/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from langfuse_wrapper.langfuse_wrapper import observe_wrapper # noqa - -module_name = "langfuse-wrapper" diff --git a/pyproject.toml b/pyproject.toml index 3ee11275..60a09874 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ dependencies = [ "click>=8.1.7", "prompt-toolkit>=3.0.47", "keyring>=25.4.1", - "langfuse-wrapper", + "langfuse>=2.38.2" ] author = [{ name = "Block", email = "ai-oss-tools@block.xyz" }] @@ -72,7 +72,6 @@ dev-dependencies = [ [tool.uv.sources] ai-exchange = { workspace = true } -langfuse-wrapper = { workspace = true } [tool.uv.workspace] members = ["packages/*"] diff --git a/scripts/langfuse-docker-compose.yaml b/scripts/langfuse-docker-compose.yaml new file mode 100644 index 00000000..15393212 --- /dev/null +++ b/scripts/langfuse-docker-compose.yaml @@ -0,0 +1,46 @@ +services: + langfuse-server: + image: langfuse/langfuse:2 + depends_on: + db: + condition: service_healthy + ports: + - "3000:3000" + environment: + - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres + - NEXTAUTH_SECRET=mysecret + - SALT=mysalt + - ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 # generate via `openssl rand -hex 32` + - NEXTAUTH_URL=http://localhost:3000 + - TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true} + - LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false} + - LANGFUSE_INIT_ORG_ID=${LANGFUSE_INIT_ORG_ID:-} + - LANGFUSE_INIT_ORG_NAME=${LANGFUSE_INIT_ORG_NAME:-} + - LANGFUSE_INIT_PROJECT_ID=${LANGFUSE_INIT_PROJECT_ID:-} + - LANGFUSE_INIT_PROJECT_NAME=${LANGFUSE_INIT_PROJECT_NAME:-} + - LANGFUSE_INIT_PROJECT_PUBLIC_KEY=${LANGFUSE_INIT_PROJECT_PUBLIC_KEY:-} + - LANGFUSE_INIT_PROJECT_SECRET_KEY=${LANGFUSE_INIT_PROJECT_SECRET_KEY:-} + - LANGFUSE_INIT_USER_EMAIL=${LANGFUSE_INIT_USER_EMAIL:-} + - LANGFUSE_INIT_USER_NAME=${LANGFUSE_INIT_USER_NAME:-} + - LANGFUSE_INIT_USER_PASSWORD=${LANGFUSE_INIT_USER_PASSWORD:-} + + db: + image: postgres + restart: always + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 3s + timeout: 3s + retries: 10 + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=postgres + ports: + - 5432:5432 + volumes: + - database_data:/var/lib/postgresql/data + +volumes: + database_data: + driver: local diff --git a/packages/langfuse-wrapper/scripts/setup_langfuse.sh b/scripts/setup_langfuse.sh similarity index 94% rename from packages/langfuse-wrapper/scripts/setup_langfuse.sh rename to scripts/setup_langfuse.sh index 6b340a41..a8895bc7 100755 --- a/packages/langfuse-wrapper/scripts/setup_langfuse.sh +++ b/scripts/setup_langfuse.sh @@ -15,7 +15,7 @@ # ./setup_langfuse.sh # # Requirements: -# - Docker +# - Docker # - curl # - A .env.langfuse.local file in the env directory # @@ -25,8 +25,8 @@ set -e SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") LANGFUSE_DOCKER_COMPOSE_URL="https://raw.githubusercontent.com/langfuse/langfuse/main/docker-compose.yml" -LANGFUSE_DOCKER_COMPOSE_FILE="docker-compose.yaml" -LANGFUSE_ENV_FILE="$SCRIPT_DIR/../env/.env.langfuse.local" +LANGFUSE_DOCKER_COMPOSE_FILE="langfuse-docker-compose.yaml" +LANGFUSE_ENV_FILE="$SCRIPT_DIR/.env.langfuse.local" check_dependencies() { local dependencies=("curl" "docker") @@ -40,7 +40,7 @@ check_dependencies() { if [ ${#missing_dependencies[@]} -ne 0 ]; then echo "Missing dependencies: ${missing_dependencies[*]}" - exit 1 + exit 1 fi } @@ -63,7 +63,7 @@ wait_for_service() { ((count++)) if [ "$count" -ge "$retries" ]; then echo "Max retries reached. Langfuse did not start in time." - exit 1 + exit 1 fi sleep 1 done diff --git a/src/goose/cli/session.py b/src/goose/cli/session.py index fdf9a8d2..11cb3aaa 100644 --- a/src/goose/cli/session.py +++ b/src/goose/cli/session.py @@ -5,7 +5,6 @@ from langfuse.decorators import langfuse_context from exchange import Message, ToolResult, ToolUse, Text -from langfuse_wrapper.langfuse_wrapper import observe_wrapper, auth_check from rich import print from rich.markdown import Markdown from rich.panel import Panel From 36dec9f5af636903f808e636bd2cc9e7ebd4c379 Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Thu, 10 Oct 2024 18:37:37 -0400 Subject: [PATCH 02/13] just langfuse-server running --- README.md | 6 +++--- ...langfuse_wrapper_observe.py => test_langfuse_wrapper.py} | 6 +++--- scripts/setup_langfuse.sh | 4 ++-- src/goose/cli/session.py | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) rename packages/exchange/tests/{test_langfuse_wrapper_observe.py => test_langfuse_wrapper.py} (86%) diff --git a/README.md b/README.md index 610916aa..637d9409 100644 --- a/README.md +++ b/README.md @@ -149,10 +149,10 @@ To see more documentation on the CLI commands currently available to Goose check ### Tracing with Langfuse -The exchange package provides a [Langfuse](https://langfuse.com/) wrapper module. The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators. - **Note: This Langfuse integration is experimental and we don't currently have integration tests for it.** +The exchange package provides a [Langfuse](https://langfuse.com/) wrapper module. The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators. + #### Start your local Langfuse server Run `just langfuse-server` to start your local Langfuse server. It requires Docker. @@ -161,7 +161,7 @@ Read more about local Langfuse deployments [here](https://langfuse.com/docs/depl #### Exchange and Goose integration -Import `from langfuse_wrapper.langfuse_wrapper import observe_wrapper` and use the `observe_wrapper()` decorator on functions you wish to enable tracing for. `observe_wrapper` functions the same way as Langfuse's observe decorator. +Import `from exchange.langfuse_wrapper import observe_wrapper` and use the `observe_wrapper()` decorator on functions you wish to enable tracing for. `observe_wrapper` functions the same way as Langfuse's observe decorator. Read more about Langfuse's decorator-based tracing [here](https://langfuse.com/docs/sdk/python/decorators). diff --git a/packages/exchange/tests/test_langfuse_wrapper_observe.py b/packages/exchange/tests/test_langfuse_wrapper.py similarity index 86% rename from packages/exchange/tests/test_langfuse_wrapper_observe.py rename to packages/exchange/tests/test_langfuse_wrapper.py index 4690a8d1..32185097 100644 --- a/packages/exchange/tests/test_langfuse_wrapper_observe.py +++ b/packages/exchange/tests/test_langfuse_wrapper.py @@ -5,11 +5,11 @@ @pytest.fixture def mock_langfuse_context(): - with patch("langfuse_wrapper.langfuse_wrapper.langfuse_context") as mock: + with patch("exchange.langfuse_wrapper.langfuse_context") as mock: yield mock -@patch("langfuse_wrapper.langfuse_wrapper.HAS_LANGFUSE_CREDENTIALS", True) +@patch("exchange.langfuse_wrapper.HAS_LANGFUSE_CREDENTIALS", True) def test_function_is_wrapped(mock_langfuse_context): mock_observe = MagicMock(side_effect=lambda *args, **kwargs: lambda fn: fn) mock_langfuse_context.observe = mock_observe @@ -31,7 +31,7 @@ def original_function(x: int, y: int) -> int: mock_observe.assert_called_with("arg1", kwarg1="kwarg1") -@patch("langfuse_wrapper.langfuse_wrapper.HAS_LANGFUSE_CREDENTIALS", False) +@patch("exchange.langfuse_wrapper.HAS_LANGFUSE_CREDENTIALS", False) def test_function_is_not_wrapped(mock_langfuse_context): mock_observe = MagicMock(return_value=lambda f: f) mock_langfuse_context.observe = mock_observe diff --git a/scripts/setup_langfuse.sh b/scripts/setup_langfuse.sh index a8895bc7..48074795 100755 --- a/scripts/setup_langfuse.sh +++ b/scripts/setup_langfuse.sh @@ -26,7 +26,7 @@ set -e SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")") LANGFUSE_DOCKER_COMPOSE_URL="https://raw.githubusercontent.com/langfuse/langfuse/main/docker-compose.yml" LANGFUSE_DOCKER_COMPOSE_FILE="langfuse-docker-compose.yaml" -LANGFUSE_ENV_FILE="$SCRIPT_DIR/.env.langfuse.local" +LANGFUSE_ENV_FILE="$SCRIPT_DIR/../packages/exchange/.env.langfuse.local" check_dependencies() { local dependencies=("curl" "docker") @@ -45,7 +45,7 @@ check_dependencies() { } download_docker_compose() { - if ! curl --fail --location --output "$SCRIPT_DIR/docker-compose.yaml" "$LANGFUSE_DOCKER_COMPOSE_URL"; then + if ! curl --fail --location --output "$SCRIPT_DIR/langfuse-docker-compose.yaml" "$LANGFUSE_DOCKER_COMPOSE_URL"; then echo "Failed to download docker-compose file from $LANGFUSE_DOCKER_COMPOSE_URL" exit 1 fi diff --git a/src/goose/cli/session.py b/src/goose/cli/session.py index 11cb3aaa..89d58db8 100644 --- a/src/goose/cli/session.py +++ b/src/goose/cli/session.py @@ -5,6 +5,8 @@ from langfuse.decorators import langfuse_context from exchange import Message, ToolResult, ToolUse, Text +from exchange.langfuse_wrapper import observe_wrapper + from rich import print from rich.markdown import Markdown from rich.panel import Panel From 05d5b6d7caff9040b0ba592fce60facc48b5c86b Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Thu, 10 Oct 2024 18:44:17 -0400 Subject: [PATCH 03/13] langfuse traces are working --- packages/exchange/src/exchange/langfuse_wrapper.py | 2 +- pyproject.toml | 4 +++- src/goose/cli/session.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/exchange/src/exchange/langfuse_wrapper.py b/packages/exchange/src/exchange/langfuse_wrapper.py index 4f464be6..d496b58b 100644 --- a/packages/exchange/src/exchange/langfuse_wrapper.py +++ b/packages/exchange/src/exchange/langfuse_wrapper.py @@ -48,7 +48,7 @@ def auth_check() -> bool: CURRENT_DIR = Path(__file__).parent PACKAGE_ROOT = find_package_root(CURRENT_DIR) -LANGFUSE_ENV_FILE = os.path.join(PACKAGE_ROOT, "env", ".env.langfuse.local") +LANGFUSE_ENV_FILE = os.path.join(PACKAGE_ROOT, ".env.langfuse.local") HAS_LANGFUSE_CREDENTIALS = False load_dotenv(LANGFUSE_ENV_FILE, override=True) diff --git a/pyproject.toml b/pyproject.toml index 60a09874..50c53fc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,8 @@ dependencies = [ "click>=8.1.7", "prompt-toolkit>=3.0.47", "keyring>=25.4.1", - "langfuse>=2.38.2" + "langfuse>=2.38.2", + "goose-plugins-block", ] author = [{ name = "Block", email = "ai-oss-tools@block.xyz" }] @@ -72,6 +73,7 @@ dev-dependencies = [ [tool.uv.sources] ai-exchange = { workspace = true } +goose-plugins-block = { path = "../goose-plugins-block", editable = true } [tool.uv.workspace] members = ["packages/*"] diff --git a/src/goose/cli/session.py b/src/goose/cli/session.py index 89d58db8..79e86920 100644 --- a/src/goose/cli/session.py +++ b/src/goose/cli/session.py @@ -5,7 +5,7 @@ from langfuse.decorators import langfuse_context from exchange import Message, ToolResult, ToolUse, Text -from exchange.langfuse_wrapper import observe_wrapper +from exchange.langfuse_wrapper import observe_wrapper, auth_check from rich import print from rich.markdown import Markdown From 1fbdc3a362f5d1611e591b05554de27abd165cc6 Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Thu, 10 Oct 2024 19:04:10 -0400 Subject: [PATCH 04/13] add in changes to goose main, session --- pyproject.toml | 4 +++- src/goose/cli/main.py | 12 +++++++++--- src/goose/cli/session.py | 26 +++++++++++++++++--------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6b1d9eb8..b76c3320 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,8 @@ dependencies = [ "click>=8.1.7", "prompt-toolkit>=3.0.47", "keyring>=25.4.1", - "langfuse>=2.38.2" + "langfuse>=2.38.2", + "goose-plugins-block", ] author = [{ name = "Block", email = "ai-oss-tools@block.xyz" }] packages = [{ include = "goose", from = "src" }] @@ -71,6 +72,7 @@ dev-dependencies = [ [tool.uv.sources] ai-exchange = { workspace = true } +goose-plugins-block = { path = "../goose-plugins-block", editable = true } [tool.uv.workspace] members = ["packages/*"] diff --git a/src/goose/cli/main.py b/src/goose/cli/main.py index 7d135988..5221cb2e 100644 --- a/src/goose/cli/main.py +++ b/src/goose/cli/main.py @@ -136,7 +136,9 @@ def get_session_files() -> dict[str, Path]: @click.option("--profile") @click.option("--plan", type=click.Path(exists=True)) @click.option("--log-level", type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]), default="INFO") -def session_start(name: Optional[str], profile: str, log_level: str, plan: Optional[str] = None) -> None: +def session_start( + name: Optional[str], profile: str, log_level: str, plan: Optional[str] = None, tracing: bool = False +) -> None: """Start a new goose session""" if plan: yaml = YAML() @@ -144,8 +146,12 @@ def session_start(name: Optional[str], profile: str, log_level: str, plan: Optio _plan = yaml.load(f) else: _plan = None - session = Session(name=name, profile=profile, plan=_plan, log_level=log_level) - session.run() + + try: + session = Session(name=name, profile=profile, plan=_plan, log_level=log_level, tracing=tracing) + session.run() + except RuntimeError as e: + print(f"[red]Error: {e}") def parse_args(ctx: click.Context, param: click.Parameter, value: str) -> dict[str, str]: diff --git a/src/goose/cli/session.py b/src/goose/cli/session.py index bf4f78a8..fe218aed 100644 --- a/src/goose/cli/session.py +++ b/src/goose/cli/session.py @@ -1,17 +1,11 @@ +import logging import traceback from pathlib import Path from typing import Any, Optional -<<<<<<< HEAD -from exchange import Message, ToolResult, ToolUse, Text -from exchange.langfuse_wrapper import observe_wrapper, auth_check - -||||||| 56d88a8 -from exchange import Message, ToolResult, ToolUse, Text -from langfuse_wrapper.langfuse_wrapper import observe_wrapper, auth_check -======= +from langfuse.decorators import langfuse_context from exchange import Message, Text, ToolResult, ToolUse ->>>>>>> origin/main +from exchange.langfuse_wrapper import observe_wrapper, auth_check from rich import print from rich.markdown import Markdown from rich.panel import Panel @@ -71,6 +65,7 @@ def __init__( profile: Optional[str] = None, plan: Optional[dict] = None, log_level: Optional[str] = "INFO", + tracing: bool = False, **kwargs: dict[str, Any], ) -> None: if name is None: @@ -81,6 +76,18 @@ def __init__( self.prompt_session = GoosePromptSession() self.status_indicator = Status("", spinner="dots") self.notifier = SessionNotifier(self.status_indicator) + if not tracing: + logging.getLogger("langfuse").setLevel(logging.ERROR) + else: + langfuse_auth = auth_check() + if langfuse_auth: + print("Local Langfuse initialized. View your traces at http://localhost:3000") + else: + raise RuntimeError( + "You passed --tracing, but a Langfuse object was not found in the current context. " + "Please initialize the local Langfuse server and restart Goose." + ) + langfuse_context.configure(enabled=tracing) self.exchange = create_exchange(profile=load_profile(profile), notifier=self.notifier) setup_logging(log_file_directory=LOG_PATH, log_level=log_level) @@ -195,6 +202,7 @@ def run(self) -> None: self._remove_empty_session() self._log_cost() + @observe_wrapper() def reply(self) -> None: """Reply to the last user message, calling tools as needed""" self.status_indicator.update("responding") From 1a5af089568980e0f3f3afe8213410d915d44284 Mon Sep 17 00:00:00 2001 From: Salman Mohammed Date: Thu, 10 Oct 2024 19:05:10 -0400 Subject: [PATCH 05/13] add in click option for tracing --- src/goose/cli/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/goose/cli/main.py b/src/goose/cli/main.py index 5221cb2e..7527b0ad 100644 --- a/src/goose/cli/main.py +++ b/src/goose/cli/main.py @@ -136,6 +136,7 @@ def get_session_files() -> dict[str, Path]: @click.option("--profile") @click.option("--plan", type=click.Path(exists=True)) @click.option("--log-level", type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]), default="INFO") +@click.option("--tracing", is_flag=True, required=False) def session_start( name: Optional[str], profile: str, log_level: str, plan: Optional[str] = None, tracing: bool = False ) -> None: From 193265e4644b3d254cbc3308872c1ddae8085878 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 13:48:06 -0400 Subject: [PATCH 06/13] add env file and update docs --- .gitignore | 3 +++ CONTRIBUTING.md | 9 +++++++++ docs/plugins/cli.md | 5 +++-- packages/exchange/.env.langfuse.local | 16 ++++++++++++++++ .../exchange/src/exchange/langfuse_wrapper.py | 4 ++-- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 packages/exchange/.env.langfuse.local diff --git a/.gitignore b/.gitignore index f799b722..807d1989 100644 --- a/.gitignore +++ b/.gitignore @@ -103,6 +103,9 @@ celerybeat.pid .env.* .venv +# exception for local langfuse init vars +!**/packages/exchange/.env.langfuse.local + # Spyder project settings .spyderproject .spyproject diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a5597e4..0c2d33b4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,6 +48,15 @@ or, as a shortcut, just test ``` +### Enable traces in Goose with [locally hosted Langfuse](https://langfuse.com/docs/deployment/self-host) +Developers can use locally hosted Langfuse tracing by applying the custom `observe_wrapper` decorator defined in `packages/exchange/src/langfuse_wrapper.py` to functions for automatic integration with Langfuse. + +- Run the `setup_langfuse` script in `scripts/` to download and deploy the Langfuse docker container with default initialization variables found in the `.env.langfuse.local` file in `packages/exchange`. +- Go to http://localhost:3000 and log in with the default email/password output by the shell script (or found in the `.env.langfuse.local` file). +- Run Goose with the --tracing flag enabled i.e., `goose session start --tracing` +- View your traces at http://localhost:3000 + + ## Exchange The lower level generation behind goose is powered by the [`exchange`][ai-exchange] package, also in this repo. diff --git a/docs/plugins/cli.md b/docs/plugins/cli.md index 5d27563c..b1181985 100644 --- a/docs/plugins/cli.md +++ b/docs/plugins/cli.md @@ -19,11 +19,12 @@ Lists the version of Goose and any associated plugins. **Usage:** ```sh - goose session start [--profile PROFILE] [--plan PLAN] -``` + goose session start [--profile PROFILE] [--plan PLAN] [--log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]] [--tracing] Starts a new Goose session. +If you want to enable locally hosted Langfuse tracing, pass the --tracing flag after starting your local Langfuse server as outlined in the [Contributing Guide]'s [contributing] Development guidelines. + #### `resume` **Usage:** diff --git a/packages/exchange/.env.langfuse.local b/packages/exchange/.env.langfuse.local new file mode 100644 index 00000000..9f127496 --- /dev/null +++ b/packages/exchange/.env.langfuse.local @@ -0,0 +1,16 @@ +# These variables are default initialization variables for locally hosted Langfuse server +LANGFUSE_INIT_PROJECT_NAME=goose-local +LANGFUSE_INIT_PROJECT_PUBLIC_KEY=publickey-local +LANGFUSE_INIT_PROJECT_SECRET_KEY=secretkey-local +LANGFUSE_INIT_USER_EMAIL=local@block.xyz +LANGFUSE_INIT_USER_NAME=localdev +LANGFUSE_INIT_USER_PASSWORD=localpwd + +LANGFUSE_INIT_ORG_ID=local-id +LANGFUSE_INIT_ORG_NAME=local-org +LANGFUSE_INIT_PROJECT_ID=goose + +# These variables are used by Goose +LANGFUSE_PUBLIC_KEY=publickey-local +LANGFUSE_SECRET_KEY=secretkey-local +LANGFUSE_HOST=http://localhost:3000 \ No newline at end of file diff --git a/packages/exchange/src/exchange/langfuse_wrapper.py b/packages/exchange/src/exchange/langfuse_wrapper.py index d496b58b..c8cec23e 100644 --- a/packages/exchange/src/exchange/langfuse_wrapper.py +++ b/packages/exchange/src/exchange/langfuse_wrapper.py @@ -22,7 +22,7 @@ from functools import wraps # Add this import -def find_package_root(start_path: Path, marker_file="pyproject.toml") -> Path: +def find_package_root(start_path: Path, marker_file: str = "pyproject.toml") -> Path: while start_path != start_path.parent: if (start_path / marker_file).exists(): return start_path @@ -74,7 +74,7 @@ def _wrapper(fn: Callable) -> Callable: if HAS_LANGFUSE_CREDENTIALS: @wraps(fn) - def wrapped_fn(*fargs, **fkwargs): + def wrapped_fn(*fargs, **fkwargs): # noqa return langfuse_context.observe(*args, **kwargs)(fn)(*fargs, **fkwargs) return wrapped_fn From d6c7017460b112c7d8d3509d0b09590fe5592dd9 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 13:54:17 -0400 Subject: [PATCH 07/13] update docs --- CONTRIBUTING.md | 11 ++++++++--- packages/exchange/.env.langfuse.local | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c2d33b4..333a5b20 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,13 +49,18 @@ just test ``` ### Enable traces in Goose with [locally hosted Langfuse](https://langfuse.com/docs/deployment/self-host) -Developers can use locally hosted Langfuse tracing by applying the custom `observe_wrapper` decorator defined in `packages/exchange/src/langfuse_wrapper.py` to functions for automatic integration with Langfuse. +Developers can use locally hosted Langfuse tracing by applying the custom `observe_wrapper` decorator defined in `packages/exchange/src/langfuse_wrapper.py` to functions for automatic integration with Langfuse. -- Run the `setup_langfuse` script in `scripts/` to download and deploy the Langfuse docker container with default initialization variables found in the `.env.langfuse.local` file in `packages/exchange`. -- Go to http://localhost:3000 and log in with the default email/password output by the shell script (or found in the `.env.langfuse.local` file). +Note: This integration is experimental and we don't currently have integration tests for it. + +- Run `just langfuse-server` to start your local Langfuse server. It requires Docker. +- Go to http://localhost:3000 and log in with the default email/password output by the shell script (values can also be found in the `.env.langfuse.local` file). - Run Goose with the --tracing flag enabled i.e., `goose session start --tracing` - View your traces at http://localhost:3000 +To extend tracing to additional functions, import `from exchange.langfuse_wrapper import observe_wrapper` and use the `observe_wrapper()` decorator on functions you wish to enable tracing for. `observe_wrapper` functions the same way as Langfuse's observe decorator. + +Read more about Langfuse's decorator-based tracing [here](https://langfuse.com/docs/sdk/python/decorators). ## Exchange diff --git a/packages/exchange/.env.langfuse.local b/packages/exchange/.env.langfuse.local index 9f127496..cdebcd7a 100644 --- a/packages/exchange/.env.langfuse.local +++ b/packages/exchange/.env.langfuse.local @@ -13,4 +13,4 @@ LANGFUSE_INIT_PROJECT_ID=goose # These variables are used by Goose LANGFUSE_PUBLIC_KEY=publickey-local LANGFUSE_SECRET_KEY=secretkey-local -LANGFUSE_HOST=http://localhost:3000 \ No newline at end of file +LANGFUSE_HOST=http://localhost:3000 From 8c2355016984638bde2798f97ac98b4575979e62 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 13:56:51 -0400 Subject: [PATCH 08/13] update test --- tests/cli/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli/test_main.py b/tests/cli/test_main.py index 9f6f2f66..30a3c32d 100644 --- a/tests/cli/test_main.py +++ b/tests/cli/test_main.py @@ -34,7 +34,7 @@ def test_session_start_command_with_session_name(mock_session): mock_session_class, mock_session_instance = mock_session runner = CliRunner() runner.invoke(goose_cli, ["session", "start", "session1", "--profile", "default"]) - mock_session_class.assert_called_once_with(name="session1", profile="default", plan=None, log_level="INFO") + mock_session_class.assert_called_once_with(name="session1", profile="default", plan=None, log_level="INFO", tracing=False) mock_session_instance.run.assert_called_once() From 476b3388abcc45100df4350f660ec2cf67ee8882 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 14:00:05 -0400 Subject: [PATCH 09/13] revert pyproject.toml --- pyproject.toml | 2 -- tests/cli/test_main.py | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0892a3c6..62f78e63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ dependencies = [ "prompt-toolkit>=3.0.47", "keyring>=25.4.1", "langfuse>=2.38.2", - "goose-plugins-block", ] author = [{ name = "Block", email = "ai-oss-tools@block.xyz" }] packages = [{ include = "goose", from = "src" }] @@ -72,7 +71,6 @@ dev-dependencies = [ [tool.uv.sources] ai-exchange = { workspace = true } -goose-plugins-block = { path = "../goose-plugins-block", editable = true } [tool.uv.workspace] members = ["packages/*"] diff --git a/tests/cli/test_main.py b/tests/cli/test_main.py index 30a3c32d..38b38920 100644 --- a/tests/cli/test_main.py +++ b/tests/cli/test_main.py @@ -34,7 +34,9 @@ def test_session_start_command_with_session_name(mock_session): mock_session_class, mock_session_instance = mock_session runner = CliRunner() runner.invoke(goose_cli, ["session", "start", "session1", "--profile", "default"]) - mock_session_class.assert_called_once_with(name="session1", profile="default", plan=None, log_level="INFO", tracing=False) + mock_session_class.assert_called_once_with( + name="session1", profile="default", plan=None, log_level="INFO", tracing=False + ) mock_session_instance.run.assert_called_once() From 630249905608c8cce12b206cb6945b938415bd87 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 14:02:37 -0400 Subject: [PATCH 10/13] fix docs --- docs/plugins/cli.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/plugins/cli.md b/docs/plugins/cli.md index b1181985..c881f5c1 100644 --- a/docs/plugins/cli.md +++ b/docs/plugins/cli.md @@ -20,6 +20,7 @@ Lists the version of Goose and any associated plugins. **Usage:** ```sh goose session start [--profile PROFILE] [--plan PLAN] [--log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]] [--tracing] +``` Starts a new Goose session. From ab89afbb79f6569269529dc96e80e7fac71cbd9f Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 14:05:36 -0400 Subject: [PATCH 11/13] reformat docs --- CONTRIBUTING.md | 5 +++-- README.md | 5 +++-- docs/plugins/cli.md | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 333a5b20..def00190 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,10 +49,11 @@ just test ``` ### Enable traces in Goose with [locally hosted Langfuse](https://langfuse.com/docs/deployment/self-host) +> [!NOTE] +> This integration is experimental and we don't currently have integration tests for it. +> Developers can use locally hosted Langfuse tracing by applying the custom `observe_wrapper` decorator defined in `packages/exchange/src/langfuse_wrapper.py` to functions for automatic integration with Langfuse. -Note: This integration is experimental and we don't currently have integration tests for it. - - Run `just langfuse-server` to start your local Langfuse server. It requires Docker. - Go to http://localhost:3000 and log in with the default email/password output by the shell script (values can also be found in the `.env.langfuse.local` file). - Run Goose with the --tracing flag enabled i.e., `goose session start --tracing` diff --git a/README.md b/README.md index 939c7fbf..2fe102dc 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,9 @@ goose session resume To see more documentation on the CLI commands currently available to Goose check out the documentation [here][cli]. If you’d like to develop your own CLI commands for Goose, check out the [Contributing document][contributing]. ### Tracing with Langfuse - -**Note: This Langfuse integration is experimental and we don't currently have integration tests for it.** +> [!NOTE] +> This Langfuse integration is experimental and we don't currently have integration tests for it. +> The exchange package provides a [Langfuse](https://langfuse.com/) wrapper module. The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators. diff --git a/docs/plugins/cli.md b/docs/plugins/cli.md index c881f5c1..7a3566d3 100644 --- a/docs/plugins/cli.md +++ b/docs/plugins/cli.md @@ -24,7 +24,7 @@ Lists the version of Goose and any associated plugins. Starts a new Goose session. -If you want to enable locally hosted Langfuse tracing, pass the --tracing flag after starting your local Langfuse server as outlined in the [Contributing Guide]'s [contributing] Development guidelines. +If you want to enable locally hosted Langfuse tracing, pass the --tracing flag after starting your local Langfuse server as outlined in the [Contributing Guide's][contributing] Development guidelines. #### `resume` From 282ce5494afbe83aa965be64cc590bc80b5e2d69 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 14:06:57 -0400 Subject: [PATCH 12/13] reformat docs --- CONTRIBUTING.md | 5 ++--- README.md | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index def00190..ff5359ae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,9 +49,8 @@ just test ``` ### Enable traces in Goose with [locally hosted Langfuse](https://langfuse.com/docs/deployment/self-host) -> [!NOTE] -> This integration is experimental and we don't currently have integration tests for it. -> +> [!NOTE] This integration is experimental and we don't currently have integration tests for it. + Developers can use locally hosted Langfuse tracing by applying the custom `observe_wrapper` decorator defined in `packages/exchange/src/langfuse_wrapper.py` to functions for automatic integration with Langfuse. - Run `just langfuse-server` to start your local Langfuse server. It requires Docker. diff --git a/README.md b/README.md index 2fe102dc..46b77c2a 100644 --- a/README.md +++ b/README.md @@ -151,9 +151,7 @@ goose session resume To see more documentation on the CLI commands currently available to Goose check out the documentation [here][cli]. If you’d like to develop your own CLI commands for Goose, check out the [Contributing document][contributing]. ### Tracing with Langfuse -> [!NOTE] -> This Langfuse integration is experimental and we don't currently have integration tests for it. -> +> [!NOTE] This Langfuse integration is experimental and we don't currently have integration tests for it. The exchange package provides a [Langfuse](https://langfuse.com/) wrapper module. The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators. From 9d34340464b03144e5ea38797d0cc7dbee739b99 Mon Sep 17 00:00:00 2001 From: Alice Hau Date: Tue, 15 Oct 2024 14:07:59 -0400 Subject: [PATCH 13/13] add note format --- CONTRIBUTING.md | 5 +++-- README.md | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff5359ae..deea3821 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,8 +49,9 @@ just test ``` ### Enable traces in Goose with [locally hosted Langfuse](https://langfuse.com/docs/deployment/self-host) -> [!NOTE] This integration is experimental and we don't currently have integration tests for it. - +> [!NOTE] +> This integration is experimental and we don't currently have integration tests for it. + Developers can use locally hosted Langfuse tracing by applying the custom `observe_wrapper` decorator defined in `packages/exchange/src/langfuse_wrapper.py` to functions for automatic integration with Langfuse. - Run `just langfuse-server` to start your local Langfuse server. It requires Docker. diff --git a/README.md b/README.md index 46b77c2a..8f2ff842 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,8 @@ goose session resume To see more documentation on the CLI commands currently available to Goose check out the documentation [here][cli]. If you’d like to develop your own CLI commands for Goose, check out the [Contributing document][contributing]. ### Tracing with Langfuse -> [!NOTE] This Langfuse integration is experimental and we don't currently have integration tests for it. +> [!NOTE] +> This Langfuse integration is experimental and we don't currently have integration tests for it. The exchange package provides a [Langfuse](https://langfuse.com/) wrapper module. The wrapper serves to initialize Langfuse appropriately if the Langfuse server is running locally and otherwise to skip applying the Langfuse observe descorators.