oasis-llm-proxy-client


Nameoasis-llm-proxy-client JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/haiqv/oasis-llm-proxy-client
SummaryNone
upload_time2025-07-24 03:28:02
maintainerNone
docs_urlNone
authorhaiqv
requires_python<4.0,>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OASIS-SDK

## 1. Concept

OASIS-LLM-PROXY-CLIENT는 OpenAI, Azure OpenAI 등 다양한 LLM Provider의 공식 SDK 및 LangChain을 얇게 wrapping하여, 사내 규칙에 맞는 필드 입력과 프록시 서버를 통한 키 주입을 지원하는 Python 라이브러리입니다. 원본 라이브러리의 모든 기능을 그대로 사용할 수 있도록 설계되어, 기존 SDK와 LangChain의 확장성과 호환성을 최대한 보장합니다.

## 2. Usage

### 2.1 install

```
pip install oasis-sdk
```

### 2.2 example

**0. parameters**

[required]

- user_id: 사용자의 id
- workspace_id: 사용자의 workspace id
- tenant_id: 사용자의 tenant id
- proxy_url: Llm Proxy Server

[optional]

- user_ip: 사용자의 ip (defualt=127.0.0.1)
- plugin_name: 호출한 시스템 명 (ex, chatbot, mcp1, rag-mcp, ..., default=default-plugin)

[auto]

- root_id: 클라이언트 생성시 발급
- req_id: 요청시마다 발급

📍 **주의**

- 1번의 연속적인 수행에서 root_id는 고정되어야 함
- 연계되는 시스템에서는 클라이언트 생성시 초기 발급된 root_id를 주입하여 사용

#### 2.2.1 SDK

**1. openai**

```python
# 동기 클라이언트
client = OasisOpenAI(
    user_id="user_id",
    workspace_id="workspace_id",
    tenant_id="tenant_id",
    proxy_url="llm_proxy_server",
    user_ip="user_ip",
    plugin_name="your_system"
)

# 동기 호출
resp = client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
)

# 동기 스트림
stream = client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
    stream=True,
)

# 비동기 클라이언트
aync_client = OasisAsyncOpenAI(
    user_id="user_id",
    workspace_id="workspace_id",
    tenant_id="tenant_id",
    proxy_url="llm_proxy_server",
    user_ip="user_ip",
    plugin_name="your_system"
)

# 비동기 호출
resp = await aync_client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
)

# 비동기 스트림
stream = await aync_client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
    stream=True,
)
```

**2. azure openai**

```python
# 동기 클라이언트
client = OasisAzureOpenAI(
    user_id="user_id",
    workspace_id="workspace_id",
    tenant_id="tenant_id",
    proxy_url="llm_proxy_server",
    user_ip="user_ip",
    plugin_name="your_system"
)

# 동기 호출
resp = client.chat.completions.create(
    model="deployment",
    messages=[{"role": "user", "content": "안녕?"}],
)

# 동기 스트림
stream = client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
    stream=True,
)

# 비동기 클라이언트
aync_client = OasisAsyncAzureOpenAI(
    user_id="user_id",
    workspace_id="workspace_id",
    tenant_id="tenant_id",
    proxy_url="llm_proxy_server",
    user_ip="user_ip",
    plugin_name="your_system"
)

# 비동기 호출
resp = await aync_client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
)

# 비동기 스트림
stream = await aync_client.chat.completions.create(
    model="model",
    messages=[{"role": "user", "content": "안녕?"}],
    stream=True,
)
```

#### 2.2.2 Langchain

**1. openai**

```python
llm = OasisChatOpenAI(
    user_id="user_id",
    workspace_id="workspace_id",
    tenant_id="tenant_id",
    proxy_url="llm_proxy_server",
    user_ip="user_ip",
    plugin_name="your_system"
)

# 동기 호출
resp = llm.invoke("안녕 Azure LangChain!")

# 비동기 호출
resp = await llm.ainvoke("안녕 Azure LangChain!")

# 동기 스트림
resp = llm.stream("안녕 Azure LangChain!")

# 비동기 스트림
resp = await llm.astream("안녕 Azure LangChain!")
```

**2. azure openai**

```python
llm = OasisAzureChatOpenAI(
    user_id="user_id",
    workspace_id="workspace_id",
    tenant_id="tenant_id",
    proxy_url="llm_proxy_server",
    user_ip="user_ip",
    plugin_name="your_system"
)

# 동기 호출
resp = llm.invoke("안녕 Azure LangChain!")

# 비동기 호출
resp = await llm.ainvoke("안녕 Azure LangChain!")

# 동기 스트림
resp = llm.stream("안녕 Azure LangChain!")

# 비동기 스트림
resp = await llm.astream("안녕 Azure LangChain!")
```

## 3. Dependency

