Skip to main content

No project description provided

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn

My LLM Utilities

About The Project

個人工具箱,便於生成式AI的開發探索。私人研究,與工作無關,來窺伺動靜的人請自行退去。

2024-02-19

修改專案及套件名稱

Built With

  • Python
  • OpenAI

Getting Started

本節說明如何建置本專案, 以及如何將建置成果供用戶使用.

Prerequisites

開發環境需要先安裝好Python和poetry

  • pyenv

    curl https://pyenv.run | bash
    
  • Python

    pyenv install 3.11
    
  • poetry

    curl -sSL https://install.python-poetry.org | python3 -
    
  • Virtual environment

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    

    或 使用 poetry:

    poetry install
    poetry shell
    

Development

see How to upload your python package to PyPi

Without Poetry

  • 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記錄。 在上傳過程中要求認證的時候, 以"token"做為username, 以該檔案中的token值做為密碼

    twine upload dist/*
    

With Poetry

  • Virtual environment

    poetry shell
    
  • Test

    pytest 
    
  • Build

    poetry build
    
  • Upload

    poetry publish --username=__token__ --password=上述檔案中的token值
    

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

  • 支援 Gemini
  • 支援 Huggingface上的開源模型

See the open issues for a full list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Ken Hu - kenhu@duck.com

Project Link: https://github.com/kenhutaiwan/MyLlmUtils

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

khu_llm_toolkit-0.1.6a0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

khu_llm_toolkit-0.1.6a0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file khu_llm_toolkit-0.1.6a0.tar.gz.

File metadata

  • Download URL: khu_llm_toolkit-0.1.6a0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/6.2.6-76060206-generic

File hashes

Hashes for khu_llm_toolkit-0.1.6a0.tar.gz
Algorithm Hash digest
SHA256 259e8e38e4b14088ffe5ba749b7ee814e934e04010fafb4696474489b8ef6f8c
MD5 fd6c1d965f7bc696b06b36e5ca6a71af
BLAKE2b-256 a7617b4f4b6b8c812fc912dfcc72d8c698144ac03895abd2382e28e5acacc8c2

See more details on using hashes here.

File details

Details for the file khu_llm_toolkit-0.1.6a0-py3-none-any.whl.

File metadata

  • Download URL: khu_llm_toolkit-0.1.6a0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/6.2.6-76060206-generic

File hashes

Hashes for khu_llm_toolkit-0.1.6a0-py3-none-any.whl
Algorithm Hash digest
SHA256 58cc09391bbc38cf6ddec36c49d93e08e1db10ea44810d3131a431cac29df270
MD5 60cff105d54b6e6ebb9c5c8ac36719a7
BLAKE2b-256 d31991e245ffab1fff4adc06a260c83aec0d48a20b575336bb960bb9e5571a21

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page