Move AI-specific functionality (especially prompts) to dedicated services rather than scattering them throughout the codebase. This improves maintainability and follows team conventions.
Move AI-specific functionality (especially prompts) to dedicated services rather than scattering them throughout the codebase. This improves maintainability and follows team conventions.
Specifically:
Example - Instead of:
def make_input_prompt(feedbacks):
feedbacks_string = "\n".join(f"- {msg}" for msg in feedbacks)
return f"""Task:
Instructions: You are an AI assistant that analyzes customer feedback.
Create a summary based on the user feedbacks...
"""
SUMMARY_REGEX = re.compile(r"Summary:\s*(.*)", re.DOTALL)
Prefer:
# In AI service module
def get_feedback_summary(feedbacks):
# Call centralized AI service with structured response format
response = ai_service.complete_prompt(
usecase="feedback_summary",
inputs={"feedbacks": feedbacks},
output_schema={"summary": str}
)
return response.summary
Enter the URL of a public GitHub repository