Skip to main content

통합 LLM 팩토리 라이브러리 - 다양한 LLM 제공자를 통합된 인터페이스로 사용

Project description

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.0

직접 설치

pip install process-gpt-llm-factory

빠른 시작

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")

마이그레이션 가이드

기존 코드에서 직접 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)

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

process_gpt_llm_factory-1.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

process_gpt_llm_factory-1.0.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file process_gpt_llm_factory-1.0.1.tar.gz.

File metadata

  • Download URL: process_gpt_llm_factory-1.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for process_gpt_llm_factory-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ae2a5bb4aca2b09b77848da7a69b150af611a42c02c2b67047dc7f81582ab597
MD5 907d5958d6f0401c3828c1dbf8c429ee
BLAKE2b-256 eb31583cfc3f0f1459f520ca7b38ce1534e79d8cc84407d336463ab4fc925cb0

See more details on using hashes here.

File details

Details for the file process_gpt_llm_factory-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for process_gpt_llm_factory-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00cdcf7fa58e10f95e4521ed82af8453e0b7939d6c0f0f9b32e3f11ca847da83
MD5 6d24086a217653a07c5725055890d6fd
BLAKE2b-256 307d8e07956b7ef8e2f6823670c81dfb43577515739373064c38c109d645edcf

See more details on using hashes here.

Supported by

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