Skip to content
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

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Dec 3, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new API endpoint for managing prompt optimization jobs, allowing users to create, update, delete, and list job logs.
    • Added support for specifying optimization algorithms with a new enumeration.
    • Enhanced response schemas for better representation of prompt optimization jobs and results.
  • Bug Fixes

    • Updated existing schemas to improve data handling for prompt optimization requests and responses.

Copy link

coderabbitai bot commented Dec 3, 2024

Walkthrough

The 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

File Path Change Summary
src/libs/LangSmith/openapi.yaml Added new endpoint /api/v1/repos/{owner}/{repo}/optimization-jobs for managing prompt optimization jobs.
app/api/v1/ace.py Added method execute_api_v1_ace_execute_post.
app/api/v1/repos.py Added methods for prompt optimization: optimize_prompt_api_v1_repos_optimize_post, optimize_prompt_job_api_v1_repos_optimize_job_post, list_jobs_api_v1_repos__owner___repo__optimization_jobs_get, create_job_api_v1_repos__owner___repo__optimization_jobs_post, get_job_api_v1_repos__owner___repo__optimization_jobs__job_id__get, update_job_api_v1_repos__owner___repo__optimization_jobs__job_id__patch, delete_job_api_v1_repos__owner___repo__optimization_jobs__job_id__delete, list_job_logs_api_v1_repos__owner___repo__optimization_jobs__job_id__logs_get, create_log_api_v1_repos__owner___repo__optimization_jobs__job_id__logs_post, get_log_api_v1_repos__owner___repo__optimization_jobs__job_id__logs__log_id__get, delete_log_api_v1_repos__owner___repo__optimization_jobs__job_id__logs__log_id__delete.
app/schemas.py Added classes: EPromptOptimizationAlgorithm, EPromptOptimizationJobLogType, EPromptOptimizationJobStatus, PromptOptimizationJob, PromptOptimizationJobCreate, PromptOptimizationJobLog, PromptOptimizationJobLogCreate, PromptOptimizationJobUpdate, PromptOptimizationJobWithLogs, PromptOptimizationResult, PromptimConfig, app__hub__crud__optimize__OptimizePromptResponse, app__schemas__OptimizePromptResponse.

Suggested reviewers

  • github-actions

🐰 In a world of prompts and jobs,
A new path opens, no more snobs.
With logs and updates, swift and bright,
Optimization takes its flight!
Hopping through code, we cheer with glee,
For every change, a new decree!
🌟


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot enabled auto-merge December 3, 2024 09:22
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add API endpoint for managing prompt optimization jobs and related classes Dec 3, 2024
Copy link

@coderabbitai coderabbitai bot left a 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 limiting

The 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 enhanced

The security schemes are well defined with:

  • API key header
  • Bearer token auth
  • Tenant/Org ID headers

Consider adding:

  1. Rate limiting headers as discussed above
  2. API versioning headers
  3. More detailed security scheme descriptions

16040-16058: Prompt optimization job request schema needs additional validation

The OptimizePromptJobRequest schema has required fields but could use additional validation:

Consider adding:

  1. Max length validation for prompt_name
  2. Schema validation for the config field
  3. Enum validation for supported algorithms
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 98a0448 and 0db8656.

⛔ 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

Comment on lines +21595 to +21609
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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency in optimization response schemas

There are two different response schemas for prompt optimization:

  1. app__hub__crud__optimize__OptimizePromptResponse returns the optimized prompt directly
  2. app__schemas__OptimizePromptResponse returns just the job ID

This inconsistency could cause confusion. Consider:

  1. Consolidating into a single response schema
  2. Or clearly documenting when each is used
  3. Adding version numbers if both need to be maintained

Also applies to: 21633-21643

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant