{"id":19818723,"url":"https://github.com/sloppycoder/pybot","last_synced_at":"2025-06-13T06:31:59.097Z","repository":{"id":202887308,"uuid":"708336627","full_name":"sloppycoder/pybot","owner":"sloppycoder","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-18T15:46:08.000Z","size":613,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-02-28T20:01:52.946Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sloppycoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-22T08:57:19.000Z","updated_at":"2024-03-18T12:29:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7d34f7f-9da5-4c96-8b9e-3325f396faff","html_url":"https://github.com/sloppycoder/pybot","commit_stats":null,"previous_names":["sloppycoder/pybot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sloppycoder/pybot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fpybot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fpybot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fpybot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fpybot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sloppycoder","download_url":"https://codeload.github.com/sloppycoder/pybot/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sloppycoder%2Fpybot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259594272,"owners_count":22881632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T10:16:41.091Z","updated_at":"2025-06-13T06:31:59.055Z","avatar_url":"https://github.com/sloppycoder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Test project to use LLM APIs for various tasks\n\nThis project contains prototype code for using OpenAI and Google LLM for various tasks.\n\n1. Use OpenAI for chat completion\n2. Use OpenAI chat completion for code generation\n3. Use OpenAI chat completion to extract features from simple text strings and use the features to train XGBoost classification model\n\n## Setup\n\nThe easiest way to get started is probably use [Jetpack.io devbox](https://www.jetpack.io/devbox). Install devbox first, then\n\n```shell\ndevbox shell\n\n# you should ready to go\n\n```\n\nThe more traditional way is to install python 3.11 and [poetry](https://python-poetry.org/), then\n\n```shell\n\n# create virtualenv\npoetry shell\n# install dependencies\npoetry install\n\n# create a file .env with following entry\nOPENAI_API_KEY=sk-xxxxx\n\n```\n\n## 1. Use OpenAI for chat completion\n\n```shell\npytest -s -k test_openai_completion\n\n```\n\n## 2. Use OpenAI chat completion for code generation\n\n```shell\npytest -s -k test_openai_codegen\n\n```\n\n## 3. Use OpenAI chat completion to extract features from simple text strings\n\nThese tests requires some propierty data files that are not in the project repository.\n\n```shell\n# get the input file test1.xlsx\nmkdir data\ncp \u003csource_file\u003e data/test1.xlsx\n\n# run feature extract to call OpenAI API to extract features\n# OpenAI API to extract features from a given part description.\n# at the moment (Nov 2023), gpt-3.5-turbo-1106 seems to have simliar output to gpt-4\n# and runs much faster (and cheaper too).\n#\n# this test case will create file data/test1.csv which will be used in the next step\n# setting DEBUG=1 will display result payload from openai APIs\n#\n# the features extract from openai API will be saved in cache directory\n# so re-running this test will not trigger API calls unless the cache is deleted\n#\n\npytest --log-cli-level=DEBUG -s -k test_extract_features\n\n\n# read data/test1.csv from the previous test and feed into XGBoost for model training\n# the code is a VERY ROUGH PROTOTYPE and should be further tuned before serious use\n# currently the accuray is 75% using the full dataset of 5300 records\n#\n# this step will save the model and encoders\n#  data/feature1_model.joblib\n#  data/feature1_combined_features.joblib\n#  data/feature1_encoder.joblib\n\npytest -s -k test_train_model_with_feature\n\n# load model from disk, lo and run one prediction\npytest -s --fromfile=tests/parts.txt -k test_batch_predict\n\n# read all rows from data/test1.csv and run prediction using the trained model\n# the result will be saved to data/compare1.csv.\n# currently the hit ratio is 86%\n# need new data to verify\npytest -s -k test_predict_all\n\n\n```\n\n## TODOs\n\n1. re-run feature extract for all 5400 items (will take some time to run) (done)\n2. improve feature extraction to more accurately extract relevant features. (added memo column to use in feature extraction, got marginal improvement only)\n3. tune the model training logic\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsloppycoder%2Fpybot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsloppycoder%2Fpybot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsloppycoder%2Fpybot/lists"}