프롬프트 관리 자동화
프롬프트 관리 자동화 (Automate Prompt Management)
Confident API를 통해 자동화된 프롬프트 관리 파이프라인을 구축해볼게요. 플랫폼에서 프롬프트를 직접 만들고 업데이트하는 대신 Confident API로 프롬프트 관리를 자동화할 수 있어요. 코드베이스나 CI/CD에서 새 커밋을 푸시하고, 프로그래밍 방식으로 버전으로 승격하며, 선택적으로 모델 설정·아웃풋 타입·툴을 함께 추적할 수 있어요.
출처: 문서
본문
개요
플랫폼에서 프롬프트를 수동으로 만들고 업데이트하는 대신, Confident API로 프롬프트 관리를 자동화할 수 있어요. 이를 통해:
- 코드베이스나 CI/CD 파이프라인에서 새 프롬프트 커밋 푸시
- 커밋을 프로그래밍 방식으로 버전으로 승격
- 선택적으로 모델 설정, 아웃풋 타입, 툴을 프롬프트와 함께 추적하도록 구성
- 프롬프트 관리를 개발 워크플로우에 통합
이 페이지의 대부분은 핵심 유스케이스, 즉 커밋을 통한 프롬프트 변경 추적에 집중해요. 모델 설정, 아웃풋 타입, 기타 구성은 전체 LLM 구성(프롬프트 + 모델)을 단일 추적 단위로 관리하려는 팀을 위한 선택적 부가 기능이에요.
아직이라면 플랫폼의 프롬프트 커밋·버전에 익숙해져서 프롬프트, 커밋, 버전, 라벨 사이의 관계를 이해하세요.
프롬프트 커밋 푸시 (Push Prompt Commits)
프롬프트의 새 커밋을 Confident AI에 푸시해요. 프롬프트 alias가 없으면 자동으로 만들어져요. 모든 푸시는 변경 사항을 추적하는 새 커밋을 만들어요.
Python
메시지 프롬프트의 경우:
from deepeval.prompt import Prompt
from deepeval.prompt.api import PromptMessage
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
prompt.push(
messages=[
PromptMessage(role="system", content="You are a helpful assistant called {name}."),
]
)
push()메서드에branch파라미터를 전달하거나Prompt객체를branch인자로 인스턴스화해 특정 브랜치에 커밋을 푸시할 수도 있어요. 지정하지 않으면 기본값은main이에요.from deepeval.prompt import Prompt from deepeval.prompt.api import PromptMessage prompt = Prompt(alias="YOUR-PROMPT-ALIAS", branch="my-new-branch") prompt.push( messages=[ PromptMessage(role="system", content="You are a helpful assistant called {name}."), ] )
텍스트 프롬프트의 경우:
from deepeval.prompt import Prompt
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
prompt.push(text="You are a helpful assistant called {name}.")
보간 타입도 지정할 수 있어요:
from deepeval.prompt import Prompt
from deepeval.prompt.api import PromptInterpolationType
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
prompt.push(
text="You are a helpful assistant called {{name}}.",
interpolation_type=PromptInterpolationType.MUSTACHE
)
TypeScript
메시지 프롬프트의 경우:
import { Prompt, PromptMessage } from "deepeval";
const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS" });
await prompt.push({
messages: [
new PromptMessage({
role: "system",
content: "You are a helpful assistant called {name}.",
}),
],
});
push()메서드에branch파라미터를 전달하거나Prompt객체를branch인자로 인스턴스화해 특정 브랜치에 커밋을 푸시할 수도 있어요. 지정하지 않으면 기본값은main이에요.import { Prompt, PromptMessage } from "deepeval"; const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS", branch: "my-new-branch", }); await prompt.push({ messages: [ new PromptMessage({ role: "system", content: "You are a helpful assistant called {name}.", }), ], });
텍스트 프롬프트의 경우:
import { Prompt } from "deepeval";
const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS" });
await prompt.push({ text: "You are a helpful assistant called {name}." });
curl
메시지 프롬프트의 경우:
Request (POST /v1/prompts) — API reference
curl -X POST "https://api.confident-ai.com/v1/prompts" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"alias": "Prompt Name",
"messages": [
{
"role": "user",
"content": "What is the weather like in {{city}}?"
}
],
"interpolationType": "FSTRING",
"outputType": "TEXT"
}'
import requests
response = requests.post(
"https://api.confident-ai.com/v1/prompts",
headers={
"CONFIDENT_API_KEY": "<PROJECT-API-KEY>",
},
json={
"alias": "Prompt Name",
"messages": [
{
"role": "user",
"content": "What is the weather like in {{city}}?"
}
],
"interpolationType": "FSTRING",
"outputType": "TEXT"
},
)
print(response.json())
const response = await fetch("https://api.confident-ai.com/v1/prompts", {
method: "POST",
headers: {
"CONFIDENT_API_KEY": "<PROJECT-API-KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"alias": "Prompt Name",
"messages": [
{
"role": "user",
"content": "What is the weather like in {{city}}?"
}
],
"interpolationType": "FSTRING",
"outputType": "TEXT"
}),
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := `{
"alias": "Prompt Name",
"messages": [
{
"role": "user",
"content": "What is the weather like in {{city}}?"
}
],
"interpolationType": "FSTRING",
"outputType": "TEXT"
}`
req, err := http.NewRequest("POST", "https://api.confident-ai.com/v1/prompts", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(out))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
String body = """
{
"alias": "Prompt Name",
"messages": [
{
"role": "user",
"content": "What is the weather like in {{city}}?"
}
],
"interpolationType": "FSTRING",
"outputType": "TEXT"
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.confident-ai.com/v1/prompts"))
.header("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = reqwest::Client::new()
.post("https://api.confident-ai.com/v1/prompts")
.header("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
.json(&json!({
"alias": "Prompt Name",
"messages": [
{
"role": "user",
"content": "What is the weather like in {{city}}?"
}
],
"interpolationType": "FSTRING",
"outputType": "TEXT"
}))
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
요청 본문에
branch파라미터를 전달해 특정 브랜치에 커밋을 푸시할 수도 있어요. 지정하지 않으면 기본값은main이에요.
텍스트 프롬프트의 경우:
Request (POST /v1/prompts) — API reference
curl -X POST "https://api.confident-ai.com/v1/prompts" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"alias": "Prompt Name",
"text": "Hello, {{name}}!",
"interpolationType": "FSTRING",
"outputType": "TEXT"
}'
import requests
response = requests.post(
"https://api.confident-ai.com/v1/prompts",
headers={
"CONFIDENT_API_KEY": "<PROJECT-API-KEY>",
},
json={
"alias": "Prompt Name",
"text": "Hello, {{name}}!",
"interpolationType": "FSTRING",
"outputType": "TEXT"
},
)
print(response.json())
const response = await fetch("https://api.confident-ai.com/v1/prompts", {
method: "POST",
headers: {
"CONFIDENT_API_KEY": "<PROJECT-API-KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"alias": "Prompt Name",
"text": "Hello, {{name}}!",
"interpolationType": "FSTRING",
"outputType": "TEXT"
}),
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := `{
"alias": "Prompt Name",
"text": "Hello, {{name}}!",
"interpolationType": "FSTRING",
"outputType": "TEXT"
}`
req, err := http.NewRequest("POST", "https://api.confident-ai.com/v1/prompts", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(out))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
String body = """
{
"alias": "Prompt Name",
"text": "Hello, {{name}}!",
"interpolationType": "FSTRING",
"outputType": "TEXT"
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.confident-ai.com/v1/prompts"))
.header("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = reqwest::Client::new()
.post("https://api.confident-ai.com/v1/prompts")
.header("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
.json(&json!({
"alias": "Prompt Name",
"text": "Hello, {{name}}!",
"interpolationType": "FSTRING",
"outputType": "TEXT"
}))
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
각 푸시는 자동으로 새 커밋을 만들어요. 커밋을 안정 릴리스로 표시할 준비가 되면 버전으로 승격할 수 있어요. 버전 번호는 Confident AI가 00.00.0X 형식으로 제어해요.
버전 만들기 (Create a Version)
커밋을 안정 릴리스로 표시할 준비가 되면 버전으로 승격할 수 있어요. 버전 번호는 Confident AI가 00.00.0X 형식(예: 00.00.01, 00.00.02)으로 자동 할당해요.
Python
from deepeval.prompt import Prompt
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
# Create a version from the latest commit
prompt.create_version()
# Or create a version from a specific commit
prompt.create_version(hash="COMMIT-HASH")
TypeScript
import { Prompt } from "deepeval";
const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS" });
// Create a version from the latest commit
await prompt.createVersion();
// Or create a version from a specific commit
await prompt.createVersion({ hash: "COMMIT-HASH" });
curl
Request (POST /v1/prompts/{alias}/versions) — API reference
curl -X POST "https://api.confident-ai.com/v1/prompts/{alias}/versions" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"hash": "bab04ce"
}'
import requests
response = requests.post(
"https://api.confident-ai.com/v1/prompts/{alias}/versions",
headers={
"CONFIDENT_API_KEY": "<PROJECT-API-KEY>",
},
json={
"hash": "bab04ce"
},
)
print(response.json())
const response = await fetch("https://api.confident-ai.com/v1/prompts/{alias}/versions", {
method: "POST",
headers: {
"CONFIDENT_API_KEY": "<PROJECT-API-KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"hash": "bab04ce"
}),
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := `{
"hash": "bab04ce"
}`
req, err := http.NewRequest("POST", "https://api.confident-ai.com/v1/prompts/{alias}/versions", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(out))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
String body = """
{
"hash": "bab04ce"
}""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.confident-ai.com/v1/prompts/{alias}/versions"))
.header("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let response = reqwest::Client::new()
.post("https://api.confident-ai.com/v1/prompts/{alias}/versions")
.header("CONFIDENT_API_KEY", "<PROJECT-API-KEY>")
.json(&json!({
"hash": "bab04ce"
}))
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}
새 버전은 가장 최근 버전화된 커밋 이후에 만들어진 커밋에만 만들 수 있어요. 기존 버전 이전에 만들어진 커밋은 버전으로 승격할 수 없어요.
커밋이 버전으로 승격되면, 그 버전에 라벨(staging이나 production 같은)을 지정할 수 있어요. 라벨은 커밋이 아닌 버전에만 존재할 수 있어요.
모델 구성 추가 (Adding Model Configs)
모델 설정, 아웃풋 타입, 툴은 완전히 선택 사항이에요. 이것들 없이도 프롬프트를 추적하고 사용할 수 있어요 — 프롬프트를 가져와 코드에서 고른 모델과 함께 쓰면 되죠. 이 옵션들은 모델 구성을 프롬프트와 함께 배치(co-locate)하려는 팀을 위한 거예요.
프롬프트와 함께 모델 구성을 관리하고 싶다면 — 각 커밋에서 프롬프트 + 모델을 함께 추적하려면 — 푸시할 때 model_settings와 output_type을 포함할 수 있어요.
다음과 같은 경우 유용해요:
- 특정 프롬프트가 항상 특정 모델과 파라미터로 실행되도록 보장하고 싶을 때
- 서로 다른 프롬프트 + 모델 조합을 함께 A/B 테스트할 때
- 프롬프트와 모델 구성을 한 곳에서 중앙화하고 싶을 때
Python
from deepeval.prompt import Prompt
from deepeval.prompt.api import (
PromptMessage,
ModelSettings,
ModelProvider,
OutputType,
ReasoningEffort,
Verbosity,
)
from pydantic import BaseModel
class ResponseSchema(BaseModel):
answer: str
confidence: float
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
# Use with push() to create a new commit
prompt.push(
messages=[
PromptMessage(role="system", content="You are a helpful assistant."),
],
model_settings=ModelSettings(
provider=ModelProvider.OPEN_AI,
name="gpt-4o",
temperature=0.7,
max_tokens=1000,
top_p=0.9,
frequency_penalty=0.1,
presence_penalty=0.1,
stop_sequence=["END"],
reasoning_effort=ReasoningEffort.MINIMAL,
verbosity=Verbosity.LOW,
),
output_type=OutputType.SCHEMA,
output_schema=ResponseSchema,
)
TypeScript
import { Prompt, PromptMessage, OutputType } from "deepeval";
const responseSchema = {
name: "ResponseSchema",
fields: {
answer: "string",
confidence: "float",
},
};
const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS" });
await prompt.push({
version: "00.00.01",
messages: [
new PromptMessage({
role: "system",
content: "You are a helpful assistant.",
}),
],
modelSettings: {
provider: "OPEN_AI",
name: "gpt-4o",
temperature: 0.7,
maxTokens: 1000,
topP: 0.9,
frequencyPenalty: 0.1,
presencePenalty: 0.1,
stopSequence: ["END"],
reasoningEffort: "MINIMAL",
verbosity: "LOW",
},
outputType: OutputType.SCHEMA,
outputSchema: responseSchema,
});
curl
요청 샘플 불가: PUT /v1/prompts/{alias}/versions/{version}은 API 스펙에 없어요.
참고 (Reference)
모델 설정 (Model settings)
모델 설정에는 provider, 모델 이름, 모델 파라미터가 포함돼요:
| 필드 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| provider | ModelProvider |
OPEN_AI |
모델 프로바이더 (아래 지원 프로바이더 참고) |
| name | str |
None |
모델 이름 (예: "gpt-4o", "claude-3-opus") |
파라미터 (Parameters)
설정할 수 있는 모든 파라미터는 다음과 같아요:
| 필드 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| temperature | float |
0 |
무작위성 제어 (0-2) |
| max_tokens | int |
None |
응답의 최대 토큰 수 |
| top_p | float |
1 |
핵심 샘플링(nucleus sampling) 파라미터 |
| frequency_penalty | float |
0 |
반복 토큰 페널티 (-2 to 2) |
| presence_penalty | float |
0 |
존재 기반 토큰 페널티 (-2 to 2) |
| stop_sequence | List[str] |
[] |
생성을 멈추는 시퀀스 |
| reasoning_effort | ReasoningEffort |
MEDIUM |
추론 노력 수준 (MINIMAL, LOW, MEDIUM, HIGH) |
| verbosity | Verbosity |
MEDIUM |
아웃풋 장황도 (LOW, MEDIUM, HIGH) |
선택한 모델 프로바이더와 모델 이름에 유효한 파라미터만 포함하세요. 예를 들어
reasoning_effort는 특정 OpenAI 모델에만 적용될 수 있고, 다른 파라미터는 모든 프로바이더가 지원하지 않을 수 있어요. Confident AI는 어떤 파라미터 조합이 허용되는지 철저히 검증하지 않아요 — 잘못된 구성은 코드에서 프롬프트를 사용할 때 런타임 오류가 발생할 수 있어요.
프로바이더 (Providers)
사용 가능한 모델 프로바이더 목록은 다음과 같아요:
| Provider | 설명 |
|---|---|
OPEN_AI |
OpenAI (GPT-4, GPT-4o 등) |
ANTHROPIC |
Anthropic (Claude 모델) |
GEMINI |
Google Gemini |
VERTEX_AI |
Google Vertex AI |
BEDROCK |
Amazon Bedrock |
AZURE |
Azure OpenAI |
MISTRAL |
Mistral AI |
DEEPSEEK |
DeepSeek |
X_AI |
xAI (Grok) |
MOONSHOT_AI |
Moonshot AI |
PERPLEXITY |
Perplexity |
PORTKEY |
Portkey (게이트웨이) |
LITE_LLM |
LiteLLM (게이트웨이) |
아웃풋 타입 (Output types)
프롬프트를 푸시할 때 아웃풋 타입을 선택적으로 설정할 수 있어요. 이는 LLM 응답이 따라야 할 형식을 제어해요:
| 타입 | 설명 |
|---|---|
TEXT |
일반 텍스트 아웃풋 (기본값) |
JSON |
JSON 형식 아웃풋 |
SCHEMA |
정의된 스키마에 대해 검증된 구조적 아웃풋 |
Python
prompt.push(
text="You are a helpful assistant.",
output_type=OutputType.JSON,
)
TypeScript
await prompt.push({
text: "You are a helpful assistant.",
outputType: OutputType.JSON,
});
아웃풋 스키마 (Output schema)
output_type이 SCHEMA로 설정되면, LLM 응답이 따라야 할 구조적 스키마를 정의할 수 있어요. LLM에서 타입이 지정되고 검증된 응답이 필요할 때 유용해요.
Python
from deepeval.prompt import Prompt
from deepeval.prompt.api import PromptMessage, OutputType
from pydantic import BaseModel
from typing import List
class Source(BaseModel):
url: str
title: str
class ResponseSchema(BaseModel):
answer: str
confidence: float
tags: List[str]
sources: List[Source]
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
prompt.push(
messages=[
PromptMessage(role="system", content="You are a helpful assistant."),
],
output_type=OutputType.SCHEMA,
output_schema=ResponseSchema,
)
output_schema 파라미터는 어떤 Pydantic BaseModel 클래스든 받아들여요. 지원되는 필드 타입에는 프리미티브(str, int, float, bool), 중첩 BaseModel 클래스, 그리고 지원되는 타입의 배열을 위한 List[...]가 포함돼요.
TypeScript
import { Prompt, PromptMessage, OutputType } from "deepeval";
const responseSchema = {
name: "ResponseSchema",
fields: {
answer: "string",
confidence: "float",
tags: ["string"],
sources: [{ url: "string", title: "string" }],
},
};
const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS" });
await prompt.push({
messages: [
new PromptMessage({
role: "system",
content: "You are a helpful assistant.",
}),
],
outputType: OutputType.SCHEMA,
outputSchema: responseSchema,
});
outputSchema 파라미터는 name과 fields 맵을 가진 SchemaDefinition 객체를 받아들여요. 필드 값은:
- 프리미티브용 문자열:
"string","integer","float","boolean" - 중첩 타입용 객체:
{ url: "string", title: "string" } - 목록용 단일 요소 배열:
["string"]또는[{ url: "string" }]
스키마로 프롬프트를 푸시했다면, 가져와 LLM 프로바이더와 함께 사용하는 방법을 배워 스키마에 대해 검증된 구조적 응답을 얻으세요.
보간 타입 (Interpolation types)
프롬프트에서 변수가 어떻게 보간되는지 지정해요:
| Type | Syntax | Example |
|---|---|---|
FSTRING |
{variable} |
Hello, {name}! |
MUSTACHE |
{{variable}} |
Hello, {{name}}! |
MUSTACHE_WITH_SPACE |
{{ variable }} |
Hello, {{ name }}! |
DOLLAR_BRACKETS |
${variable} |
Hello, ${name}! |
JINJA |
{% ... %} |
{% if admin %}Hello!{% endif %} |
툴은 어떻게 하나요? (What about Tools?)
프롬프트와 함께 툴을 푸시해 툴을 만들고 업데이트할 수 있어요. Confident AI에서 툴은 이름으로 식별돼요 — 새 이름의 툴을 전달하면 툴이 만들어지고, 기존 이름의 툴을 전달하면 플랫폼의 툴이 업데이트돼요. 각 푸시는 툴 구성을 추적하는 새 커밋을 만들어요. 툴을 만들고/업데이트하는 방법은 다음과 같아요:
Python
from deepeval.prompt import Prompt, Tool
from deepeval.prompt.api import ToolMode
from pydantic import BaseModel
class ToolInputSchema(BaseModel):
result: str
confidence: float
prompt = Prompt(alias="YOUR-PROMPT-ALIAS")
tool = Tool(
name="SearchTool",
description="Search functionality",
mode=ToolMode.STRICT,
structured_schema=ToolInputSchema,
)
# Use with push() to create a new commit with the tool
prompt.push(
text="This a prompt for a tool using agent",
tools=[tool]
)
tool_2 = Tool(
name="SearchTool",
description="New search functionality",
mode=ToolMode.STRICT,
structured_schema=ToolInputSchema,
)
# Create a new commit with the new updated tool using 'push'
prompt.push(
text="This a prompt for a tool using agent",
tools=[tool_2]
)
TypeScript
import { Prompt, Tool, ToolMode } from "deepeval";
const responseSchema = {
name: "ResponseSchema",
fields: {
answer: "string",
confidence: "float",
},
};
const prompt = new Prompt({ alias: "YOUR-PROMPT-ALIAS" });
const tool = new Tool({
name = "SearchTool",
description = "Search functionality",
mode = ToolMode.STRICT,
structuredSchema = responseSchema,
});
await prompt.push({
version: "00.00.01",
messages: [
new PromptMessage({
role: "system",
content: "You are a helpful assistant.",
}),
],
tools = [tool],
});
const tool2 = new Tool({
name = "SearchTool",
description = "New search functionality",
mode = ToolMode.STRICT,
structuredSchema = responseSchema,
});
// Create a new commit with the new updated tool using 'push'
await prompt.push({
messages: [
new PromptMessage({
role: "system",
content: "You are a helpful assistant.",
}),
],
tools = [tool2],
});
curl
요청 샘플 불가: PUT /v1/prompts/{alias}/versions/{version}은 API 스펙에 없어요.
CI/CD에서의 프롬프트 (Prompts in CI/CD)
프롬프트 추적을 CI/CD 파이프라인의 일부로 자동화해요. 흔한 패턴은 프롬프트 파일이 변경될 때마다 프롬프트 커밋을 푸시하는 것이에요:
name: Push Prompt Commits
on:
push:
paths:
- "prompts/**"
jobs:
push-prompts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install deepeval
- name: Push prompts
env:
CONFIDENT_API_KEY: ${{ secrets.CONFIDENT_API_KEY }}
run: python scripts/push_prompts.py
push_prompts.py 스크립트가 프롬프트 파일을 읽고 푸시할 수 있어요:
from deepeval.prompt import Prompt
# Read your prompt content from file or config
with open("prompts/assistant.txt") as f:
prompt_text = f.read()
prompt = Prompt(alias="assistant-prompt")
prompt.push(text=prompt_text)
print("Prompt commit pushed successfully!")
자동화된 프롬프트 푸시를 프롬프트 라벨링과 결합해 어떤 버전이 다른 환경(예: staging, production)에 배포될지 제어하세요. 라벨은 버전에만 지정할 수 있다는 점을 기억하세요 — 라벨을 붙이기 전에 커밋을 버전으로 승격해야 해요.
다음 단계
이제 프롬프트를 프로그래밍 방식으로 푸시할 수 있으니, 앱에서 사용하기 위해 가져오는 방법을 배워볼게요.
프롬프트 가져오기 (Pull Prompts)
프롬프트 버전을 코드로 가져와 LLM 앱에서 사용해요.