use Python package approach to project structure

This commit is contained in:
Adam Wilson
2025-04-24 11:27:03 -06:00
parent 8c6f38db31
commit c9c5b8b0a7
7 changed files with 8 additions and 12 deletions

View File

@@ -36,7 +36,8 @@ jobs:
- name: Run REST API server
run: |
python ${{ github.workspace }}/tests/api/server.py &
# python ${{ github.workspace }}/tests/api/server.py &
python -m tests.api.server
- name: Test API call
run: |

0
tests/__init__.py Normal file
View File

0
tests/api/__init__.py Normal file
View File

View File

@@ -1,11 +1,6 @@
import json
import os
import sys
# Add the parent folder (or any relative path)
sys.path.append(os.path.abspath('./../llm'))
from phi3_language_model import Phi3LanguageModel
from tests.llm.phi3_language_model import Phi3LanguageModel
class ApiController:

View File

@@ -1,6 +1,6 @@
import json
from controller import ApiController
from tests.api.controller import ApiController
from wsgiref.simple_server import make_server

0
tests/llm/__init__.py Normal file
View File

View File

@@ -1,16 +1,16 @@
# TODO: business logic for REST API interaction w/ LLM via prompt input
import onnxruntime_genai as og
import argparse
import onnxruntime_genai as og
import os
default_model_path = './cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4'
class Phi3LanguageModel:
def __init__(self, model_path=None):
# configure ONNX runtime
model_path = default_model_path if model_path == None else model_path
base_dir = os.path.dirname(os.path.abspath(__file__))
model_path = os.path.join(base_dir, "cpu_and_mobile", "cpu-int4-rtn-block-32-acc-level-4")
config = og.Config(model_path)
config.clear_providers()
self.model = og.Model(config)