Name | khu-llm-toolkit JSON |
Version |
0.1.8
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-06-15 03:28:50 |
maintainer | None |
docs_url | None |
author | Ken Hu |
requires_python | <4.0,>=3.9 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->
<a name="readme-top"></a>
<!--
*** Thanks for checking out the Best-README-Template. If you have a suggestion
*** that would make this better, please fork the repo and create a pull request
*** or simply open an issue with the tag "enhancement".
*** Don't forget to give the project a star!
*** Thanks again! Now go create something AMAZING! :D
-->
<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]
<h3 align="center">My LLM Utilities</h3>
<!-- ABOUT THE PROJECT -->
## About The Project
<p>
個人工具箱,便於生成式AI的開發探索。私人研究,與工作無關,來窺伺動靜的人請自行退去。
</p>
### 2024-02-19
修改專案及套件名稱
### Built With
* [![Python][Python.org]][Python-url]
* [![OpenAI][OpenAI.com]][OpenAI-url]
<!-- GETTING STARTED -->
## Getting Started
本節說明如何建置本專案, 以及如何將建置成果供用戶使用.
### Prerequisites
開發環境需要先安裝好Python和poetry
* pyenv
```shell
curl https://pyenv.run | bash
```
* Python
```sh
pyenv install 3.11
```
* poetry
```shell
curl -sSL https://install.python-poetry.org | python3 -
```
* Virtual environment
```
poetry install
poetry shell
```
### Development
see [How to upload your python package to PyPi](https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56)
#### 使用 Poetry
* Virtual environment
```
poetry shell
```
* Test
```
pytest
```
* Build
```
poetry build
```
* Upload
```
poetry publish --username=__token__ --password=pypi token值
```
#### 手動執行 setuptools
* Virtual environment
```
source .venv/bin/activate
```
* Test
```
pytest
```
* Github Release
建立並發布git tag
```
git tag -a 0.1.1 -m "adjust config file content layout"
git push origin 0.1.1
```
然後到Github倉庫頁面建立一個新的release
複製Assets中Source code(.tar.gz)的URL, 把它貼到setup.py裡的download_url中
* Build
```
python3 setup.py sdist
python3 setup.py clean --all
```
* Upload
PyPi不再允許在上傳過程中用個人帳號密碼做為身份驗證方式, 參考[Hackmd記錄](https://hackmd.io/4zug-RFaS362quf2Qfj2CA#2023-09-21)。
在上傳過程中要求認證的時候, 以"__token__"做為username, 以該檔案中的token值做為密碼
```
twine upload dist/*
```
<!-- USAGE EXAMPLES -->
## Usage
完成建置並推送到PyPi server後, 就可以在其它專案中將它設為相依套件, 並在程式碼中使用.
* 相依套件
Poetry: 在 pyproject.toml 填入
```
khu_llm_toolkit = "^0.1.6"
```
Pip: 在 requirements.txt 填入
```
khu_llm_toolkit >= 0.1.6
```
* 匯入套件
```
from khu_llm_toolkit import ModelDefinition
from khu_llm_toolkit.commons import ProviderType
config_file_path = os.path.join(os.getcwd(), f"instance/model_definition.ini")
model_def = ModelDefinition(ProviderType.AZURE, config_file_path)
llm, embeddings = model_def.get_models(temperature=temperature)
```
* 設定檔範例
```
[DEFAULT]
[openai]
USE_AZURE = False
API_KEY = OPENAI_API_KEY
CHAT_COMPLETIONS_MODEL = gpt-4-0613
EMBEDDINGS_MODEL = text-embedding-ada-002
[azure]
USE_AZURE = True
API_KEY = AZURE_OPENAI_API_KEY
API_BASE = AZURE_OPENAI_API_ENDPOINT_URL
API_VERSION = 2023-05-15
COMPLETIONS_MODEL = gpt-35-turbo
EMBEDDINGS_MODEL = text-embedding-ada-002
```
<!-- ROADMAP -->
## Roadmap
- [x] 支援 Gemini (0.1.7 2024-04-25)
- [x] 一設定檔,多模型 (0.1.7 2024-04-25)
- [x] 排除Gemini Embeddings模型使用錯誤問題 (0.1.8 2024-06-15)
- [ ] 支援 Huggingface上的開源模型
See the [open issues](https://github.com/kenhutaiwan/MyLlmUtils/issues) for a full list of proposed features (and known issues).
<!-- LICENSE -->
## License
Distributed under the MIT License. See `LICENSE.txt` for more information.
<p align="right">(<a href="#readme-top">back to top</a>)</p>
<!-- CONTACT -->
## Contact
Ken Hu - kenhu@duck.com
Project Link: [https://github.com/kenhutaiwan/MyLlmUtils](https://github.com/kenhutaiwan/MyLlmUtils)
<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge
[contributors-url]: https://github.com/kenhutaiwan/MyLlmUtils/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge
[forks-url]: https://github.com/kenhutaiwan/MyLlmUtils/network/members
[stars-shield]: https://img.shields.io/github/stars/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge
[stars-url]: https://github.com/kenhutaiwan/MyLlmUtils/stargazers
[issues-shield]: https://img.shields.io/github/issues/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge
[issues-url]: https://github.com/kenhutaiwan/MyLlmUtils/issues
[license-shield]: https://img.shields.io/github/license/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge
[license-url]: https://github.com/kenhutaiwan/MyLlmUtils/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/linkedin_username
[product-screenshot]: images/screenshot.png
[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
[Next-url]: https://nextjs.org/
[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
[React-url]: https://reactjs.org/
[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D
[Vue-url]: https://vuejs.org/
[Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white
[Angular-url]: https://angular.io/
[Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge&logo=svelte&logoColor=FF3E00
[Svelte-url]: https://svelte.dev/
[Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge&logo=laravel&logoColor=white
[Laravel-url]: https://laravel.com
[Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge&logo=bootstrap&logoColor=white
[Bootstrap-url]: https://getbootstrap.com
[JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white
[JQuery-url]: https://jquery.com
[Python.org]: https://img.shields.io/badge/Python-00FFEE?style=for-the-badge&logo=python&logoColor=white
[Python-url]: https://www.python.org/
[OpenAI.com]: https://img.shields.io/badge/OpenAI-666666?style=for-the-badge&logo=openai&logoColor=white
[OpenAI-url]: https://openai.com/
Raw data
{
"_id": null,
"home_page": null,
"name": "khu-llm-toolkit",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Ken Hu",
"author_email": "ken.hu@hwacom.com",
"download_url": "https://files.pythonhosted.org/packages/94/5c/5bd664e57de18bdbb1778363d771b79b0c24a75615fdaf999535fd466371/khu_llm_toolkit-0.1.8.tar.gz",
"platform": null,
"description": "<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->\n<a name=\"readme-top\"></a>\n<!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag \"enhancement\".\n*** Don't forget to give the project a star!\n*** Thanks again! Now go create something AMAZING! :D\n-->\n\n\n\n<!-- PROJECT SHIELDS -->\n<!--\n*** I'm using markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n-->\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\n\n<h3 align=\"center\">My LLM Utilities</h3>\n\n<!-- ABOUT THE PROJECT -->\n## About The Project\n\n<p>\n\u500b\u4eba\u5de5\u5177\u7bb1\uff0c\u4fbf\u65bc\u751f\u6210\u5f0fAI\u7684\u958b\u767c\u63a2\u7d22\u3002\u79c1\u4eba\u7814\u7a76\uff0c\u8207\u5de5\u4f5c\u7121\u95dc\uff0c\u4f86\u7aba\u4f3a\u52d5\u975c\u7684\u4eba\u8acb\u81ea\u884c\u9000\u53bb\u3002\n</p>\n\n### 2024-02-19\n\n\u4fee\u6539\u5c08\u6848\u53ca\u5957\u4ef6\u540d\u7a31\n\n### Built With\n\n* [![Python][Python.org]][Python-url]\n* [![OpenAI][OpenAI.com]][OpenAI-url]\n\n\n<!-- GETTING STARTED -->\n## Getting Started\n\n\u672c\u7bc0\u8aaa\u660e\u5982\u4f55\u5efa\u7f6e\u672c\u5c08\u6848, \u4ee5\u53ca\u5982\u4f55\u5c07\u5efa\u7f6e\u6210\u679c\u4f9b\u7528\u6236\u4f7f\u7528.\n\n### Prerequisites\n\n\u958b\u767c\u74b0\u5883\u9700\u8981\u5148\u5b89\u88dd\u597dPython\u548cpoetry\n\n* pyenv\n \n ```shell\n curl https://pyenv.run | bash\n ```\n* Python\n\n ```sh\n pyenv install 3.11\n ```\n \n* poetry\n \n ```shell\n curl -sSL https://install.python-poetry.org | python3 -\n ```\n\n* Virtual environment\n\n ```\n poetry install\n poetry shell\n ```\n\n### Development\n\nsee [How to upload your python package to PyPi](https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56)\n\n#### \u4f7f\u7528 Poetry\n\n* Virtual environment\n\n ```\n poetry shell\n ```\n\n* Test\n\n ```\n pytest \n ```\n\n* Build\n\n ```\n poetry build\n ```\n\n* Upload\n\n ```\n poetry publish --username=__token__ --password=pypi token\u503c\n ```\n\n#### \u624b\u52d5\u57f7\u884c setuptools\n\n* Virtual environment\n\n ```\n source .venv/bin/activate\n ```\n\n* Test\n\n ```\n pytest \n ```\n\n* Github Release\n\n \u5efa\u7acb\u4e26\u767c\u5e03git tag\n\n ```\n git tag -a 0.1.1 -m \"adjust config file content layout\"\n git push origin 0.1.1\n ```\n\n \u7136\u5f8c\u5230Github\u5009\u5eab\u9801\u9762\u5efa\u7acb\u4e00\u500b\u65b0\u7684release\n\n \u8907\u88fdAssets\u4e2dSource code(.tar.gz)\u7684URL, \u628a\u5b83\u8cbc\u5230setup.py\u88e1\u7684download_url\u4e2d\n\n* Build\n\n ```\n python3 setup.py sdist\n python3 setup.py clean --all\n ```\n\n* Upload\n\n PyPi\u4e0d\u518d\u5141\u8a31\u5728\u4e0a\u50b3\u904e\u7a0b\u4e2d\u7528\u500b\u4eba\u5e33\u865f\u5bc6\u78bc\u505a\u70ba\u8eab\u4efd\u9a57\u8b49\u65b9\u5f0f, \u53c3\u8003[Hackmd\u8a18\u9304](https://hackmd.io/4zug-RFaS362quf2Qfj2CA#2023-09-21)\u3002\n \u5728\u4e0a\u50b3\u904e\u7a0b\u4e2d\u8981\u6c42\u8a8d\u8b49\u7684\u6642\u5019, \u4ee5\"__token__\"\u505a\u70bausername, \u4ee5\u8a72\u6a94\u6848\u4e2d\u7684token\u503c\u505a\u70ba\u5bc6\u78bc \n\n ```\n twine upload dist/*\n ```\n\n<!-- USAGE EXAMPLES -->\n## Usage\n\n\u5b8c\u6210\u5efa\u7f6e\u4e26\u63a8\u9001\u5230PyPi server\u5f8c, \u5c31\u53ef\u4ee5\u5728\u5176\u5b83\u5c08\u6848\u4e2d\u5c07\u5b83\u8a2d\u70ba\u76f8\u4f9d\u5957\u4ef6, \u4e26\u5728\u7a0b\u5f0f\u78bc\u4e2d\u4f7f\u7528.\n\n* \u76f8\u4f9d\u5957\u4ef6\n\nPoetry: \u5728 pyproject.toml \u586b\u5165 \n\n```\nkhu_llm_toolkit = \"^0.1.6\"\n```\n\nPip: \u5728 requirements.txt \u586b\u5165 \n\n```\nkhu_llm_toolkit >= 0.1.6\n```\n\n* \u532f\u5165\u5957\u4ef6\n\n```\nfrom khu_llm_toolkit import ModelDefinition\nfrom khu_llm_toolkit.commons import ProviderType\n\nconfig_file_path = os.path.join(os.getcwd(), f\"instance/model_definition.ini\")\nmodel_def = ModelDefinition(ProviderType.AZURE, config_file_path)\nllm, embeddings = model_def.get_models(temperature=temperature)\n```\n\n* \u8a2d\u5b9a\u6a94\u7bc4\u4f8b\n\n```\n[DEFAULT]\n\n[openai]\nUSE_AZURE = False\nAPI_KEY = OPENAI_API_KEY\nCHAT_COMPLETIONS_MODEL = gpt-4-0613\nEMBEDDINGS_MODEL = text-embedding-ada-002\n\n[azure]\nUSE_AZURE = True\nAPI_KEY = AZURE_OPENAI_API_KEY\nAPI_BASE = AZURE_OPENAI_API_ENDPOINT_URL\nAPI_VERSION = 2023-05-15\nCOMPLETIONS_MODEL = gpt-35-turbo\nEMBEDDINGS_MODEL = text-embedding-ada-002\n```\n\n<!-- ROADMAP -->\n## Roadmap\n\n- [x] \u652f\u63f4 Gemini (0.1.7 2024-04-25)\n- [x] \u4e00\u8a2d\u5b9a\u6a94,\u591a\u6a21\u578b (0.1.7 2024-04-25)\n - [x] \u6392\u9664Gemini Embeddings\u6a21\u578b\u4f7f\u7528\u932f\u8aa4\u554f\u984c (0.1.8 2024-06-15) \n- [ ] \u652f\u63f4 Huggingface\u4e0a\u7684\u958b\u6e90\u6a21\u578b\n\nSee the [open issues](https://github.com/kenhutaiwan/MyLlmUtils/issues) for a full list of proposed features (and known issues).\n\n<!-- LICENSE -->\n## License\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\n\n\n\n<!-- CONTACT -->\n## Contact\n\nKen Hu - kenhu@duck.com\n\nProject Link: [https://github.com/kenhutaiwan/MyLlmUtils](https://github.com/kenhutaiwan/MyLlmUtils)\n\n\n\n<!-- MARKDOWN LINKS & IMAGES -->\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\n[contributors-shield]: https://img.shields.io/github/contributors/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge\n[contributors-url]: https://github.com/kenhutaiwan/MyLlmUtils/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge\n[forks-url]: https://github.com/kenhutaiwan/MyLlmUtils/network/members\n[stars-shield]: https://img.shields.io/github/stars/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge\n[stars-url]: https://github.com/kenhutaiwan/MyLlmUtils/stargazers\n[issues-shield]: https://img.shields.io/github/issues/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge\n[issues-url]: https://github.com/kenhutaiwan/MyLlmUtils/issues\n[license-shield]: https://img.shields.io/github/license/kenhutaiwan/MyLlmUtils.svg?style=for-the-badge\n[license-url]: https://github.com/kenhutaiwan/MyLlmUtils/blob/master/LICENSE.txt\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555\n[linkedin-url]: https://linkedin.com/in/linkedin_username\n[product-screenshot]: images/screenshot.png\n[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white\n[Next-url]: https://nextjs.org/\n[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB\n[React-url]: https://reactjs.org/\n[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D\n[Vue-url]: https://vuejs.org/\n[Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white\n[Angular-url]: https://angular.io/\n[Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge&logo=svelte&logoColor=FF3E00\n[Svelte-url]: https://svelte.dev/\n[Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge&logo=laravel&logoColor=white\n[Laravel-url]: https://laravel.com\n[Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge&logo=bootstrap&logoColor=white\n[Bootstrap-url]: https://getbootstrap.com\n[JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white\n[JQuery-url]: https://jquery.com \n[Python.org]: https://img.shields.io/badge/Python-00FFEE?style=for-the-badge&logo=python&logoColor=white\n[Python-url]: https://www.python.org/\n[OpenAI.com]: https://img.shields.io/badge/OpenAI-666666?style=for-the-badge&logo=openai&logoColor=white\n[OpenAI-url]: https://openai.com/",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.1.8",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9d44be03b6a58b71af4a6f2dc69b3b03e2045393c1160baa7ad60ed4d47f8301",
"md5": "6b9587d228d671acc337f34e821425c5",
"sha256": "018ac781898761a65527ec56b139bbbd7b03ac04b4a453c6c7f79c1674672442"
},
"downloads": -1,
"filename": "khu_llm_toolkit-0.1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6b9587d228d671acc337f34e821425c5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 8261,
"upload_time": "2024-06-15T03:28:47",
"upload_time_iso_8601": "2024-06-15T03:28:47.950571Z",
"url": "https://files.pythonhosted.org/packages/9d/44/be03b6a58b71af4a6f2dc69b3b03e2045393c1160baa7ad60ed4d47f8301/khu_llm_toolkit-0.1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "945c5bd664e57de18bdbb1778363d771b79b0c24a75615fdaf999535fd466371",
"md5": "df1a3418dfbc61090396de8a06e9772c",
"sha256": "8a9affecedfd5ab161f541b6e132a49483bd5b2261657f62c0ef825eaf492495"
},
"downloads": -1,
"filename": "khu_llm_toolkit-0.1.8.tar.gz",
"has_sig": false,
"md5_digest": "df1a3418dfbc61090396de8a06e9772c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 6326,
"upload_time": "2024-06-15T03:28:50",
"upload_time_iso_8601": "2024-06-15T03:28:50.085150Z",
"url": "https://files.pythonhosted.org/packages/94/5c/5bd664e57de18bdbb1778363d771b79b0c24a75615fdaf999535fd466371/khu_llm_toolkit-0.1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-15 03:28:50",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "khu-llm-toolkit"
}