예측 출력
예측 출력 (Predicted Outputs)
| 속성 | 상세 |
|---|---|
| 설명 | LLM 출력의 대부분을 미리 알 때 사용하세요. 예를 들어 모델에게 텍스트나 코드를 약간의 변경만으로 재작성하라고 요청하면, 기존 콘텐츠를 예측으로 전달해 Predicted Outputs로 지연 시간을 크게 줄일 수 있어요. |
| 지원 프로바이더 | openai |
| 링크 | OpenAI doc on Predicted Outputs ↗ |
| LiteLLM 버전 | v1.51.4부터 지원 |
Predicted Outputs 사용하기
- LiteLLM Python SDK
- LiteLLM Proxy Server
이 예시에서는 C# 코드 일부를 리팩터링하고 Username 속성을 Email로 바꾸려고 해요:
import litellm
os.environ["OPENAI_API_KEY"] = "your-api-key"
code = """
/// <summary>
/// Represents a user with a first name, last name, and username.
/// </summary>
public class User
{
/// <summary>
/// Gets or sets the user's first name.
/// </summary>
public string FirstName { get; set; }
/// <summary>
/// Gets or sets the user's last name.
/// </summary>
public string LastName { get; set; }
/// <summary>
/// Gets or sets the user's username.
/// </summary>
public string Username { get; set; }
}
"""
completion = litellm.completion(
model="gpt-5.6-luna",
messages=[
{
"role": "user",
"content": "Replace the Username property with an Email property. Respond only with code, and with no markdown formatting.",
},
{"role": "user", "content": code},
],
prediction={"type": "content", "content": code},
)
print(completion)
출처: 문서
본문
Proxy Server 사용
- config.yaml에 모델 정의
model_list:
- model_name: gpt-5.6-luna # OpenAI gpt-5.6-luna
litellm_params:
model: openai/gpt-5.6-luna
api_key: os.environ/OPENAI_API_KEY
- proxy server 실행
litellm --config config.yaml
- OpenAI Python SDK로 테스트
from openai import OpenAI
client = OpenAI(
api_key="LITELLM_PROXY_KEY", # sk-<your-litellm-api-key>
base_url="LITELLM_PROXY_BASE" # http://0.0.0.0:4000
)
completion = client.chat.completions.create(
model="gpt-5.6-luna",
messages=[
{
"role": "user",
"content": "Replace the Username property with an Email property. Respond only with code, and with no markdown formatting.",
},
{"role": "user", "content": code},
],
prediction={"type": "content", "content": code},
)
print(completion)