Skip to content

Commit

Permalink
add entry points for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
j2whiting committed Feb 28, 2024
1 parent 33f55d9 commit 960470d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"gollm:configure_model=tasks.configure_model:main",
"gollm:model_card=tasks.model_card:main",
"gollm:embedding=tasks.embedding:main",
"gollm:compare_models=tasks.compare_models:main",
"gollm:dataset_configure=tasks.dataset_configure:main",
],
},
python_requires=">=3.8",
Expand Down
39 changes: 39 additions & 0 deletions tasks/compare_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import sys
from core.entities import ModelCompareModel
from core.openai.tool_utils import compare_models
from core.taskrunner import TaskRunnerInterface


def cleanup():
pass


def main():
exitCode = 0
try:
taskrunner = TaskRunnerInterface(description="Model Comparison CLI")
taskrunner.on_cancellation(cleanup)

input_dict = taskrunner.read_input_with_timeout()

taskrunner.log("Creating ModelCardModel from input")
input_model = ModelCompareModel(**input_dict)

taskrunner.log("Sending request to OpenAI API")
response = compare_models(model_cards=input_model.model_cards)
taskrunner.log("Received response from OpenAI API")

taskrunner.write_output_with_timeout({"response": response})

except Exception as e:
sys.stderr.write(f"Error: {str(e)}\n")
sys.stderr.flush()
exitCode = 1

taskrunner.log("Shutting down")
taskrunner.shutdown()
sys.exit(exitCode)


if __name__ == "__main__":
main()

0 comments on commit 960470d

Please sign in to comment.