- python 3.11.x
- openai 1.97.0
- langchain-openai 0.3.28

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/haiqv/oasis-llm-proxy-client",
    "name": "oasis-llm-proxy-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "haiqv",
    "author_email": "\uc2e0\uac15\uc2dd / AI\uc194\ub8e8\uc158\ud300 <kangsik.shin@hanwha.com>",
    "download_url": "https://files.pythonhosted.org/packages/df/bb/05203b3f8d17a7e545b37d14b59aa0722cb4f1bb406723ef9b08c94017ac/oasis_llm_proxy_client-0.1.0.tar.gz",
    "platform": null,
    "description": "# OASIS-SDK\n\n## 1. Concept\n\nOASIS-LLM-PROXY-CLIENT\ub294 OpenAI, Azure OpenAI \ub4f1 \ub2e4\uc591\ud55c LLM Provider\uc758 \uacf5\uc2dd SDK \ubc0f LangChain\uc744 \uc587\uac8c wrapping\ud558\uc5ec, \uc0ac\ub0b4 \uaddc\uce59\uc5d0 \ub9de\ub294 \ud544\ub4dc \uc785\ub825\uacfc \ud504\ub85d\uc2dc \uc11c\ubc84\ub97c \ud1b5\ud55c \ud0a4 \uc8fc\uc785\uc744 \uc9c0\uc6d0\ud558\ub294 Python \ub77c\uc774\ube0c\ub7ec\ub9ac\uc785\ub2c8\ub2e4. \uc6d0\ubcf8 \ub77c\uc774\ube0c\ub7ec\ub9ac\uc758 \ubaa8\ub4e0 \uae30\ub2a5\uc744 \uadf8\ub300\ub85c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub3c4\ub85d \uc124\uacc4\ub418\uc5b4, \uae30\uc874 SDK\uc640 LangChain\uc758 \ud655\uc7a5\uc131\uacfc \ud638\ud658\uc131\uc744 \ucd5c\ub300\ud55c \ubcf4\uc7a5\ud569\ub2c8\ub2e4.\n\n## 2. Usage\n\n### 2.1 install\n\n```\npip install oasis-sdk\n```\n\n### 2.2 example\n\n**0. parameters**\n\n[required]\n\n- user_id: \uc0ac\uc6a9\uc790\uc758 id\n- workspace_id: \uc0ac\uc6a9\uc790\uc758 workspace id\n- tenant_id: \uc0ac\uc6a9\uc790\uc758 tenant id\n- proxy_url: Llm Proxy Server\n\n[optional]\n\n- user_ip: \uc0ac\uc6a9\uc790\uc758 ip (defualt=127.0.0.1)\n- plugin_name: \ud638\ucd9c\ud55c \uc2dc\uc2a4\ud15c \uba85 (ex, chatbot, mcp1, rag-mcp, ..., default=default-plugin)\n\n[auto]\n\n- root_id: \ud074\ub77c\uc774\uc5b8\ud2b8 \uc0dd\uc131\uc2dc \ubc1c\uae09\n- req_id: \uc694\uccad\uc2dc\ub9c8\ub2e4 \ubc1c\uae09\n\n\ud83d\udccd **\uc8fc\uc758**\n\n- 1\ubc88\uc758 \uc5f0\uc18d\uc801\uc778 \uc218\ud589\uc5d0\uc11c root_id\ub294 \uace0\uc815\ub418\uc5b4\uc57c \ud568\n- \uc5f0\uacc4\ub418\ub294 \uc2dc\uc2a4\ud15c\uc5d0\uc11c\ub294 \ud074\ub77c\uc774\uc5b8\ud2b8 \uc0dd\uc131\uc2dc \ucd08\uae30 \ubc1c\uae09\ub41c root_id\ub97c \uc8fc\uc785\ud558\uc5ec \uc0ac\uc6a9\n\n#### 2.2.1 SDK\n\n**1. openai**\n\n```python\n# \ub3d9\uae30 \ud074\ub77c\uc774\uc5b8\ud2b8\nclient = OasisOpenAI(\n    user_id=\"user_id\",\n    workspace_id=\"workspace_id\",\n    tenant_id=\"tenant_id\",\n    proxy_url=\"llm_proxy_server\",\n    user_ip=\"user_ip\",\n    plugin_name=\"your_system\"\n)\n\n# \ub3d9\uae30 \ud638\ucd9c\nresp = client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n)\n\n# \ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nstream = client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n    stream=True,\n)\n\n# \ube44\ub3d9\uae30 \ud074\ub77c\uc774\uc5b8\ud2b8\naync_client = OasisAsyncOpenAI(\n    user_id=\"user_id\",\n    workspace_id=\"workspace_id\",\n    tenant_id=\"tenant_id\",\n    proxy_url=\"llm_proxy_server\",\n    user_ip=\"user_ip\",\n    plugin_name=\"your_system\"\n)\n\n# \ube44\ub3d9\uae30 \ud638\ucd9c\nresp = await aync_client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n)\n\n# \ube44\ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nstream = await aync_client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n    stream=True,\n)\n```\n\n**2. azure openai**\n\n```python\n# \ub3d9\uae30 \ud074\ub77c\uc774\uc5b8\ud2b8\nclient = OasisAzureOpenAI(\n    user_id=\"user_id\",\n    workspace_id=\"workspace_id\",\n    tenant_id=\"tenant_id\",\n    proxy_url=\"llm_proxy_server\",\n    user_ip=\"user_ip\",\n    plugin_name=\"your_system\"\n)\n\n# \ub3d9\uae30 \ud638\ucd9c\nresp = client.chat.completions.create(\n    model=\"deployment\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n)\n\n# \ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nstream = client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n    stream=True,\n)\n\n# \ube44\ub3d9\uae30 \ud074\ub77c\uc774\uc5b8\ud2b8\naync_client = OasisAsyncAzureOpenAI(\n    user_id=\"user_id\",\n    workspace_id=\"workspace_id\",\n    tenant_id=\"tenant_id\",\n    proxy_url=\"llm_proxy_server\",\n    user_ip=\"user_ip\",\n    plugin_name=\"your_system\"\n)\n\n# \ube44\ub3d9\uae30 \ud638\ucd9c\nresp = await aync_client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n)\n\n# \ube44\ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nstream = await aync_client.chat.completions.create(\n    model=\"model\",\n    messages=[{\"role\": \"user\", \"content\": \"\uc548\ub155?\"}],\n    stream=True,\n)\n```\n\n#### 2.2.2 Langchain\n\n**1. openai**\n\n```python\nllm = OasisChatOpenAI(\n    user_id=\"user_id\",\n    workspace_id=\"workspace_id\",\n    tenant_id=\"tenant_id\",\n    proxy_url=\"llm_proxy_server\",\n    user_ip=\"user_ip\",\n    plugin_name=\"your_system\"\n)\n\n# \ub3d9\uae30 \ud638\ucd9c\nresp = llm.invoke(\"\uc548\ub155 Azure LangChain!\")\n\n# \ube44\ub3d9\uae30 \ud638\ucd9c\nresp = await llm.ainvoke(\"\uc548\ub155 Azure LangChain!\")\n\n# \ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nresp = llm.stream(\"\uc548\ub155 Azure LangChain!\")\n\n# \ube44\ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nresp = await llm.astream(\"\uc548\ub155 Azure LangChain!\")\n```\n\n**2. azure openai**\n\n```python\nllm = OasisAzureChatOpenAI(\n    user_id=\"user_id\",\n    workspace_id=\"workspace_id\",\n    tenant_id=\"tenant_id\",\n    proxy_url=\"llm_proxy_server\",\n    user_ip=\"user_ip\",\n    plugin_name=\"your_system\"\n)\n\n# \ub3d9\uae30 \ud638\ucd9c\nresp = llm.invoke(\"\uc548\ub155 Azure LangChain!\")\n\n# \ube44\ub3d9\uae30 \ud638\ucd9c\nresp = await llm.ainvoke(\"\uc548\ub155 Azure LangChain!\")\n\n# \ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nresp = llm.stream(\"\uc548\ub155 Azure LangChain!\")\n\n# \ube44\ub3d9\uae30 \uc2a4\ud2b8\ub9bc\nresp = await llm.astream(\"\uc548\ub155 Azure LangChain!\")\n```\n\n## 3. Dependency\n\n- python 3.11.x\n- openai 1.97.0\n- langchain-openai 0.3.28\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/haiqv/oasis-llm-proxy-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dfbb05203b3f8d17a7e545b37d14b59aa0722cb4f1bb406723ef9b08c94017ac",
                "md5": "52306a4686ae5d3d016a1041cea19131",
                "sha256": "c685fc63b5733c879cafa3f77d1a1d8d9b7009e3710263f428578b742870b95a"
            },
            "downloads": -1,
            "filename": "oasis_llm_proxy_client-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "52306a4686ae5d3d016a1041cea19131",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 7046,
            "upload_time": "2025-07-24T03:28:02",
            "upload_time_iso_8601": "2025-07-24T03:28:02.197645Z",
            "url": "https://files.pythonhosted.org/packages/df/bb/05203b3f8d17a7e545b37d14b59aa0722cb4f1bb406723ef9b08c94017ac/oasis_llm_proxy_client-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-24 03:28:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "haiqv",
    "github_project": "oasis-llm-proxy-client",
    "github_not_found": true,
    "lcname": "oasis-llm-proxy-client"
}
        
Elapsed time: 0.69060s