Introduction
Evaluation
- Overview
- Quickstart
- Concept
- How To
- Eval Definition
Dataset
- Overview
- Concept
- Adding Dataset
- Create Dynamic Column
- Add Annotations
- Change Column Type
- Create Static Column
- Create Synthetic Data
- Experimentation
Tracing
- Overview
- Concept
- Instrumentation ( Auto )
- Manual Tracing
Prompt Workbench
Admin & Settings
Improve an Existing Prompt
Using Python SDK
Improve an Existing Prompt
Using Python SDK
from fi.prompt.client import PromptClient
from fi.prompt.types import ModelConfig, PromptTemplate, SystemMessage, UserMessage
def improve_prompt_examples():
"""Examples of improving prompts with different approaches"""
template = PromptTemplate(
name="customer_support_template",
messages=[
SystemMessage(content="You are a customer service representative."),
UserMessage(content="How can I help with your {issue_type} today?")
],
model_configuration=ModelConfig(
model_name="gpt-4",
temperature=0.7,
max_tokens=1000
)
)
prompt_client = PromptClient(template=template)
client = prompt_client.create()
# Example 1: Basic Improvement - Make Language More Professional
client = client.improve("Make the language more formal and professional")
print("\nAfter professional improvement:")
print(f"Latest message: {client.template.messages[-1].content}")
# Example 2: Improve Clarity and Structure
client = client.improve(
"Add clear structure with greeting, issue identification, and next steps"
)
print("\nAfter structural improvement:")
print(f"Latest message: {client.template.messages[-1].content}")
# Example 3: Add Empathy and Personalization
client = client.improve(
"Add empathetic language and personalization while maintaining professionalism"
)
print("\nAfter empathy improvement:")
print(f"Latest message: {client.template.messages[-1].content}")
# Example 4: Optimize for Specific Use Case
client = client.improve(
"Optimize for technical support issues with relevant terminology"
)
print("\nAfter use-case optimization:")
print(f"Latest message: {client.template.messages[-1].content}")
return client
if __name__ == "__main__":
try:
improved_client = improve_prompt_examples()
print("\nFinal improved template:")
for msg in improved_client.template.messages:
print(f"{msg.role}: {msg.content}")
except Exception as e:
print(f"Error improving prompt: {str(e)}")
Was this page helpful?
Previous
OverviewFuture AGI’s Protect module brings real-time safety and policy enforcement directly into your GenAI application flow. Unlike traditional offline checks, Protect enables live monitoring and screening of every model input and output blocking or flagging harmful content before it reaches end users.
Next