Metadata-Version: 2.4
Name: gzhlaker
Version: 0.0.8
Summary: Gzhlaker's lib
Author-email: "zihang.guo" <15047271937@163.com>
Project-URL: Homepage, https://github.com/guozihang/gzhlaker_pylib
Project-URL: Issues, https://github.com/guozihang/gzhlaker_pylib/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: openai>=1.0
Requires-Dist: google-genai>=1.0
Requires-Dist: oss2>=2.19

# gzhlaker's python lib

Python 工具库：OpenAI / Gemini embedding 封装与阿里云 OSS 常用操作。

## 安装

```bash
pip install gzhlaker
```

## util_openai

OpenAI embedding 工具（依赖 `openai>=1.0`）。

```python
from gzhlaker import init_openai, get_embedding, get_embeddings

client = init_openai(max_retries=2, api_key="sk-...")  # api_key 缺省时读取 OPENAI_API_KEY 环境变量
vec = get_embedding(client, "hello world")
vecs = get_embeddings(client, ["hello", "world"])
```

* init_openai
* get_embedding
* aget_embedding
* get_embeddings
* aget_embeddings

## util_gemini

Gemini embedding 工具（依赖 `google-genai>=1.0`）。

```python
from gzhlaker import init_gemini, get_gemini_embedding, get_gemini_embeddings

client = init_gemini(api_key="...")
vec = get_gemini_embedding(client, "hello world", task_type="retrieval_document")
vecs = get_gemini_embeddings(client, ["hello", "world"])
```

* init_gemini
* get_gemini_embedding
* get_gemini_embeddings

## util_oss

阿里云 OSS 工具（依赖 `oss2>=2.19`）。

```python
from gzhlaker import check_and_upload

check_and_upload(
    source_path="local/dir",
    target_path="oss/dir",
    file_list=["a.txt", ("b.txt", "description of b")],
    ass_key="...",
    ass_secret="...",
    bucket_name="my-bucket",
    endpoint="https://oss-cn-hangzhou.aliyuncs.com",
    region="cn-hangzhou",
)
```

* check_and_upload
* get_file_name
* check_path
* save_pickle
* load_pickle

> ⚠️ 注意：`load_pickle` 只能加载可信来源的 pickle 文件（反序列化会执行任意代码）。
