diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d02e053..0000000 --- a/.gitignore +++ /dev/null @@ -1,289 +0,0 @@ - Created by https://www.toptal.com/developers/gitignore/api/pycharm,python -# Edit at https://www.toptal.com/developers/gitignore?templates=pycharm,python - -### PyCharm ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# AWS User-specific -.idea/**/aws.xml - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# SonarLint plugin -.idea/sonarlint/ - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### PyCharm Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml -# .idea/misc.xml -# *.ipr - -# Sonarlint plugin -# https://plugins.jetbrains.com/plugin/7973-sonarlint -.idea/**/sonarlint/ - -# SonarQube Plugin -# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin -.idea/**/sonarIssues.xml - -# Markdown Navigator plugin -# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced -.idea/**/markdown-navigator.xml -.idea/**/markdown-navigator-enh.xml -.idea/**/markdown-navigator/ - -# Cache file creation bug -# See https://youtrack.jetbrains.com/issue/JBR-2257 -.idea/$CACHE_FILE$ - -# CodeStream plugin -# https://plugins.jetbrains.com/plugin/12206-codestream -.idea/codestream.xml - -# Azure Toolkit for IntelliJ plugin -# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij -.idea/**/azureSettings.xml - -### Python ### -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -### Python Patch ### -# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration -poetry.toml - -# ruff -.ruff_cache/ - -# LSP config files -pyrightconfig.json - -# End of https://www.toptal.com/developers/gitignore/api/pycharm,python \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/ai-lawyer-agent.iml b/.idea/ai-lawyer-agent.iml new file mode 100644 index 0000000..7d67021 --- /dev/null +++ b/.idea/ai-lawyer-agent.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..06bb031 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8b05534 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..01b20db --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.streamlit/config.toml b/.streamlit/config.toml deleted file mode 100644 index b5fa8c9..0000000 --- a/.streamlit/config.toml +++ /dev/null @@ -1,18 +0,0 @@ - -[browser] -serverAddress = "localhost" -gatherUsageStats = false -serverPort = 8501 - -[theme] -base = "light" -backgroundColor = "#E6F4FF" -secondaryBackgroundColor = "#D6EDFF" - -font = "Ubuntu, sans-serif" -baseFontSize = 16 -baseFontWeight = 300 -headingFont = "Ubuntu, sans-serif" - -baseRadius = "small" -#borderColor = "#D6EDFF" diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/app/__init__.py b/app/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/app.py b/app/app.py deleted file mode 100644 index 0dc8dfc..0000000 --- a/app/app.py +++ /dev/null @@ -1,93 +0,0 @@ -from datetime import datetime -import streamlit as st -from core.initialize_agent import assistant_agent -from core.stream_response import SQLiteSession -from app.components.sidebar import add_sidebar - -style_chat_message = """ - -""" - -def get_time() -> str: - return datetime.now().strftime("%d.%m.%Y %H:%M:%S") - -def init_session_state() -> None: - if "messages" not in st.session_state: - st.session_state.messages = [] - if "chat_session" not in st.session_state: - st.session_state.chat_session = SQLiteSession(":memory:") - if "show_about" not in st.session_state: - st.session_state.show_about = True - - st.markdown(style_chat_message, unsafe_allow_html=True) - -def create_app() -> None: - - st.set_page_config( - page_title="LawGPT", - page_icon="app/assets/images/title.png", - initial_sidebar_state="collapsed", - layout="centered", - menu_items={ - 'Get help': None, - 'Report a bug': None, - 'About': """ - This is a cool educational project exploring the creation of an AI agent powered by API keys. - You can learn how to build, interact with, and experiment with AI using real API integration. - """ - } - ) - - add_sidebar() - init_session_state() - - for message in st.session_state.messages: - with st.chat_message(message["role"], avatar=message["avatar"]): - st.markdown(message["content"]) - if "time" in message: - st.caption(message["time"]) - - user_avatar = "app/assets/images/user.png" - assistant_avatar = "app/assets/images/assistant.png" - - if request := st.chat_input("Ask anything"): - user_time = get_time() - - with st.chat_message(name="user", avatar=user_avatar): - st.markdown(f"{request}") - st.caption(user_time) - - user_message = {"role": "user", - "avatar": user_avatar, - "content": request, - "time": user_time} - st.session_state.messages.append(user_message) - - with st.chat_message(name="assistant", avatar=assistant_avatar): - with st.spinner("Thinking..."): - try: - response = st.write_stream(assistant_agent(request, st.session_state.chat_session)) - except Exception as e: - response = f"๏ธโš ๏ธ๐ŸŒ Error: {e}" - finally: - assistant_time = get_time() - - st.caption(assistant_time) - - assistant_message = {"role": "assistant", - "avatar": assistant_avatar, - "content": response, - "time": assistant_time} - st.session_state.messages.append(assistant_message) - - st.rerun() \ No newline at end of file diff --git a/app/assets/images/assistant.png b/app/assets/images/assistant.png deleted file mode 100644 index 9768b79..0000000 Binary files a/app/assets/images/assistant.png and /dev/null differ diff --git a/app/assets/images/title.png b/app/assets/images/title.png deleted file mode 100644 index 895dc45..0000000 Binary files a/app/assets/images/title.png and /dev/null differ diff --git a/app/assets/images/user.png b/app/assets/images/user.png deleted file mode 100644 index fe3d48e..0000000 Binary files a/app/assets/images/user.png and /dev/null differ diff --git a/app/components/__init__.py b/app/components/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/components/__pycache__/__init__.cpython-313.pyc b/app/components/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 8d9e969..0000000 Binary files a/app/components/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/app/components/__pycache__/sidebar.cpython-313.pyc b/app/components/__pycache__/sidebar.cpython-313.pyc deleted file mode 100644 index cf4d54e..0000000 Binary files a/app/components/__pycache__/sidebar.cpython-313.pyc and /dev/null differ diff --git a/app/components/sidebar.py b/app/components/sidebar.py deleted file mode 100644 index a776852..0000000 --- a/app/components/sidebar.py +++ /dev/null @@ -1,32 +0,0 @@ -import streamlit as st -from agents import SQLiteSession - -sidebar_style = """ - -""" - -def add_sidebar(): - st.markdown(sidebar_style, unsafe_allow_html=True) - - with st.sidebar: - - st.title("โš–๏ธ LawGPT") - st.markdown(":blue-badge[โš™๏ธTool] :orange-badge[โš ๏ธCurrent chat will be deleted]") - if st.button(":material/note_stack_add: Create new chat"): - st.session_state.messages = [] - st.session_state.chat_session = SQLiteSession(":memory:") diff --git a/core/__init__.py b/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/api/__init__.py b/core/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/api/fetch_api_data.py b/core/api/fetch_api_data.py deleted file mode 100644 index 0424a4d..0000000 --- a/core/api/fetch_api_data.py +++ /dev/null @@ -1,23 +0,0 @@ -import httpx - -async def fetch_api_data(icon: str, url: str, params: dict, remove_keys: list = None) -> dict: - try: - print(f"๐Ÿ”จ{icon}Input parameters: {params}") - async with httpx.AsyncClient() as client: - response = await client.get(url, params=params, timeout=10.0) - response.raise_for_status() - print(f"๐Ÿ–‡๏ธ{icon}Request URL: {response.url}") - - data = response.json() - if remove_keys and isinstance(data, dict): - for key in remove_keys: - data.pop(key, None) - print(f"๐Ÿšฎ{icon}Successfully removed key: {key}") - return data - - except httpx.HTTPStatusError as e: - return {"error": "http_error", "status_code": e.response.status_code, "detail": e.response.text} - except httpx.RequestError as e: - return {"error": "request_error", "status_code": str(e)} - except Exception as e: - return {"error": "unexpected_error", "status_code": str(e)} diff --git a/core/api/schemas.py b/core/api/schemas.py deleted file mode 100644 index 2f48dc9..0000000 --- a/core/api/schemas.py +++ /dev/null @@ -1,178 +0,0 @@ -from pydantic import BaseModel, Field, conint -from typing import Optional, List, Literal - -# ================================================================================================================= -# COURT SCHEMAS -# ================================================================================================================= - -class Court(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - typSuduFacetFilter: Optional[List[str]] = Field(None, description="Court type (facet filter)") - krajFacetFilter: Optional[List[str]] = Field(None, description="Region (facet filter)") - okresFacetFilter: Optional[List[str]] = Field(None, description="District (facet filter)") - zahrnutZaniknuteSudy: Optional[bool] = Field(None, description="Flag to filter defunct/inactive courts") - page: Optional[conint(ge=1)] = Field(None, description="Requested page number (starting from 1)") - size: Optional[conint(ge=1)] = Field(None, description="Number of results per page") - indexDatumOd: Optional[str] = Field(None, description="Index date from (format YYYY-MM-DD)") - indexDatumDo: Optional[str] = Field(None, description="Index date to (format YYYY-MM-DD)") - sortProperty: Optional[str] = Field(None, description="Field to sort the output by") - sortDirection: Literal["ASC", "DESC"] = Field("ASC", description="Sort direction (ASC or DESC)") - -class CourtID(BaseModel): - id: str = Field(..., description="Court identifier (e. g., sud_175)") - -class CourtAutocomplete(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - limit: Optional[conint(ge=1)] = Field(None, description="Limits the number of returned results (pagination)") - - -# ================================================================================================================= -# JUDGE SCHEMAS -# ================================================================================================================= - -class Judge(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - funkciaFacetFilter: Optional[List[str]] = Field(None, description="Judge function (facet filter)") - typSuduFacetFilter: Optional[List[str]] = Field(None, description="Court type (facet filter)") - krajFacetFilter: Optional[List[str]] = Field(None, description="Region (facet filter)") - okresFacetFilter: Optional[List[str]] = Field(None, description="District (facet filter)") - stavZapisuFacetFilter: Optional[List[str]] = Field(None, description="Record status (facet filter)") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - indexDatumOd: Optional[str] = Field(None, description="Index date from (format YYYY-MM-DD)") - indexDatumDo: Optional[str] = Field(None, description="Index date to (format YYYY-MM-DD)") - page: Optional[conint(ge=1)] = Field(None, description="Requested page number (starting from 1)") - size: Optional[conint(ge=1)] = Field(None, description="Number of results per page") - sortProperty: Optional[str] = Field(None, description="Field to sort the output by") - sortDirection: Literal["ASC", "DESC"] = Field("ASC", description="Sort direction (ASC or DESC)") - -class JudgeID(BaseModel): - id: str = Field(..., description="Judge identifier (e. g., sudca_1)") - -class JudgeAutocomplete(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - limit: Optional[conint(ge=1)] = Field(None, description="Limits the number of returned results (pagination)") - - -# ================================================================================================================= -# CONTRACTS SCHEMAS -# ================================================================================================================= - -class Contracts(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - typDokumentuFacetFilter: Optional[List[str]] = Field(None, description="Contract's type (facet filter)") - odberatelFacetFilter: Optional[List[str]] = Field(None, description="Subscriber filter") - dodavatelFacetFilter: Optional[List[str]] = Field(None, description="Supplier filter") - hodnotaZmluvyFacetFilter: Optional[List[str]] = Field(None, description="Contract value in EUR filter") - datumZverejeneniaOd: Optional[str] = Field(None, description="Index date from (format YYYY-MM-DD)") - datumZverejeneniaDo: Optional[str] = Field(None, description="Index date to (format YYYY-MM-DD)") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - indexDatumOd: Optional[str] = Field(None, description="Index date from (format YYYY-MM-DD)") - indexDatumDo: Optional[str] = Field(None, description="Index date to (format YYYY-MM-DD)") - sortProperty: Optional[str] = Field(None, description="Field to sort the output by") - sortDirection: Literal["ASC", "DESC"] = Field("ASC", description="Sort direction (ASC or DESC)") - page: Optional[conint(ge=1)] = Field(None, description="Requested page number (starting from 1)") - size: Optional[conint(ge=1)] = Field(None, description="Number of results per page") - -class ContractID(BaseModel): - idZmluvy: str = Field(..., description="Contract identifier (e. g., 2156252)") - -class ContractAutocomplete(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - limit: Optional[conint(ge=1)] = Field(None, description="Limits the number of returned results (pagination)") - - -# ================================================================================================================= -# DECISION SCHEMAS -# ================================================================================================================= - -class Decision(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - typSuduFacetFilter: Optional[List[str]] = Field(None, description="Court type (facet filter)") - krajFacetFilter: Optional[List[str]] = Field(None, description="Region (facet filter)") - okresFacetFilter: Optional[List[str]] = Field(None, description="District (facet filter)") - odkazovanePredpisy: Optional[str] = Field(None, description="Referenced regulations") - oblastPravnejUpravyFacetFilter: Optional[List[str]] = Field(None, description="Area of legal regulation (facet filter)") - podOblastPravnejUpravyFacetFilter: Optional[List[str]] = Field(None, description="Sub-area of legal regulation (facet filter)") - formaRozhodnutiaFacetFilter: Optional[List[str]] = Field(None, description="Form of decision (facet filter)") - povahaRozhodnutiaFacetFilter: Optional[str] = Field(None, description="Nature of decision") - vydaniaOd: Optional[str] = Field(None, description="Issue date from") - vydaniaDo: Optional[str] = Field(None, description="Issue date to") - ecli: Optional[str] = Field(None, description="ECLI identifier") - spisovaZnacka: Optional[str] = Field(None, description="Case reference number") - cisloSpisu: Optional[str] = Field(None, description="File identification number") - guidSudca: Optional[str] = Field(None, description="Judge identifier (e.g., sudca_1)") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - indexDatumOd: Optional[str] = Field(None, description="Index date from (format YYYY-MM-DD)") - indexDatumDo: Optional[str] = Field(None, description="Index date to (format YYYY-MM-DD)") - sortProperty: Optional[str] = Field(None, description="Field to sort the output by") - sortDirection: Literal["ASC", "DESC"] = Field("ASC", description="Sort direction (ASC or DESC)") - page: Optional[conint(ge=1)] = Field(None, description="Requested page number (starting from 1)") - size: Optional[conint(ge=1)] = Field(None, description="Number of results per page") - -class DecisionID(BaseModel): - id: str = Field(..., description="Decision identifier (e.g., a3310194-e9ac-4e6b-bfbd-25c40f26938b:1097de02-3389-405b-98a4-df7abea3f9ec)") - -class DecisionAutocomplete(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - limit: Optional[conint(ge=1)] = Field(None, description="Limits the number of returned results (pagination)") - - -# ================================================================================================================= -# CIVIL PROCEEDINGS SCHEMAS -# ================================================================================================================= - -class CivilProceedings(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - typSuduFacetFilter: Optional[List[str]] = Field(None, description="Court type (facet filter)") - krajFacetFilter: Optional[List[str]] = Field(None, description="Region (facet filter)") - okresFacetFilter: Optional[List[str]] = Field(None, description="District (facet filter)") - usekFacetFilter: Optional[List[str]] = Field(None, description="List of sections (facet filter)") - formaUkonuFacetFilter: Optional[List[str]] = Field(None, description="List of action types (facet filter)") - pojednavaniaOd: Optional[str] = Field(None, description="Hearing date from (DD.MM.YYYY)") - pojednavaniaDo: Optional[str] = Field(None, description="Hearing date to (DD.MM.YYYY)") - guidSudca: Optional[str] = Field(None, description="Judge identifier (e.g., sudca_1)") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - spisovaZnacka: Optional[str] = Field(None,description="Case reference number") - verejneVyhlasenie: Optional[bool] = Field(None,description="Flag indicating whether the announcement is public") - indexDatumOd: Optional[str] = Field(None, description="Index date from (format YYYY-MM-DD)") - indexDatumDo: Optional[str] = Field(None, description="Index date to (format YYYY-MM-DD)") - sortProperty: Optional[str] = Field(None, description="Field to sort the output by") - sortDirection: Literal["ASC", "DESC"] = Field("ASC", description="Sort direction (ASC or DESC)") - page: Optional[conint(ge=1)] = Field(None, description="Requested page number (starting from 1)") - size: Optional[conint(ge=1)] = Field(None, description="Number of results per page") - -class CivilProceedingsID(BaseModel): - id: str = Field(..., description="Identifier (e.g., 121e4d31-695e-41e1-9191-7c9ad5d8d484)") - -class CivilProceedingsAutocomplete(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - guidSud: Optional[str] = Field(None, description="Court identifier (e.g., sud_100)") - guidSudca: Optional[str] = Field(None, description="Judge identifier (e.g., sudca_1)") - verejneVyhlasenie: Optional[bool] = Field(None,description="Flag indicating whether the announcement is public") - limit: Optional[conint(ge=1)] = Field(None, description="Limits the number of returned results (pagination)") - - -# ================================================================================================================= -# ADMINISTRATIVE PROCEEDINGS SCHEMAS -# ================================================================================================================= - -class AdministrativeProceedings(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - druhFacetFilter: Optional[List[str]] = Field(None, description="List of types (faceted filter)") - datumPravoplatnostiOd: Optional[str] = Field(None, description="Validity date from (DD.MM.YYYY)") - datumPravoplatnostiDo: Optional[str] = Field(None, description="Validity date to (DD.MM.YYYY)") - page: Optional[conint(ge=1)] = Field(None, description="Requested page number (starting from 1)") - size: Optional[conint(ge=1)] = Field(None, description="Number of results per page") - sortProperty: Optional[str] = Field(None, description="Field to sort the output by") - sortDirection: Literal["ASC", "DESC"] = Field("ASC", description="Sort direction (ASC or DESC)") - -class AdministrativeProceedingsID(BaseModel): - id: str = Field(..., description="Identifier of administrative proceedings (e.g., spravneKonanie_103)") - -class AdministrativeProceedingsAutocomplete(BaseModel): - query: Optional[str] = Field(None, description="Search term or phrase") - limit: Optional[conint(ge=1)] = Field(None, description="Limits the number of returned results (pagination)") - diff --git a/core/api/tools/__init__.py b/core/api/tools/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/api/tools/admin_proceedings.py b/core/api/tools/admin_proceedings.py deleted file mode 100644 index a0eb7f2..0000000 --- a/core/api/tools/admin_proceedings.py +++ /dev/null @@ -1,54 +0,0 @@ -from core.api.fetch_api_data import fetch_api_data -from core.api.schemas import (AdministrativeProceedings, - AdministrativeProceedingsID, - AdministrativeProceedingsAutocomplete) -from agents import function_tool - -BASE_URL = "https://obcan.justice.sk/pilot/api/ress-isu-service" - -class AdminProceedingsAPI: - - @function_tool - async def admin_proceedings(self, params: AdministrativeProceedings) -> dict: - """ - Fetch a list of administrative proceedings from the Justice API with optional filtering. - - Args: - params (AdministrativeProceedings): Filtering and pagination parameters. - - Returns: - dict: A dictionary containing a list of administrative proceedings and related metadata. - """ - url = f"{BASE_URL}/v1/spravneKonanie" - - return await fetch_api_data(icon="โœ’๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def admin_proceedings_id(self, params: AdministrativeProceedingsID) -> dict: - """ - Fetch detailed information about a specific administrative proceeding by its identifier. - - Args: - params (AdministrativeProceedingsID): Unique identifier of the administrative proceeding. - - Returns: - dict: Details of the specified administrative proceeding. - """ - url = f"{BASE_URL}/v1/spravneKonanie/{params.id}" - - return await fetch_api_data(icon="โœ’๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def admin_proceedings_autocomplete(self, params: AdministrativeProceedingsAutocomplete) -> dict: - """ - Fetch autocomplete suggestions for administrative proceeding search terms. - - Args: - params (AdministrativeProceedingsAutocomplete): Parameters for autocomplete query (e.g., partial text). - - Returns: - dict: Suggested values matching the input query. - """ - url = f"{BASE_URL}/v1/spravneKonanie/autocomplete" - - return await fetch_api_data(icon="โœ’๏ธ", url=url, params=params.model_dump(exclude_none=True)) \ No newline at end of file diff --git a/core/api/tools/civil_proceedings.py b/core/api/tools/civil_proceedings.py deleted file mode 100644 index 4c6d3b1..0000000 --- a/core/api/tools/civil_proceedings.py +++ /dev/null @@ -1,56 +0,0 @@ -from core.api.fetch_api_data import fetch_api_data -from core.api.schemas import (CivilProceedings, - CivilProceedingsID, - CivilProceedingsAutocomplete) -from agents import function_tool - -BASE_URL = "https://obcan.justice.sk/pilot/api/ress-isu-service" - -class CivilProceedingsAPI: - - @function_tool - async def civil_proceedings(self, params: CivilProceedings) -> dict: - """ - Fetch a list of civil proceedings and publicly announced judgments - from the Justice API with optional filtering. - - Args: - params (CivilProceedings): Filtering and pagination parameters. - - Returns: - dict: A dictionary containing a list of civil proceedings and related metadata. - """ - url = f"{BASE_URL}/v1/obcianPojednavania" - - return await fetch_api_data(icon="๐Ÿ–Š๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def civil_proceedings_id(self, params: CivilProceedingsID) -> dict: - """ - Fetch detailed information about a specific civil proceeding - and publicly announced judgment by its identifier. - - Args: - params (CivilProceedingsID): Unique identifier of the civil proceeding. - - Returns: - dict: Details of the specified civil proceeding and judgment. - """ - url = f"{BASE_URL}/v1/obcianPojednavania/{params.id}" - - return await fetch_api_data(icon="๐Ÿ–Š๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def civil_proceedings_autocomplete(self, params: CivilProceedingsAutocomplete) -> dict: - """ - Fetch autocomplete suggestions for civil proceeding search terms. - - Args: - params (CivilProceedingsAutocomplete): Parameters for autocomplete query (e.g., partial text). - - Returns: - dict: Suggested values matching the input query. - """ - url = f"{BASE_URL}/v1/obcianPojednavania/autocomplete" - - return await fetch_api_data(icon="๐Ÿ–Š๏ธ", url=url, params=params.model_dump(exclude_none=True)) \ No newline at end of file diff --git a/core/api/tools/contracts.py b/core/api/tools/contracts.py deleted file mode 100644 index 241b580..0000000 --- a/core/api/tools/contracts.py +++ /dev/null @@ -1,53 +0,0 @@ -from core.api.fetch_api_data import fetch_api_data -from core.api.schemas import Contracts, ContractID, ContractAutocomplete -from agents import function_tool - -BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service' - -class ContractsAPI: - - @function_tool - async def contract(self, params: Contracts) -> dict: - """ - Fetch a list of contracts from the Justice API with optional filtering. - - Args: - params (Contracts): Filtering and pagination parameters. - - Returns: - dict: A dictionary containing a list of contracts and related metadata. - """ - url = f"{BASE_URL}/v1/zmluvy" - - return await fetch_api_data(icon="๐Ÿ“ƒ", url=url, params=params.model_dump(exclude_none=True)) - - - @function_tool - async def contract_id(self, params: ContractID) -> dict: - """ - Fetch detailed information about a specific contract by its identifier. - - Args: - params (ContractID): Unique identifier of the contract. - - Returns: - dict: Details of the specified contract. - """ - url = f"{BASE_URL}/v1/zmluvy/{params.id}" - - return await fetch_api_data(icon="๐Ÿ“ƒ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def contract_autocomplete(self, params: ContractAutocomplete) -> dict: - """ - Fetch autocomplete suggestions for contract-related search terms. - - Args: - params (ContractAutocomplete): Parameters for autocomplete query (e.g., partial text). - - Returns: - dict: Suggested values matching the input query. - """ - url = f"{BASE_URL}/v1/zmluvy/autocomplete" - - return await fetch_api_data(icon="๐Ÿ“ƒ", url=url, params=params.model_dump(exclude_none=True)) \ No newline at end of file diff --git a/core/api/tools/coutrs.py b/core/api/tools/coutrs.py deleted file mode 100644 index 5e2b2e9..0000000 --- a/core/api/tools/coutrs.py +++ /dev/null @@ -1,52 +0,0 @@ -from core.api.fetch_api_data import fetch_api_data -from core.api.schemas import Court, CourtID, CourtAutocomplete -from agents import function_tool - -BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service' - -class CourtsAPI: - - @function_tool - async def court(self, params: Court) -> dict: - """ - Fetch a list of courts from the Justice API with optional filtering. - - Args: - params (Court): Filtering and pagination parameters. - - Returns: - dict: A dictionary containing a list of courts and related metadata. - """ - url = f"{BASE_URL}/v1/sud" - - return await fetch_api_data(icon="๐Ÿ›๏ธ๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def court_id(self, params: CourtID) -> dict: - """ - Fetch detailed information about a specific court by its identifier. - - Args: - params (CourtID): Unique identifier of the court. - - Returns: - dict: Details of the specified court. - """ - url = f"{BASE_URL}/v1/sud/{params.id}" - - return await fetch_api_data(icon="๐Ÿ›๏ธ๏ธ", url=url, params=params.model_dump(exclude_none=True), remove_keys=['foto']) - - @function_tool - async def court_autocomplete(self, params: CourtAutocomplete) -> dict: - """ - Fetch autocomplete suggestions for court names. - - Args: - params (CourtAutocomplete): Parameters for autocomplete. - - Returns: - dict: Suggested court names matching the input query. - """ - url = f"{BASE_URL}/v1/sud/autocomplete" - - return await fetch_api_data(icon="๐Ÿ›๏ธ๏ธ", url=url, params=params.model_dump(exclude_none=True)) diff --git a/core/api/tools/decisions.py b/core/api/tools/decisions.py deleted file mode 100644 index 8e063f1..0000000 --- a/core/api/tools/decisions.py +++ /dev/null @@ -1,53 +0,0 @@ -from core.api.fetch_api_data import fetch_api_data -from core.api.schemas import Decision, DecisionID, DecisionAutocomplete -from agents import function_tool - -BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service' - -class DecisionsAPI: - - @function_tool - async def decision(self, params: Decision) -> dict: - """ - Fetch a list of decisions from the Justice API with optional filtering. - - Args: - params (Decision): Filtering and pagination parameters. - - Returns: - dict: A dictionary containing a list of decisions and related metadata. - """ - url = f"{BASE_URL}/v1/rozhodnutie" - - return await fetch_api_data(icon="โš–๏ธ๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - - @function_tool - async def decision_id(self, params: DecisionID) -> dict: - """ - Fetch detailed information about a specific decision by its identifier. - - Args: - params (DecisionID): Unique identifier of the decision. - - Returns: - dict: Details of the specified decision. - """ - url = f"{BASE_URL}/v1/rozhodnutie/{params.id}" - - return await fetch_api_data(icon="โš–๏ธ๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - @function_tool - async def decision_autocomplete(self, params: DecisionAutocomplete) -> dict: - """ - Fetch autocomplete suggestions for decision-related search terms. - - Args: - params (DecisionAutocomplete): Parameters for autocomplete. - - Returns: - dict: Suggested values matching the input query. - """ - url = f"{BASE_URL}/v1/rozhodnutie/autocomplete" - - return await fetch_api_data(icon="โš–๏ธ๏ธ", url=url, params=params.model_dump(exclude_none=True)) \ No newline at end of file diff --git a/core/api/tools/judges.py b/core/api/tools/judges.py deleted file mode 100644 index b775346..0000000 --- a/core/api/tools/judges.py +++ /dev/null @@ -1,54 +0,0 @@ -from core.api.fetch_api_data import fetch_api_data -from core.api.schemas import Judge, JudgeID, JudgeAutocomplete -from agents import function_tool - -BASE_URL = 'https://obcan.justice.sk/pilot/api/ress-isu-service' - -class JudgesAPI: - - @function_tool - async def judge(self, params: Judge) -> dict: - """ - Fetch a list of judges from the Justice API with optional filtering. - - Args: - params (Judge): Filtering and pagination parameters. - - Returns: - dict: A dictionary containing a list of judges and related metadata. - """ - url = f"{BASE_URL}/v1/sudca" - - return await fetch_api_data(icon="๐Ÿง‘โ€โš–๏ธ", url=url, params=params.model_dump(exclude_none=True), remove_keys=['sudcaMapList']) - - - @function_tool - async def judge_id(self, params: JudgeID) -> dict: - """ - Fetch detailed information about a specific judge by their identifier. - - Args: - params (JudgeID): Unique identifier of the judge. - - Returns: - dict: Details of the specified judge. - """ - url = f"{BASE_URL}/v1/sudca/{params.id}" - - return await fetch_api_data(icon="๐Ÿง‘โ€โš–๏ธ", url=url, params=params.model_dump(exclude_none=True)) - - - @function_tool - async def judge_autocomplete(self, params: JudgeAutocomplete) -> dict: - """ - Fetch autocomplete suggestions for judges' names. - - Args: - params (JudgeAutocomplete): Parameters for autocomplete query (e.g., partial name). - - Returns: - dict: Suggested judge names matching the input query. - """ - url = f"{BASE_URL}/v1/sudca/autocomplete" - - return await fetch_api_data(icon="๐Ÿง‘โ€โš–๏ธ", url=url, params=params.model_dump(exclude_none=True)) \ No newline at end of file diff --git a/core/initialize_agent.py b/core/initialize_agent.py deleted file mode 100644 index 233143c..0000000 --- a/core/initialize_agent.py +++ /dev/null @@ -1,58 +0,0 @@ -from agents import Agent -from agents import OpenAIChatCompletionsModel, AsyncOpenAI, ModelSettings -from agents import set_tracing_disabled, enable_verbose_stdout_logging - -from core.system_prompt import SYSTEM_PROMPT -from core.stream_response import stream_response - -from core.api.tools.judges import JudgesAPI -from core.api.tools.coutrs import CourtsAPI -from core.api.tools.contracts import ContractsAPI -from core.api.tools.decisions import DecisionsAPI -from core.api.tools.admin_proceedings import AdminProceedingsAPI -from core.api.tools.civil_proceedings import CivilProceedingsAPI - -set_tracing_disabled(True) -#enable_verbose_stdout_logging() - -class BaseAgent(Agent[None]): pass - -def assistant_agent(prompt: str, session): - - judge_api = JudgesAPI() - court_api = CourtsAPI() - contract_api = ContractsAPI() - decision_api = DecisionsAPI() - admin_proceedings_api = AdminProceedingsAPI() - civil_proceedings_api = CivilProceedingsAPI() - - model = OpenAIChatCompletionsModel( - model="gpt-oss:20b-cloud", - openai_client=AsyncOpenAI(base_url="http://localhost:11434/v1", - api_key="ollama" - ) - ) - - agent = BaseAgent( - name="Assistant", - instructions=SYSTEM_PROMPT, - model=model, - model_settings=ModelSettings( - temperature=0.1, - tool_choice="auto", - parallel_tool_calls=False, - max_tokens=512, - ), - tools=[ - judge_api.judge, judge_api.judge_id, judge_api.judge_autocomplete, - court_api.court, court_api.court_id, court_api.court_autocomplete, - contract_api.contract, contract_api.contract_id, contract_api.contract_autocomplete, - decision_api.decision, decision_api.decision_id, decision_api.decision_autocomplete, - admin_proceedings_api.admin_proceedings, admin_proceedings_api.admin_proceedings_id, admin_proceedings_api.admin_proceedings_autocomplete, - civil_proceedings_api.civil_proceedings, civil_proceedings_api.civil_proceedings_id, civil_proceedings_api.civil_proceedings_autocomplete, - ], - tool_use_behavior="run_llm_again", - reset_tool_choice=True, - ) - - return stream_response(agent, prompt, session) \ No newline at end of file diff --git a/core/stream_response.py b/core/stream_response.py deleted file mode 100644 index 00053da..0000000 --- a/core/stream_response.py +++ /dev/null @@ -1,13 +0,0 @@ -from agents import Agent, Runner, SQLiteSession -from openai.types.responses import ResponseTextDeltaEvent - -async def stream_response(agent: Agent, prompt: str, session: SQLiteSession): - """Stream agent response and update the UI.""" - - try: - result = Runner.run_streamed(agent, input=prompt, session=session) - async for event in result.stream_events(): - if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent): - yield event.data.delta # <-- sends the next piece of response text - except Exception as e: - yield f"โš ๏ธ๐Ÿ–จ๏ธ Error: {e}" diff --git a/core/system_prompt.py b/core/system_prompt.py deleted file mode 100644 index db0f810..0000000 --- a/core/system_prompt.py +++ /dev/null @@ -1,2 +0,0 @@ -SYSTEM_PROMPT = """ -""" \ No newline at end of file diff --git a/main.py b/main.py deleted file mode 100644 index 0229e45..0000000 --- a/main.py +++ /dev/null @@ -1,7 +0,0 @@ -from app.app import create_app - -def main(): - create_app() - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 4e07b8a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -openai-agents -python-dotenv -streamlit -requests -pydantic -httpx \ No newline at end of file diff --git a/test/Examples of questions.pdf b/test/Examples of questions.pdf deleted file mode 100644 index 0920a55..0000000 Binary files a/test/Examples of questions.pdf and /dev/null differ diff --git a/test/latex_problem.png b/test/latex_problem.png deleted file mode 100644 index 607ae42..0000000 Binary files a/test/latex_problem.png and /dev/null differ