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

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.2.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.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for process_gpt_llm_factory-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5b6081707525c80ab8edf338afa818fa8e80705904de6e3cc0f7a37a65d40c5f
MD5 58ad9ba3b3209eacd58652c135bd7fb3
BLAKE2b-256 af57f15ff5a16b772deb6c225dea00f4b4c0171c6b8a9ccef3cee864b72a7921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for process_gpt_llm_factory-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 669b478891f4c1928fd5d98597ec11a8bc1032c52901d51a94d4c452a38d3e5a
MD5 f93c310641c3d49b4feb32d3812234ec
BLAKE2b-256 93bea6a6229c89f4eb57a75a1821351c8b7506506407c203aced71d7a52d8e6d

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