Skip to main content

LLM Factory

PyPI version Python Support License: MIT

통합 LLM 팩토리 라이브러리 - 다양한 LLM 제공자를 통합된 인터페이스로 사용할 수 있게 해주는 Python 라이브러리입니다.

주요 기능

  • 다중 LLM 제공자 지원: OpenAI, Azure OpenAI, Anthropic, Ollama

설치

requirements.txt에 추가:

process-gpt-llm-factory==1.0.1

직접 설치

pip install process-gpt-llm-factory

마이그레이션 가이드

기존 코드에서 직접 LLM을 생성하던 방식을 LLM Factory로 변경하는 방법:

Before (기존 방식)

from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o", streaming=True, temperature=0)

After (LLM Factory 사용)

from llm_factory import create_llm

model = create_llm(temperature=0)

상세 설명

1. 환경변수 설정

.env 파일에 다음 환경변수들을 설정하세요:

# LLM Provider 설정 (설정하지 않는 경우 openai 기본값 사용)
LLM_PROVIDER=openai  # openai, azure, anthropic, ollama 중 선택

# OpenAI 설정
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o

# 아래 설정은 openai 외 사용시에만 필요
# Azure OpenAI 설정
AZURE_API_KEY=your_azure_api_key_here
AZURE_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_DEPLOYMENT=your_deployment_name
AZURE_MODEL=gpt-4o
AZURE_API_VERSION=2024-06-01-preview

# Anthropic 설정
ANTHROPIC_API_KEY=your_anthropic_api_key_here
ANTHROPIC_MODEL=claude-3-sonnet-20240229

# Ollama 설정
OLLAMA_MODEL=llama3
OLLAMA_BASE_URL=http://localhost:11434

2. 기본 사용법

from llm_factory import create_llm, create_embedding

# 환경변수에 설정된 제공자와 모델 사용
llm = create_llm()

# 특정 제공자 지정
llm = create_llm(provider="openai")

# 특정 모델과 옵션 지정
llm = create_llm(
    model="gpt-4o",
    temperature=0.7,
    streaming=True
)

## API 참조

### LLM 생성 함수

```python
from llm_factory import (
    create_llm,
    create_openai_llm,
    create_azure_llm,
    create_anthropic_llm,
    create_ollama_llm
)

# 기본 LLM 생성 
llm = create_llm()

# 특정 제공자 LLM 생성 
openai_llm = create_openai_llm(model="gpt-4o", temperature=0.5)
azure_llm = create_azure_llm(model="gpt-4o")
anthropic_llm = create_anthropic_llm(model="claude-3-sonnet-20240229")
ollama_llm = create_ollama_llm(model="llama3")

Embedding 생성 함수

from llm_factory import (
    create_embedding,
    create_openai_embedding,
    create_azure_embedding
)

# 기본 Embedding 생성 (환경변수 기반)
embedding = create_embedding()

# 특정 제공자 Embedding 생성
openai_embedding = create_openai_embedding(model="text-embedding-3-large")
azure_embedding = create_azure_embedding(model="text-embedding-3-large")

Metadata

Release files for process-gpt-llm-factory 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for process-gpt-llm-factory 1.0.2
File Size Uploaded Provenance
process_gpt_llm_factory-1.0.2.tar.gz 6.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for process-gpt-llm-factory 1.0.2
File Interpreter ABI Platform
process_gpt_llm_factory-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / process_gpt_llm_factory-1.0.2.tar.gz

Download URL process_gpt_llm_factory-1.0.2.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5b6081707525c80ab8edf338afa818fa8e80705904de6e3cc0f7a37a65d40c5f
BLAKE2b-256 checksum
How to use checksums
af57f15ff5a16b772deb6c225dea00f4b4c0171c6b8a9ccef3cee864b72a7921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / process_gpt_llm_factory-1.0.2-py3-none-any.whl

Download URL process_gpt_llm_factory-1.0.2-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
669b478891f4c1928fd5d98597ec11a8bc1032c52901d51a94d4c452a38d3e5a
BLAKE2b-256 checksum
How to use checksums
93bea6a6229c89f4eb57a75a1821351c8b7506506407c203aced71d7a52d8e6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for process-gpt-llm-factory 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page