From 2c67596d383f0d7fbf07eb1ba42e57053db9dc7f Mon Sep 17 00:00:00 2001 From: Rene Luria Date: Fri, 1 Nov 2024 15:23:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20myice/myice.py=20->=20A?= =?UTF-8?q?dded=20new=20AI=20functionality=20using=20Infomaniak=20LLM=20AP?= =?UTF-8?q?I=20=F0=9F=9B=A0=EF=B8=8F=20poetry.lock=20->=20Added=20rl-ai-to?= =?UTF-8?q?ols=20package=20dependency=20=F0=9F=9B=A0=EF=B8=8F=20pyproject.?= =?UTF-8?q?toml=20->=20Updated=20dependencies=20and=20added=20rl-ai-tools?= =?UTF-8?q?=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- myice/myice.py | 30 ++++++++++++++++++++++++++++++ poetry.lock | 22 +++++++++++++++++++++- pyproject.toml | 7 +++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/myice/myice.py b/myice/myice.py index 2f12ded..9b04e20 100755 --- a/myice/myice.py +++ b/myice/myice.py @@ -12,6 +12,8 @@ import sys from enum import Enum from pathlib import Path from typing import Annotated +from typing import List, Tuple +from rl_ai_tools import utils # type: ignore import requests import typer @@ -297,5 +299,33 @@ def parse_schedule( print(f"{event_type}: {title}\n") +@app.command("ai") +def check_with_ai( + schedule_file: Annotated[ + Path, typer.Option(help="schedule json file to parse") + ] = Path("schedule.json"), +): + """ + Search through the schedule with natural language using Infomaniak LLM API + """ + if not utils.init(): + sys.exit(1) + with schedule_file.open("r") as f: + schedule_data = json.load(f) + system = ( + "Tu es une IA connaissant bien les données suivantes, qui décrivent les match et entraînements d'équipes de hockey sur glace:\n" + + json.dumps(schedule_data) + ) + history: List[Tuple[str, str]] = [] + while True: + try: + question = input("> ") + except EOFError: + break + answer = utils.llm_inference(question, history, system=system) + print(">", answer) + history.append((question, answer)) + + if __name__ == "__main__": app() diff --git a/poetry.lock b/poetry.lock index b331b8a..5dc8dbf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -890,6 +890,26 @@ pygments = ">=2.13.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] +[[package]] +name = "rl-ai-tools" +version = "1.9.0" +description = "Tools using AI" +optional = false +python-versions = ">=3.11,<4.0" +files = [ + {file = "rl_ai_tools-1.9.0-py3-none-any.whl", hash = "sha256:c986a17e39afe6bd5bc21eb8d259e465dcc52e60a73b81db3931b45599e94fc1"}, + {file = "rl_ai_tools-1.9.0.tar.gz", hash = "sha256:80c43d434a330544e5d201f3a99460996cc31276fb360cb45a0962f743a342bb"}, +] + +[package.dependencies] +requests = ">=2.32.3,<3.0.0" +typer = ">=0.12.5,<0.13.0" + +[package.source] +type = "legacy" +url = "https://pypi.purple.infomaniak.ch" +reference = "infomaniak" + [[package]] name = "shellingham" version = "1.5.4" @@ -1025,4 +1045,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "32eb77391a5bfd29bed30f4a384ccd08ca307923ac47c48eaad6bfee18798081" +content-hash = "c8b74100d5c4f5889db217b5fb249f55248d1955787fd76dbda5ded8b73875b3" diff --git a/pyproject.toml b/pyproject.toml index bc80ad5..0a5f4b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,11 +10,18 @@ readme = "README.md" python = "^3.12" requests = "^2.32.3" typer = "^0.12.5" +rl-ai-tools = {version = "^1.9.0", source = "infomaniak"} [tool.poetry.group.dev.dependencies] ipykernel = "^6.29.5" + +[[tool.poetry.source]] +name = "infomaniak" +url = "https://pypi.purple.infomaniak.ch" +priority = "supplemental" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"