-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Add API endpoint for managing prompt optimization jobs and related classes #147
Conversation
WalkthroughThe changes introduce a new API endpoint for managing prompt optimization jobs, allowing for the creation, updating, deletion, and logging of these jobs. Several new classes and enums have been added to support the functionality, including an enumeration for optimization algorithms and schemas for job requests and responses. Additionally, multiple methods have been implemented in the API modules to facilitate these operations, enhancing the system's prompt optimization capabilities. Changes
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
src/libs/LangSmith/openapi.yaml (3)
Line range hint
10149-10174
: New prompt optimization endpoint looks good but needs rate limitingThe new
/api/v1/repos/optimize
endpoint is well-defined with proper request/response schemas. However, since prompt optimization can be computationally intensive, consider adding rate limiting headers to prevent abuse.Consider adding the following rate limiting headers:
- X-RateLimit-Limit
- X-RateLimit-Remaining
- X-RateLimit-Reset
Line range hint
21967-22024
: Security scheme definitions look good but could be enhancedThe security schemes are well defined with:
- API key header
- Bearer token auth
- Tenant/Org ID headers
Consider adding:
- Rate limiting headers as discussed above
- API versioning headers
- More detailed security scheme descriptions
16040-16058
: Prompt optimization job request schema needs additional validationThe
OptimizePromptJobRequest
schema has required fields but could use additional validation:Consider adding:
- Max length validation for
prompt_name
- Schema validation for the
config
field- Enum validation for supported algorithms
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (73)
src/libs/LangSmith/Generated/JsonConverters.EPromptOptimizationAlgorithm.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonConverters.EPromptOptimizationAlgorithmNullable.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonConverters.EPromptOptimizationJobLogType.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonConverters.EPromptOptimizationJobLogTypeNullable.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonConverters.EPromptOptimizationJobStatus.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonConverters.EPromptOptimizationJobStatusNullable.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonSerializerContext.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/JsonSerializerContextTypes.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.ILangSmithApi.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.CreateJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.CreateLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.DeleteJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.DeleteLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.GetJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.GetLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.ListJobLogs.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.ListJobs.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.UpdateJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IOptimizationJobsClient.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IReposClient.OptimizePrompt.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.IReposClient.OptimizePromptJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.LangSmithApi.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.AppHubCrudOptimizeOptimizePromptResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.AppHubCrudOptimizeOptimizePromptResponse.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.AppSchemasOptimizePromptResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.AppSchemasOptimizePromptResponse.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DeleteJobApiV1ReposOwnerRepoOptimizationJobsJobIdDeleteResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DeleteJobApiV1ReposOwnerRepoOptimizationJobsJobIdDeleteResponse.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DeleteLogApiV1ReposOwnerRepoOptimizationJobsJobIdLogsLogIdDeleteResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DeleteLogApiV1ReposOwnerRepoOptimizationJobsJobIdLogsLogIdDeleteResponse.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DemoConfig.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DemoConfig.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DemoConfigExample.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DemoConfigExample.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DemoConfigMetaprompt.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.DemoConfigMetaprompt.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.EPromptOptimizationAlgorithm.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.EPromptOptimizationJobLogType.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.EPromptOptimizationJobStatus.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.OptimizePromptJobRequest.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.OptimizePromptJobRequest.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJob.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobCreate.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobCreate.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLog.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLogCreate.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLogCreate.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLogCreateData.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLogCreateData.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLogData.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobLogData.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobUpdate.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobUpdate.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobWithLogs.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationJobWithLogs.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationResult.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptOptimizationResult.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptimConfig.Json.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.Models.PromptimConfig.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.CreateJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.CreateLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.DeleteJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.DeleteLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.GetJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.GetLog.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.ListJobLogs.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.ListJobs.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.UpdateJob.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.OptimizationJobsClient.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.ReposClient.OptimizePrompt.g.cs
is excluded by!**/generated/**
src/libs/LangSmith/Generated/LangSmith.ReposClient.OptimizePromptJob.g.cs
is excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/LangSmith/openapi.yaml
(8 hunks)
🔇 Additional comments (1)
src/libs/LangSmith/openapi.yaml (1)
14018-14039
: Enum values for optimization job status look good
The EPromptOptimizationJobStatus
enum properly covers all necessary states for tracking optimization jobs:
- created
- running
- successful
- failed
app__hub__crud__optimize__OptimizePromptResponse: | ||
title: OptimizePromptResponse | ||
required: | ||
- prompt | ||
- error | ||
type: object | ||
properties: | ||
prompt: | ||
title: Prompt | ||
type: string | ||
error: | ||
title: Error | ||
type: string | ||
nullable: true | ||
description: Response from optimizing a prompt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistency in optimization response schemas
There are two different response schemas for prompt optimization:
app__hub__crud__optimize__OptimizePromptResponse
returns the optimized prompt directlyapp__schemas__OptimizePromptResponse
returns just the job ID
This inconsistency could cause confusion. Consider:
- Consolidating into a single response schema
- Or clearly documenting when each is used
- Adding version numbers if both need to be maintained
Also applies to: 21633-21643
Summary by CodeRabbit
New Features
Bug Fixes