{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [], "authorship_tag": "ABX9TyOYzHixv9uEIy4VNhqc0MNu", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "view-in-github", "colab_type": "text" }, "source": [ "\"Open" ] }, { "cell_type": "code", "source": [ "!pip install git+https://huggingface.co/spaces/vinay-pepakayala/GitHubIssueTriageManager" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ecB_AWVKCYf8", "outputId": "e8c8a9e3-2b16-4f21-df32-2e5fcc0de906" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Collecting git+https://huggingface.co/spaces/vinay-pepakayala/GitHubIssueTriageManager\n", " Cloning https://huggingface.co/spaces/vinay-pepakayala/GitHubIssueTriageManager to /tmp/pip-req-build-a0dj2976\n", " Running command git clone --filter=blob:none --quiet https://huggingface.co/spaces/vinay-pepakayala/GitHubIssueTriageManager /tmp/pip-req-build-a0dj2976\n", " fatal: error reading section header 'shallow-info'\n", " Resolved https://huggingface.co/spaces/vinay-pepakayala/GitHubIssueTriageManager to commit d2cd79194c3ed5957df2ecc5d524de0dceffe596\n", " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", "Collecting openenv-core>=0.2.2 (from openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading openenv_core-0.2.3-py3-none-any.whl.metadata (19 kB)\n", "Requirement already satisfied: fastapi>=0.104.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.135.2)\n", "Requirement already satisfied: pydantic>=2.0.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.12.3)\n", "Requirement already satisfied: uvicorn>=0.24.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.42.0)\n", "Requirement already satisfied: requests>=2.25.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.32.4)\n", "Requirement already satisfied: typer>=0.9.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.24.1)\n", "Requirement already satisfied: rich>=13.0.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (13.9.4)\n", "Requirement already satisfied: pyyaml>=6.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (6.0.3)\n", "Requirement already satisfied: huggingface_hub>=0.20.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.8.0)\n", "Requirement already satisfied: openai>=2.7.2 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.30.0)\n", "Collecting tomli>=2.3.0 (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading tomli-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (10 kB)\n", "Collecting tomli-w>=1.2.0 (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading tomli_w-1.2.0-py3-none-any.whl.metadata (5.7 kB)\n", "Requirement already satisfied: websockets>=15.0.1 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (15.0.1)\n", "Collecting fastmcp>=3.0.0 (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading fastmcp-3.2.0-py3-none-any.whl.metadata (8.1 kB)\n", "Requirement already satisfied: gradio>=4.0.0 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (5.50.0)\n", "Requirement already satisfied: httpx>=0.28.1 in /usr/local/lib/python3.12/dist-packages (from openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.28.1)\n", "Requirement already satisfied: starlette>=0.46.0 in /usr/local/lib/python3.12/dist-packages (from fastapi>=0.104.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.52.1)\n", "Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.12/dist-packages (from fastapi>=0.104.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.15.0)\n", "Requirement already satisfied: typing-inspection>=0.4.2 in /usr/local/lib/python3.12/dist-packages (from fastapi>=0.104.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.4.2)\n", "Requirement already satisfied: annotated-doc>=0.0.2 in /usr/local/lib/python3.12/dist-packages (from fastapi>=0.104.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.0.4)\n", "Requirement already satisfied: authlib>=1.6.5 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.6.9)\n", "Collecting cyclopts>=4.0.0 (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading cyclopts-4.10.1-py3-none-any.whl.metadata (12 kB)\n", "Collecting exceptiongroup>=1.2.2 (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading exceptiongroup-1.3.1-py3-none-any.whl.metadata (6.7 kB)\n", "Collecting jsonref>=1.1.0 (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading jsonref-1.1.0-py3-none-any.whl.metadata (2.7 kB)\n", "Collecting jsonschema-path>=0.3.4 (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading jsonschema_path-0.4.5-py3-none-any.whl.metadata (5.9 kB)\n", "Requirement already satisfied: mcp<2.0,>=1.24.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.26.0)\n", "Collecting openapi-pydantic>=0.5.1 (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading openapi_pydantic-0.5.1-py3-none-any.whl.metadata (10 kB)\n", "Requirement already satisfied: opentelemetry-api>=1.20.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.38.0)\n", "Requirement already satisfied: packaging>=24.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (26.0)\n", "Requirement already satisfied: platformdirs>=4.0.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.9.4)\n", "Collecting py-key-value-aio<0.5.0,>=0.4.4 (from py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading py_key_value_aio-0.4.4-py3-none-any.whl.metadata (15 kB)\n", "Requirement already satisfied: pyperclip>=1.9.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.11.0)\n", "Requirement already satisfied: python-dotenv>=1.1.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.2.2)\n", "Collecting uncalled-for>=0.2.0 (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading uncalled_for-0.2.0-py3-none-any.whl.metadata (2.9 kB)\n", "Requirement already satisfied: watchfiles>=1.0.0 in /usr/local/lib/python3.12/dist-packages (from fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.1.1)\n", "Requirement already satisfied: aiofiles<25.0,>=22.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (24.1.0)\n", "Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.13.0)\n", "Requirement already satisfied: brotli>=1.1.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.2.0)\n", "Requirement already satisfied: ffmpy in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.0.0)\n", "Requirement already satisfied: gradio-client==1.14.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.14.0)\n", "Requirement already satisfied: groovy~=0.1 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.1.2)\n", "Requirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.1.6)\n", "Requirement already satisfied: markupsafe<4.0,>=2.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.0.3)\n", "Requirement already satisfied: numpy<3.0,>=1.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.0.2)\n", "Requirement already satisfied: orjson~=3.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.11.8)\n", "Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.2.2)\n", "Requirement already satisfied: pillow<12.0,>=8.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (11.3.0)\n", "Requirement already satisfied: pydub in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.25.1)\n", "Requirement already satisfied: python-multipart>=0.0.18 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.0.22)\n", "Requirement already satisfied: ruff>=0.9.3 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.15.8)\n", "Requirement already satisfied: safehttpx<0.2.0,>=0.1.6 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.1.7)\n", "Requirement already satisfied: semantic-version~=2.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.10.0)\n", "Requirement already satisfied: tomlkit<0.14.0,>=0.12.0 in /usr/local/lib/python3.12/dist-packages (from gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.13.3)\n", "Requirement already satisfied: fsspec in /usr/local/lib/python3.12/dist-packages (from gradio-client==1.14.0->gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2025.3.0)\n", "Requirement already satisfied: certifi in /usr/local/lib/python3.12/dist-packages (from httpx>=0.28.1->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2026.2.25)\n", "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.12/dist-packages (from httpx>=0.28.1->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.0.9)\n", "Requirement already satisfied: idna in /usr/local/lib/python3.12/dist-packages (from httpx>=0.28.1->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.11)\n", "Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.12/dist-packages (from httpcore==1.*->httpx>=0.28.1->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.16.0)\n", "Requirement already satisfied: filelock>=3.10.0 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub>=0.20.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.25.2)\n", "Requirement already satisfied: hf-xet<2.0.0,>=1.4.2 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub>=0.20.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.4.2)\n", "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub>=0.20.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.67.3)\n", "Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.12/dist-packages (from openai>=2.7.2->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.9.0)\n", "Requirement already satisfied: jiter<1,>=0.10.0 in /usr/local/lib/python3.12/dist-packages (from openai>=2.7.2->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.13.0)\n", "Requirement already satisfied: sniffio in /usr/local/lib/python3.12/dist-packages (from openai>=2.7.2->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.3.1)\n", "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.12/dist-packages (from pydantic>=2.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.7.0)\n", "Requirement already satisfied: pydantic-core==2.41.4 in /usr/local/lib/python3.12/dist-packages (from pydantic>=2.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.41.4)\n", "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests>=2.25.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.4.6)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests>=2.25.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.5.0)\n", "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.12/dist-packages (from rich>=13.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.0.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.12/dist-packages (from rich>=13.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.20.0)\n", "Requirement already satisfied: click>=8.2.1 in /usr/local/lib/python3.12/dist-packages (from typer>=0.9.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (8.3.1)\n", "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.12/dist-packages (from typer>=0.9.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.5.4)\n", "Requirement already satisfied: cryptography in /usr/local/lib/python3.12/dist-packages (from authlib>=1.6.5->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (43.0.3)\n", "Requirement already satisfied: attrs>=23.1.0 in /usr/local/lib/python3.12/dist-packages (from cyclopts>=4.0.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (26.1.0)\n", "Requirement already satisfied: docstring-parser<4.0,>=0.15 in /usr/local/lib/python3.12/dist-packages (from cyclopts>=4.0.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.17.0)\n", "Collecting rich-rst<2.0.0,>=1.3.1 (from cyclopts>=4.0.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading rich_rst-1.3.2-py3-none-any.whl.metadata (6.1 kB)\n", "Collecting pathable<0.6.0,>=0.5.0 (from jsonschema-path>=0.3.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading pathable-0.5.0-py3-none-any.whl.metadata (5.9 kB)\n", "Requirement already satisfied: referencing<0.38.0 in /usr/local/lib/python3.12/dist-packages (from jsonschema-path>=0.3.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.37.0)\n", "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.12/dist-packages (from markdown-it-py>=2.2.0->rich>=13.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.1.2)\n", "Requirement already satisfied: httpx-sse>=0.4 in /usr/local/lib/python3.12/dist-packages (from mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.4.3)\n", "Requirement already satisfied: jsonschema>=4.20.0 in /usr/local/lib/python3.12/dist-packages (from mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.26.0)\n", "Requirement already satisfied: pydantic-settings>=2.5.2 in /usr/local/lib/python3.12/dist-packages (from mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.13.1)\n", "Requirement already satisfied: pyjwt>=2.10.1 in /usr/local/lib/python3.12/dist-packages (from pyjwt[crypto]>=2.10.1->mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.12.1)\n", "Requirement already satisfied: sse-starlette>=1.6.1 in /usr/local/lib/python3.12/dist-packages (from mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.3.4)\n", "Requirement already satisfied: importlib-metadata<8.8.0,>=6.0 in /usr/local/lib/python3.12/dist-packages (from opentelemetry-api>=1.20.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (8.7.1)\n", "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas<3.0,>=1.0->gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.9.0.post0)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas<3.0,>=1.0->gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2025.2)\n", "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas<3.0,>=1.0->gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2025.3)\n", "Requirement already satisfied: beartype>=0.20.0 in /usr/local/lib/python3.12/dist-packages (from py-key-value-aio<0.5.0,>=0.4.4->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.22.9)\n", "Collecting aiofile>=3.5.0 (from py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading aiofile-3.9.0-py3-none-any.whl.metadata (14 kB)\n", "Requirement already satisfied: keyring>=25.6.0 in /usr/local/lib/python3.12/dist-packages (from py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (25.7.0)\n", "Requirement already satisfied: cachetools>=5.0.0 in /usr/local/lib/python3.12/dist-packages (from py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (6.2.6)\n", "Collecting email-validator>=2.0.0 (from pydantic[email]>=2.11.7->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading email_validator-2.3.0-py3-none-any.whl.metadata (26 kB)\n", "Collecting caio<0.10.0,>=0.9.0 (from aiofile>=3.5.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading caio-0.9.25-cp312-cp312-manylinux_2_34_x86_64.whl.metadata (3.3 kB)\n", "Collecting dnspython>=2.0.0 (from email-validator>=2.0.0->pydantic[email]>=2.11.7->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0)\n", " Downloading dnspython-2.8.0-py3-none-any.whl.metadata (5.7 kB)\n", "Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.12/dist-packages (from importlib-metadata<8.8.0,>=6.0->opentelemetry-api>=1.20.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.23.0)\n", "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.12/dist-packages (from jsonschema>=4.20.0->mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2025.9.1)\n", "Requirement already satisfied: rpds-py>=0.25.0 in /usr/local/lib/python3.12/dist-packages (from jsonschema>=4.20.0->mcp<2.0,>=1.24.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.30.0)\n", "Requirement already satisfied: SecretStorage>=3.2 in /usr/local/lib/python3.12/dist-packages (from keyring>=25.6.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.5.0)\n", "Requirement already satisfied: jeepney>=0.4.2 in /usr/local/lib/python3.12/dist-packages (from keyring>=25.6.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.9.0)\n", "Requirement already satisfied: jaraco.classes in /usr/local/lib/python3.12/dist-packages (from keyring>=25.6.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.4.0)\n", "Requirement already satisfied: jaraco.functools in /usr/local/lib/python3.12/dist-packages (from keyring>=25.6.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (4.4.0)\n", "Requirement already satisfied: jaraco.context in /usr/local/lib/python3.12/dist-packages (from keyring>=25.6.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (6.1.2)\n", "Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.12/dist-packages (from cryptography->authlib>=1.6.5->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (2.0.0)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas<3.0,>=1.0->gradio>=4.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (1.17.0)\n", "Requirement already satisfied: docutils in /usr/local/lib/python3.12/dist-packages (from rich-rst<2.0.0,>=1.3.1->cyclopts>=4.0.0->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (0.21.2)\n", "Requirement already satisfied: pycparser in /usr/local/lib/python3.12/dist-packages (from cffi>=1.12->cryptography->authlib>=1.6.5->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (3.0)\n", "Requirement already satisfied: more-itertools in /usr/local/lib/python3.12/dist-packages (from jaraco.classes->keyring>=25.6.0->py-key-value-aio[filetree,keyring,memory]<0.5.0,>=0.4.4->fastmcp>=3.0.0->openenv-core>=0.2.2->openenv-core[core]>=0.2.2->openenv-GitHubIssueTriage==0.1.0) (10.8.0)\n", "Downloading openenv_core-0.2.3-py3-none-any.whl (174 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m174.6/174.6 kB\u001b[0m \u001b[31m7.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading fastmcp-3.2.0-py3-none-any.whl (705 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m705.5/705.5 kB\u001b[0m \u001b[31m27.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading tomli-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (253 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m253.3/253.3 kB\u001b[0m \u001b[31m24.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading tomli_w-1.2.0-py3-none-any.whl (6.7 kB)\n", "Downloading cyclopts-4.10.1-py3-none-any.whl (204 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m204.3/204.3 kB\u001b[0m \u001b[31m20.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading exceptiongroup-1.3.1-py3-none-any.whl (16 kB)\n", "Downloading jsonref-1.1.0-py3-none-any.whl (9.4 kB)\n", "Downloading jsonschema_path-0.4.5-py3-none-any.whl (19 kB)\n", "Downloading openapi_pydantic-0.5.1-py3-none-any.whl (96 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m96.4/96.4 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading py_key_value_aio-0.4.4-py3-none-any.whl (152 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m152.3/152.3 kB\u001b[0m \u001b[31m17.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading uncalled_for-0.2.0-py3-none-any.whl (11 kB)\n", "Downloading aiofile-3.9.0-py3-none-any.whl (19 kB)\n", "Downloading email_validator-2.3.0-py3-none-any.whl (35 kB)\n", "Downloading pathable-0.5.0-py3-none-any.whl (16 kB)\n", "Downloading rich_rst-1.3.2-py3-none-any.whl (12 kB)\n", "Downloading caio-0.9.25-cp312-cp312-manylinux_2_34_x86_64.whl (80 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m80.2/80.2 kB\u001b[0m \u001b[31m9.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading dnspython-2.8.0-py3-none-any.whl (331 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m331.1/331.1 kB\u001b[0m \u001b[31m32.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hBuilding wheels for collected packages: openenv-GitHubIssueTriage\n", " Building wheel for openenv-GitHubIssueTriage (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", " Created wheel for openenv-GitHubIssueTriage: filename=openenv_githubissuetriage-0.1.0-py3-none-any.whl size=41044 sha256=9ff8666973822cb59f537443f8cfda384d58440e81ca1040c437bddff066007a\n", " Stored in directory: /tmp/pip-ephem-wheel-cache-73l7c_0e/wheels/e3/a1/2e/790c7cfe319ad5d2d228596900085edeb4197812d880c746eb\n", "Successfully built openenv-GitHubIssueTriage\n", "Installing collected packages: uncalled-for, tomli-w, tomli, py-key-value-aio, pathable, jsonref, exceptiongroup, dnspython, caio, jsonschema-path, email-validator, aiofile, rich-rst, openapi-pydantic, cyclopts, fastmcp, openenv-core, openenv-GitHubIssueTriage\n", "Successfully installed aiofile-3.9.0 caio-0.9.25 cyclopts-4.10.1 dnspython-2.8.0 email-validator-2.3.0 exceptiongroup-1.3.1 fastmcp-3.2.0 jsonref-1.1.0 jsonschema-path-0.4.5 openapi-pydantic-0.5.1 openenv-GitHubIssueTriage-0.1.0 openenv-core-0.2.3 pathable-0.5.0 py-key-value-aio-0.4.4 rich-rst-1.3.2 tomli-2.4.1 tomli-w-1.2.0 uncalled-for-0.2.0\n" ] } ] }, { "cell_type": "code", "source": [ "from __future__ import annotations\n", "\n", "import json\n", "import os\n", "from typing import Any, Dict, List\n", "\n", "from dotenv import load_dotenv\n", "from openai import OpenAI\n", "from pydantic import TypeAdapter, ValidationError\n", "\n", "from GitHubIssueTriage import Action, ActionType\n", "\n", "load_dotenv()\n", "\n", "API_KEY = \"\"\n", "BASE_URL = \"\"\n", "\n", "ACTION_ADAPTER = TypeAdapter(Action)\n", "\n", "SYSTEM_PROMPT = \"\"\"\n", "You are a GitHub Issue Triage Manager agent operating inside a strict Pydantic-validated action environment.\n", "\n", "You MUST output exactly one JSON object and nothing else.\n", "\n", "Hard requirements:\n", "- The JSON object must conform to exactly one of the Action models in the discriminated union.\n", "- The action discriminator key is \"type\", not \"action\".\n", "- Never output plain strings, nested wrappers, explanations, markdown, or extra keys.\n", "- Every action must include all required fields for that action.\n", "- Use only these exact action type values:\n", " read_issue\n", " read_repo_rules\n", " read_label_definitions\n", " read_team_routing\n", " read_assignee_pool\n", " read_milestones\n", " search_similar_issues\n", " add_label\n", " remove_label\n", " assign_user\n", " set_priority\n", " set_milestone\n", " comment\n", " request_info\n", " provide_info\n", " mark_duplicate\n", " close_issue\n", " reopen_issue\n", " noop\n", "\n", "Field requirements:\n", "- read_issue MUST include \"issue_id\"\n", "- request_info MUST include \"fields\"\n", "- provide_info MUST include \"fields\"\n", "- add_label MUST include \"label\"\n", "- remove_label MUST include \"label\"\n", "- assign_user MUST include \"username\"\n", "- set_priority MUST include \"priority\"\n", "- set_milestone MUST include \"milestone\"\n", "- comment MUST include \"text\"\n", "- mark_duplicate MUST include \"issue_id\"\n", "- close_issue MUST include \"reason\"\n", "- reopen_issue MUST include \"reason\"\n", "\n", "Context rules:\n", "- Read the issue and repo rules early if you need context before taking a triage action.\n", "- If required information is missing, choose REQUEST_INFO and list only the missing fields.\n", "- If a strong duplicate is present, choose MARK_DUPLICATE with the correct issue_id.\n", "- Follow repo rules for labels, priority, milestone, severity, routing, and closure.\n", "- Take only one action per step.\n", "- Keep COMMENT short and focused.\n", "\"\"\".strip()\n", "\n", "\n", "class IssueTriageAgent:\n", " def __init__(self) -> None:\n", " self.api_base_url = BASE_URL\n", " self.api_key = API_KEY\n", " self.model_name = os.getenv(\"MODEL_NAME\", \"oca/gpt-5\")\n", " self.temperature = float(os.getenv(\"TEMPERATURE\", \"0.2\"))\n", " self.max_tokens = int(os.getenv(\"MAX_OUTPUT_TOKENS\", \"200\"))\n", "\n", " print(f\"Using API base URL: {self.api_base_url}\")\n", " print(f\"Using model: {self.model_name}\")\n", " print(f\"Using API key: {'Yes' if self.api_key else 'No'}\")\n", "\n", " if not self.api_key:\n", " raise RuntimeError(\"Missing API_KEY / HF_TOKEN / OPENAI_API_KEY.\")\n", "\n", " self.client = OpenAI(api_key=self.api_key, base_url=self.api_base_url)\n", "\n", " def _build_messages(self, observation: Dict[str, Any]) -> List[Dict[str, str]]:\n", " return [\n", " {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n", " {\n", " \"role\": \"user\",\n", " \"content\": json.dumps(\n", " {\n", " \"instruction\": \"Choose the next best triage action.\",\n", " \"observation\": observation,\n", " },\n", " indent=2,\n", " ),\n", " },\n", " ]\n", "\n", " def _strip_code_fences(self, text: str) -> str:\n", " text = text.strip()\n", " if text.startswith(\"```\"):\n", " lines = text.splitlines()\n", " if len(lines) >= 2 and lines[0].startswith(\"```\"):\n", " lines = lines[1:]\n", " if lines and lines[-1].strip().startswith(\"```\"):\n", " lines = lines[:-1]\n", " text = \"\\n\".join(lines).strip()\n", " return text\n", "\n", " def _extract_json_object(self, text: str) -> str:\n", " text = self._strip_code_fences(text)\n", "\n", " if text.startswith(\"{\") and text.endswith(\"}\"):\n", " return text\n", "\n", " start = text.find(\"{\")\n", " end = text.rfind(\"}\")\n", " if start != -1 and end != -1 and end > start:\n", " return text[start : end + 1]\n", "\n", " raise ValueError(\"No JSON object found in model output.\")\n", "\n", " def _sanitize_action_dict(self, data: Dict[str, Any]) -> Dict[str, Any]:\n", " data = dict(data)\n", "\n", " if \"type\" not in data:\n", " if \"action\" in data:\n", " data[\"type\"] = data.pop(\"action\")\n", " elif \"action_type\" in data:\n", " data[\"type\"] = data.pop(\"action_type\")\n", "\n", " payload = data.pop(\"action_payload\", None)\n", " if isinstance(payload, dict):\n", " for key, value in payload.items():\n", " data.setdefault(key, value)\n", "\n", " for key in [\n", " \"outcome\",\n", " \"success\",\n", " \"timestamp\",\n", " \"step_index\",\n", " \"message\",\n", " \"analysis\",\n", " \"thought\",\n", " \"reasoning\",\n", " ]:\n", " data.pop(key, None)\n", "\n", " return data\n", "\n", " def _parse_action_json(self, raw_text: str) -> Dict[str, Any]:\n", " json_text = self._extract_json_object(raw_text)\n", " data = json.loads(json_text)\n", " if not isinstance(data, dict):\n", " raise ValueError(\"Model output was not a JSON object.\")\n", "\n", " sanitized = self._sanitize_action_dict(data)\n", " action = ACTION_ADAPTER.validate_python(sanitized)\n", " return action.model_dump(mode=\"json\", exclude_none=True)\n", "\n", " def next_action(self, observation: Dict[str, Any]) -> Dict[str, Any]:\n", " try:\n", " stream = self.client.chat.completions.create(\n", " model=self.model_name,\n", " messages=self._build_messages(observation),\n", " stream=True,\n", " temperature=self.temperature,\n", " max_tokens=self.max_tokens,\n", " )\n", "\n", " parts: List[str] = []\n", " for chunk in stream:\n", " delta = chunk.choices[0].delta.content\n", " if delta:\n", " parts.append(delta)\n", "\n", " raw_text = \"\".join(parts).strip()\n", " print(f\"[Debug] LLM Raw Stream Output: {raw_text}\")\n", "\n", " return self._parse_action_json(raw_text)\n", "\n", " except Exception as e:\n", " print(f\"Error occurred in next_action_streaming: {e}\")\n", " return {\"type\": ActionType.NOOP.value}" ], "metadata": { "id": "oUxoBvAPCY2j" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from __future__ import annotations\n", "\n", "import argparse\n", "import json\n", "from typing import Any, Dict, List, Optional, Protocol\n", "from types import SimpleNamespace\n", "from urllib.parse import urlparse\n", "\n", "try:\n", " from GitHubIssueTriage import (\n", " ActionType,\n", " GithubissuetriageEnv,\n", " grade_episode,\n", " load_episode_from_source,\n", " GitHubIssueTriageEnvironment,\n", " )\n", "except ImportError: # pragma: no cover\n", " from models import ActionType\n", " from client import GithubissuetriageEnv\n", " from server.grader import grade_episode\n", " from server.loader import load_episode_from_source\n", "\n", "\n", "def _structured_print(label: str, payload: Dict) -> None:\n", " print(f\"[{label}] {json.dumps(payload, sort_keys=True)}\", flush=True)\n", "\n", "\n", "def _observation_snapshot(observation) -> Dict:\n", " return {\n", " \"step_count\": observation.step_count,\n", " \"remaining_steps\": observation.remaining_steps,\n", " \"done\": observation.done,\n", " \"last_action_message\": observation.last_action_message,\n", " \"objective_summary\": observation.objective_summary,\n", " \"pending_missing_fields\": getattr(observation, \"pending_missing_fields\", []),\n", " \"provided_fields\": getattr(observation, \"provided_fields\", {}),\n", " }\n", "\n", "\n", "def _parse_github_issue_url(issue_url: str) -> tuple[str, str]:\n", " parsed = urlparse(issue_url)\n", " parts = [p for p in parsed.path.split(\"/\") if p]\n", "\n", " if len(parts) < 4 or parts[2] != \"issues\":\n", " raise ValueError(\n", " f\"Unsupported GitHub issue URL: {issue_url}. Expected https://github.com/OWNER/REPO/issues/123\"\n", " )\n", "\n", " owner = parts[0]\n", " repo = parts[1]\n", " issue_id = parts[3]\n", " return f\"{owner}/{repo}\", issue_id\n", "\n", "\n", "def _collect_provided_info(fields: List[str]) -> Dict[str, str]:\n", " print(\"\\nThe environment requested more information.\")\n", " print(\"Enter values for the fields below. Leave blank to skip any field.\\n\")\n", "\n", " values: Dict[str, str] = {}\n", " for field in fields:\n", " value = input(f\"{field}: \").strip()\n", " if value:\n", " values[field] = value\n", " return values\n", "\n", "\n", "def _build_provide_info_action(fields: List[str]) -> Dict[str, object]:\n", " return {\n", " \"type\": ActionType.PROVIDE_INFO.value,\n", " \"fields\": _collect_provided_info(fields),\n", " }\n", "\n", "\n", "class EpisodeEnv:\n", " \"\"\"Adapter that returns an observation from reset(), which run_episode expects.\"\"\"\n", "\n", " def __init__(self, sync_client):\n", " self._client = sync_client\n", " self._last_observation = None\n", "\n", " def __enter__(self):\n", " self._client.__enter__()\n", " return self\n", "\n", " def __exit__(self, exc_type, exc, tb):\n", " return self._client.__exit__(exc_type, exc, tb)\n", "\n", " def reset(self, **kwargs):\n", " result = self._client.reset(**kwargs)\n", " self._last_observation = result.observation\n", " return self._last_observation\n", "\n", " def step(self, action, **kwargs):\n", " result = self._client.step(action, **kwargs)\n", " reward_value = float(result.reward or 0.0)\n", " self._last_observation = result.observation\n", "\n", " reward_proxy = SimpleNamespace(\n", " total=reward_value,\n", " model_dump=lambda: {\"total\": reward_value},\n", " )\n", " info_proxy = SimpleNamespace(\n", " action_valid=getattr(result.observation, \"last_action_valid\", True),\n", " action_effect=getattr(result.observation, \"last_action_message\", \"\"),\n", " grader_notes=[],\n", " changed_fields=[],\n", " reward_breakdown={\"total\": reward_value},\n", " reward_components={},\n", " )\n", "\n", " return SimpleNamespace(\n", " observation=result.observation,\n", " reward=reward_proxy,\n", " done=result.done,\n", " info=info_proxy,\n", " )\n", "\n", " @property\n", " def state(self):\n", " if self._last_observation is None:\n", " return SimpleNamespace()\n", " return self._last_observation\n", "\n", "\n", "def run_episode(\n", " env,\n", " agent: IssueTriageAgent,\n", ") -> Dict[str, float]:\n", " observation = env.reset()\n", "\n", " _structured_print(\n", " \"START\",\n", " {\n", " \"task_id\": observation.task.task_id,\n", " \"episode_id\": observation.episode_id,\n", " \"difficulty\": observation.task.difficulty.value,\n", " \"max_steps\": observation.task.max_steps,\n", " \"objective_summary\": observation.objective_summary,\n", " },\n", " )\n", "\n", " step_index = 0\n", "\n", " while True:\n", " action = agent.next_action(observation.model_dump())\n", "\n", " # Debug logging for the action being sent\n", " _structured_print(\"DEBUG_ACTION\", action)\n", "\n", " try:\n", " step_result = env.step(action)\n", " except RuntimeError as e:\n", " # Catch OpenEnv server errors and provide context\n", " error_msg = str(e)\n", " print(f\"[ERROR] Environment step failed: {error_msg}\", flush=True)\n", " print(f\"[ERROR] Action was: {json.dumps(action, sort_keys=True)}\", flush=True)\n", " print(f\"[ERROR] Observation state: episode_id={observation.episode_id}, step={step_index}\", flush=True)\n", " raise\n", "\n", " _structured_print(\n", " \"STEP\",\n", " {\n", " \"task_id\": observation.task.task_id,\n", " \"step\": step_index,\n", " \"action\": action,\n", " \"reward\": step_result.reward.total,\n", " \"reward_breakdown\": step_result.reward.model_dump(),\n", " \"action_valid\": step_result.info.action_valid,\n", " \"action_effect\": step_result.info.action_effect,\n", " \"grader_notes\": step_result.info.grader_notes,\n", " \"observation\": _observation_snapshot(step_result.observation),\n", " },\n", " )\n", "\n", " observation = step_result.observation\n", " step_index += 1\n", "\n", " if step_result.done:\n", " break\n", "\n", " if action.get(\"type\") == ActionType.REQUEST_INFO.value:\n", " requested_fields = action.get(\"fields\") or list(\n", " getattr(observation, \"pending_missing_fields\", [])\n", " )\n", " if requested_fields:\n", " provide_action = _build_provide_info_action(list(requested_fields))\n", " try:\n", " provide_result = env.step(provide_action)\n", " except RuntimeError as e:\n", " error_msg = str(e)\n", " print(f\"[ERROR] Environment step failed on PROVIDE_INFO: {error_msg}\", flush=True)\n", " print(f\"[ERROR] Action was: {json.dumps(provide_action, sort_keys=True)}\", flush=True)\n", " raise\n", "\n", " _structured_print(\n", " \"STEP\",\n", " {\n", " \"task_id\": observation.task.task_id,\n", " \"step\": step_index,\n", " \"action\": provide_action,\n", " \"reward\": provide_result.reward.total,\n", " \"reward_breakdown\": provide_result.reward.model_dump(),\n", " \"action_valid\": provide_result.info.action_valid,\n", " \"action_effect\": provide_result.info.action_effect,\n", " \"grader_notes\": provide_result.info.grader_notes,\n", " \"observation\": _observation_snapshot(provide_result.observation),\n", " },\n", " )\n", "\n", " observation = provide_result.observation\n", " step_index += 1\n", "\n", " if provide_result.done:\n", " break\n", "\n", " final_state = env.state\n", " grade = grade_episode(final_state)\n", "\n", " result_payload = {\n", " \"task_id\": observation.task.task_id,\n", " \"steps_taken\": step_index,\n", " \"score\": grade.score,\n", " \"matched_labels\": grade.matched_labels,\n", " \"matched_assignee\": grade.matched_assignee,\n", " \"matched_priority\": grade.matched_priority,\n", " \"matched_milestone\": grade.matched_milestone,\n", " \"duplicate_matched\": grade.duplicate_matched,\n", " \"missing_fields_requested\": grade.missing_fields_requested,\n", " \"closed_correctly\": grade.closed_correctly,\n", " \"comment_accepted\": grade.comment_accepted,\n", " \"notes\": grade.notes,\n", " }\n", " _structured_print(\"END\", result_payload)\n", "\n", " return {\"score\": grade.score, \"steps\": float(step_index)}\n", "\n", "\n", "\n", "\n", "\n", "def main() -> None:\n", " # 🔧 Hardcoded config (edit here if needed)\n", " repo_rules = \"https://github.com/vinay-852/GitHubIssueTriage/blob/main/data/url_repo_rules.json\"\n", " issue_url = \"https://github.com/ai-joe-git/pocket-tts-server/issues/3\"\n", " live_github = True\n", " task_id = None\n", " max_steps = 10\n", " base_url = \"https://vinay-pepakayala-githubissuetriagemanager.hf.space\"\n", " transport = \"remote\"\n", " episode = load_episode_from_source(\n", " repo_rules_path=repo_rules,\n", " issue_source=issue_url,\n", " live_github=live_github,\n", " task_id=task_id,\n", " max_steps=max_steps,\n", " )\n", "\n", " agent = IssueTriageAgent()\n", "\n", " if transport == \"local\":\n", "\n", " env = GitHubIssueTriageEnvironment(\n", " episodes=[episode],\n", " strict_mode=True,\n", " live_github=True,\n", " )\n", " run_episode(env, agent)\n", " else:\n", " with GithubissuetriageEnv(\n", " base_url=base_url,\n", " episodes=[episode],\n", " strict_mode=True,\n", " live_github=True,\n", " ).sync() as client:\n", " env = EpisodeEnv(client)\n", " print(run_episode(env, agent))\n", "\n", "if __name__ == \"__main__\":\n", " main()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "QOet6sSWCyzk", "outputId": "2a77831c-8021-4dce-e4b1-e1440eb3981f" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Using API base URL: https://code-internal.aiservice.us-chicago-1.oci.oraclecloud.com/20250206/app/litellm\n", "Using model: oca/gpt-5\n", "Using API key: Yes\n", "[CLIENT_PARSE_RESULT] Received payload keys: ['observation', 'reward', 'done']\n", "[CLIENT_PARSE_RESULT] Observation keys: ['episode_id', 'task', 'issue', 'repo_rules', 'available_labels', 'available_assignees', 'available_milestones', 'candidate_duplicates', 'action_history', 'pending_missing_fields', 'objective_summary', 'progress_metrics', 'provided_fields', 'remaining_steps', 'step_count', 'last_action_valid', 'last_action_message']\n", "[START] {\"difficulty\": \"easy\", \"episode_id\": \"ep_easy_routing\", \"max_steps\": 8, \"objective_summary\": [\"Labels needed: component:api, severity:critical, status:triaged\"], \"task_id\": \"triage_easy_api_p1\"}\n", "[Debug] LLM Raw Stream Output: {\"type\":\"add_label\",\"label\":\"component:api\"}\n", "[DEBUG_ACTION] {\"label\": \"component:api\", \"type\": \"add_label\"}\n", "[CLIENT_STEP_PAYLOAD] {\"type\": \"add_label\", \"label\": \"component:api\"}\n", "[CLIENT_PARSE_RESULT] Received payload keys: ['observation', 'reward', 'done']\n", "[CLIENT_PARSE_RESULT] Observation keys: ['episode_id', 'task', 'issue', 'repo_rules', 'reward', 'available_labels', 'available_assignees', 'available_milestones', 'candidate_duplicates', 'action_history', 'pending_missing_fields', 'objective_summary', 'progress_metrics', 'provided_fields', 'remaining_steps', 'step_count', 'done', 'last_action_valid', 'last_action_message']\n", "[STEP] {\"action\": {\"label\": \"component:api\", \"type\": \"add_label\"}, \"action_effect\": \"label_added:component:api\", \"action_valid\": true, \"grader_notes\": [], \"observation\": {\"done\": false, \"last_action_message\": \"label_added:component:api\", \"objective_summary\": [\"Labels needed: severity:critical, status:triaged\"], \"pending_missing_fields\": [], \"provided_fields\": {}, \"remaining_steps\": 7, \"step_count\": 1}, \"reward\": 0.83, \"reward_breakdown\": {\"total\": 0.83}, \"step\": 0, \"task_id\": \"triage_easy_api_p1\"}\n", "[Debug] LLM Raw Stream Output: {\"type\":\"add_label\",\"label\":\"severity:critical\"}\n", "[DEBUG_ACTION] {\"label\": \"severity:critical\", \"type\": \"add_label\"}\n", "[CLIENT_STEP_PAYLOAD] {\"type\": \"add_label\", \"label\": \"severity:critical\"}\n", "[CLIENT_PARSE_RESULT] Received payload keys: ['observation', 'reward', 'done']\n", "[CLIENT_PARSE_RESULT] Observation keys: ['episode_id', 'task', 'issue', 'repo_rules', 'reward', 'available_labels', 'available_assignees', 'available_milestones', 'candidate_duplicates', 'action_history', 'pending_missing_fields', 'objective_summary', 'progress_metrics', 'provided_fields', 'remaining_steps', 'step_count', 'done', 'last_action_valid', 'last_action_message']\n", "[STEP] {\"action\": {\"label\": \"severity:critical\", \"type\": \"add_label\"}, \"action_effect\": \"label_added:severity:critical\", \"action_valid\": true, \"grader_notes\": [], \"observation\": {\"done\": false, \"last_action_message\": \"label_added:severity:critical\", \"objective_summary\": [\"Labels needed: status:triaged\"], \"pending_missing_fields\": [], \"provided_fields\": {}, \"remaining_steps\": 6, \"step_count\": 2}, \"reward\": 0.83, \"reward_breakdown\": {\"total\": 0.83}, \"step\": 1, \"task_id\": \"triage_easy_api_p1\"}\n", "[Debug] LLM Raw Stream Output: {\"type\":\"add_label\",\"label\":\"status:triaged\"}\n", "[DEBUG_ACTION] {\"label\": \"status:triaged\", \"type\": \"add_label\"}\n", "[CLIENT_STEP_PAYLOAD] {\"type\": \"add_label\", \"label\": \"status:triaged\"}\n", "[CLIENT_PARSE_RESULT] Received payload keys: ['observation', 'reward', 'done']\n", "[CLIENT_PARSE_RESULT] Observation keys: ['episode_id', 'task', 'issue', 'repo_rules', 'reward', 'available_labels', 'available_assignees', 'available_milestones', 'candidate_duplicates', 'action_history', 'pending_missing_fields', 'objective_summary', 'progress_metrics', 'provided_fields', 'remaining_steps', 'step_count', 'done', 'last_action_valid', 'last_action_message']\n", "[STEP] {\"action\": {\"label\": \"status:triaged\", \"type\": \"add_label\"}, \"action_effect\": \"label_added:status:triaged\", \"action_valid\": true, \"grader_notes\": [], \"observation\": {\"done\": false, \"last_action_message\": \"label_added:status:triaged\", \"objective_summary\": [], \"pending_missing_fields\": [], \"provided_fields\": {}, \"remaining_steps\": 5, \"step_count\": 3}, \"reward\": 0.83, \"reward_breakdown\": {\"total\": 0.83}, \"step\": 2, \"task_id\": \"triage_easy_api_p1\"}\n", "[Debug] LLM Raw Stream Output: {\"type\":\"assign_user\",\"username\":\"devon\"}\n", "[DEBUG_ACTION] {\"type\": \"assign_user\", \"username\": \"devon\"}\n", "[CLIENT_STEP_PAYLOAD] {\"type\": \"assign_user\", \"username\": \"devon\"}\n", "[CLIENT_PARSE_RESULT] Received payload keys: ['observation', 'reward', 'done']\n", "[CLIENT_PARSE_RESULT] Observation keys: ['episode_id', 'task', 'issue', 'repo_rules', 'reward', 'available_labels', 'available_assignees', 'available_milestones', 'candidate_duplicates', 'action_history', 'pending_missing_fields', 'objective_summary', 'progress_metrics', 'provided_fields', 'remaining_steps', 'step_count', 'done', 'last_action_valid', 'last_action_message']\n", "[STEP] {\"action\": {\"type\": \"assign_user\", \"username\": \"devon\"}, \"action_effect\": \"assignee_set:devon\", \"action_valid\": true, \"grader_notes\": [], \"observation\": {\"done\": true, \"last_action_message\": \"assignee_set:devon\", \"objective_summary\": [], \"pending_missing_fields\": [], \"provided_fields\": {}, \"remaining_steps\": 4, \"step_count\": 4}, \"reward\": 0.98, \"reward_breakdown\": {\"total\": 0.98}, \"step\": 3, \"task_id\": \"triage_easy_api_p1\"}\n", "[END] {\"closed_correctly\": false, \"comment_accepted\": false, \"duplicate_matched\": false, \"matched_assignee\": true, \"matched_labels\": [\"type:bug\", \"component:api\", \"severity:critical\", \"status:triaged\"], \"matched_milestone\": true, \"matched_priority\": true, \"missing_fields_requested\": false, \"notes\": [\"No hidden_target present; graded on observable state.\"], \"score\": 0.8479999999999999, \"steps_taken\": 4, \"task_id\": \"triage_easy_api_p1\"}\n", "{'score': 0.8479999999999999, 'steps': 4.0}\n" ] } ] }, { "cell_type": "code", "source": [], "metadata": { "id": "EyTaCbuFFaAF" }, "execution_count": null, "outputs": [] } ] }