{"id":25215167,"url":"https://github.com/trubrics/trubrics-python","last_synced_at":"2025-04-04T19:08:41.566Z","repository":{"id":47294225,"uuid":"449794325","full_name":"trubrics/trubrics-python","owner":"trubrics","description":"Product analytics for AI Assistants","archived":false,"fork":false,"pushed_at":"2025-03-28T16:23:13.000Z","size":9772,"stargazers_count":149,"open_issues_count":5,"forks_count":26,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T18:15:11.634Z","etag":null,"topics":["human-feedback","llm","llmops","machine-learning","ml-monitoring","mlops","model-feedback","streamlit"],"latest_commit_sha":null,"homepage":"https://docs.trubrics.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trubrics.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-19T17:40:44.000Z","updated_at":"2025-03-24T08:28:52.000Z","dependencies_parsed_at":"2023-02-16T11:00:25.934Z","dependency_job_id":"d27a592b-7c6c-4f41-874d-ee7f6aa1007c","html_url":"https://github.com/trubrics/trubrics-python","commit_stats":null,"previous_names":["trubrics/trubrics-python"],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trubrics%2Ftrubrics-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trubrics%2Ftrubrics-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trubrics%2Ftrubrics-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trubrics%2Ftrubrics-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trubrics","download_url":"https://codeload.github.com/trubrics/trubrics-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234921,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["human-feedback","llm","llmops","machine-learning","ml-monitoring","mlops","model-feedback","streamlit"],"created_at":"2025-02-10T18:05:58.679Z","updated_at":"2025-04-04T19:08:41.547Z","avatar_url":"https://github.com/trubrics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trubrics\n\nA Python client for tracking and analyzing events and LLM interactions with Trubrics.\n\n## Overview\n\nTrubrics is a Python client that provides event tracking capabilities with a focus on LLM (Large Language Model) interactions. It is fast and non-blocking, meaning there will be no performance hits to your LLM app. It features an efficient queuing system with automatic background flushing of events to the Trubrics API.\n\n## Installation\n\n``` bash\npip install trubrics\n```\n\n## Usage\n\n### Setup\n\nGet your project API key from settings in [Trubrics](https://app.trubrics.com/). This is a POST only API key.\n``` python\nfrom trubrics import Trubrics\n\nclient = Trubrics(api_key=\"your-api-key\")\n```\n\n### Tracking Events\n\n``` python\n# Track a simple event\nclient.track(\n    user_id=\"user123\",\n    event=\"button_click\",\n    properties={\"button_type\": \"submit\"},\n)\n\n# Track LLM interactions\nclient.track_llm(\n    user_id=\"user123\",\n    prompt=\"What is the capital of France?\",\n    assistant_id=\"gpt-4\",\n    generation=\"The capital of France is Paris.\",\n    properties={\n        \"support_tier\": \"entreprise\",\n    },\n    latency=1.5,  # seconds\n    thread_id=\"user123_thread_id\"\n)\n```\n\n### Closing the Client\n\n``` python\n# optional closing method to ensure all events are flushed from the queue before exiting your app\nclient.close()\n```\n\n### Logging\n\nThe client uses python's `logging` library to log messages, by default at the `ERROR` level.\n\nTo adjust the verbosity of the default logs, specify the log level:\n``` python\ntrubrics = Trubrics(api_key=\"your-api-key\")\ntrubrics.logger.setLevel(logging.DEBUG)\n```\n\nOr specify your own logger completely:\n``` python\ntrubrics = Trubrics(api_key=\"your-api-key\", logger=your_cool_logger)\n```\n\n## Other Client Configuration Options\n\n``` python\nfrom trubrics import Trubrics\n\nclient = Trubrics(\n    api_key=\"your-api-key\",\n    flush_interval=20,\n    flush_batch_size=10,\n)\n```\n\n- flush_interval: Time in seconds between automatic flushes (default: 10)\n- flush_batch_size: Number of events that trigger a flush (default: 20)\n\n## Development\n\n### Requirements\n\nThe project uses the following main dependencies:\n- requests==2.32.3\n- certifi==2025.1.31\n- charset-normalizer==3.4.1\n- idna==3.10\n- urllib3==2.3.0\n\n### Setting up Development Environment\n\nUsing Make commands:\n\n``` bash\nmake setup_uv_venv\nmake install_dev_requirements  # Install development dependencies\nmake install_requirements     # Install production dependencies\n```\n\n## Publishing\n\nThe package is automatically published to PyPI when a new version tag is pushed. To publish a new version:\n- Create a PR from the main branch for the desired changes\n- Update the version in `pyproject.toml`, and add changelog entry in `CHANGELOG.md`\n- Once the PR is merged, create a tag in the repo `trubrics-python` based on the version in `pyproject.toml`, and push it\n    ``` bash\n    git tag -a v1.0.0 -m \"Release version v1.0.0\"\n    git push origin v1.0.0\n    ```\n- Once the tag is pushed, a Github action `release.yml` will be triggered. It will:\n  - Create a release in the repo `trubrics-python` based on the `CHANGELOG.md` entry\n  - build the package with `uv`\n  - publish it to PyPI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrubrics%2Ftrubrics-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrubrics%2Ftrubrics-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrubrics%2Ftrubrics-python/lists"}