이 문서는 영어 원문을 자동 번역한 것으로, 내용이 원문과 다를 수 있습니다.영어 원문 보기
지정한 입력 파일로 Workflow를 실행합니다.
from openai import OpenAI
from time import sleep
import json
client = OpenAI(
api_key="UPSTAGE_API_KEY",
base_url="https://api.upstage.ai/v2"
)
# Supports multiple files
input_files = [
{
"type": "input_file",
"file_id": "file-abc123"
}
]
input = [
{
"role": "user",
"content": [
*input_files
]
}
]
# Create a job
resp = client.responses.create(
model="agt_BxcRatEWzVYH2yRNtyWynn",
include=["last"],
input=input,
background=True,
)
# Poll until the job is no longer running or cancelling
while resp.status in {"in_progress", "cancelling"}:
sleep(2)
resp = client.responses.retrieve(
resp.id,
include=["last"]
)
# When completed, read the final output text
if resp.status == "completed":
print(json.loads(resp.output_text))
{
"id": "job_7yMqwGy3rfh6Pwo7MdseMo",
"object": "response",
"created_at": 1767613535,
"status": "completed",
"background": true,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"model": "agt_BxcRatEWzVYH2yRNtyWynn",
"output": [
{
"id": "fb543069-1a45-4fde-94de-2383995d7339",
"type": "message",
"status": "completed",
"role": "assistant",
"model": "step_2_extract",
"content": [
{
"type": "output_text",
"text": "{\"key\": \"value\", \"group_key\": [{\"properties\": \"properties_value\"}]}",
"annotations": [],
"additional_values": "{...}"
}
]
}
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0
}
}