Skip to content

WIP: openai image generation#493

Closed
Bran18 wants to merge 9 commits intodevelopfrom
feat-openai-image-generation
Closed

WIP: openai image generation#493
Bran18 wants to merge 9 commits intodevelopfrom
feat-openai-image-generation

Conversation

@Bran18
Copy link
Contributor

@Bran18 Bran18 commented May 22, 2025

Summary by Sourcery

Enable experimental image generation by integrating OpenAI's images API with chat UI toggles and state management

New Features:

  • Support generating images via OpenAI's DALL-E models

Enhancements:

  • Add image generation toggle and DALL-E model selection in chat UI components
  • Introduce ImageGenerationProvider and useImageGeneration hook for managing image mode state
  • Handle image generation in server response stream by calling OpenAI's images.generate endpoint
  • Extend JSONResponseStream type to include isImageGeneration flag
  • Update model icon mapping to recognize DALL-E models

Summary by CodeRabbit

  • New Features

    • Introduced image generation capabilities, allowing users to generate images using supported models.
    • Added an "Image Generation" toggle in the chat panel for easy activation of this feature.
  • Enhancements

    • Models related to image generation now display appropriate icons.
    • Expanded model support with new image generation models.
    • Improved error handling and notifications for failed chat responses.
  • User Interface

    • Improved provider structure to support image generation context across the app.
  • Chores

    • Updated dependencies for enhanced compatibility.

@vercel
Copy link

vercel bot commented May 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
masterbots ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 9:39pm

@sourcery-ai
Copy link

sourcery-ai bot commented May 22, 2025

Reviewer's Guide

This PR implements an image‐generation feature end-to-end by extending the server AI action to branch on an image flag, introducing a React context/hook for toggling image mode, and updating the chat UI to surface an image‐generation toggle and group DALL∙E models appropriately.

Sequence Diagram for Image Generation Request

sequenceDiagram
    actor User
    participant ChatUI as "Chat UI"
    participant ServerAction as "createResponseStream (Server)"
    participant OpenAI_Images_API as "OpenAI Images API"

    User->>ChatUI: Toggles Image Generation mode via FeatureToggle
    User->>ChatUI: Selects DALL-E model (e.g., from ChatCombobox)
    User->>ChatUI: Enters prompt and submits
    ChatUI->>ServerAction: Request (model, prompt, messages, isImageGeneration: true)
    ServerAction->>ServerAction: Check isImageGeneration flag and clientType
    alt isImageGeneration is true AND clientType is 'OpenAI'
        ServerAction->>OpenAI_Images_API: openai.images.generate({ model, prompt, size, quality, style })
        OpenAI_Images_API-->>ServerAction: Image data (response.data[0].b64_json)
        ServerAction-->>ChatUI: JSON Response ({ type: 'image', data })
    else Not image generation or different clientType
        ServerAction->>ServerAction: Process as text generation (existing flow)
        ServerAction-->>ChatUI: Text stream or JSON response (existing flow)
    end
    ChatUI->>User: Displays generated image or text response
Loading

Class Diagram for UI Component Changes for Image Generation

classDiagram
    class useImageGeneration {
        <<Hook>>
        +isImageGenerationEnabled: boolean
        +toggleImageGeneration(): void
    }

    class ChatCombobox {
        <<React Component>>
        -models: any[]
        -IMAGE_MODELS: any[]
        -isImageGenerationEnabled: boolean
        +groupModels(modelsToGroup: any[]): any
    }
    ChatCombobox ..> useImageGeneration : uses

    class ChatPanel {
        <<React Component>>
        -isImageGenerationEnabled: boolean
        +toggleImageGeneration(): void
        +FeatureToggle (ImageIcon)
    }
    ChatPanel ..> useImageGeneration : uses
Loading

File-Level Changes

Change Details Files
Integrate image generation in the AI response stream
  • Import experimental image generator and default OpenAI client
  • Extend request type to include isImageGeneration flag
  • Branch on image generation: call openai.images.generate, return base64 JSON payload
apps/masterbots.ai/app/actions/ai-main-call.ts
apps/masterbots.ai/types/types.ts
Provide React context/hook for image generation state
  • Create ImageGenerationProvider with toggle state
  • Expose useImageGeneration hook for children to consume
apps/masterbots.ai/lib/hooks/use-image.tsx
apps/masterbots.ai/components/layout/providers.tsx
Expose image-generation controls and model grouping in UI
  • Add image toggle in ChatPanel with icon and hook
  • Use useImageGeneration in ChatCombobox, group DALL·E models when enabled
  • Augment model icon logic to recognize DALL·E prefixes
apps/masterbots.ai/components/routes/chat/chat-panel.tsx
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx
apps/masterbots.ai/lib/models.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 22, 2025

"""

Walkthrough

This update introduces image generation capabilities to the chat application. It adds a context and toggle for enabling image generation in the UI, updates request and response handling to support image generation via OpenAI, and extends relevant types, models, and helpers. The provider hierarchy and dependencies are also adjusted accordingly.

Changes

File(s) Change Summary
.../app/actions/ai-main-call.ts Adds support for image generation in createResponseStream, handling a new flag and returning an event stream with base64-encoded image data when requested.
.../components/layout/providers.tsx Wraps MBChatProvider with a new ImageGenerationProvider to supply image generation context throughout the app.
.../components/routes/chat/chat-panel.tsx Adds an "Image Generation" toggle to the chat panel UI, integrated with the new context and using a dedicated icon.
.../lib/hooks/use-image.tsx Introduces ImageGenerationProvider and useImageGeneration hook for managing and accessing the image generation enabled state.
.../lib/models.tsx Updates getModelIcon to return the OpenAI icon for models starting with "dall-e".
.../types/types.ts Updates AiClientType and JSONResponseStream types to support image generation, removing some unused properties and adding the relevant flag.
.../app/api/chat/models/models.ts Adds three new enum members for OpenAI image models to AIModels.
.../lib/helpers/ai-helpers.ts Updates getModelClientType to recognize "dall-e" models as OpenAI client type.
.../lib/hooks/use-mb-chat.tsx Refactors MBChatProvider to include the image generation flag in requests and reorganizes error handling and hook initialization.
.../lib/hooks/use-model.tsx Adds detailed logging to the model change function for debugging purposes.
.../package.json Updates @ai-sdk/openai dependency version from 1.2.5 to ^1.3.22.
.../components/routes/chat/chat-message.tsx Enhances logging when no images are extracted and improves key generation for image elements to ensure uniqueness.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatPanel
    participant ImageGenerationProvider
    participant MBChatProvider
    participant ai-main-call.ts
    participant OpenAI

    User->>ChatPanel: Toggles Image Generation
    ChatPanel->>ImageGenerationProvider: Updates isImageGenerationEnabled
    User->>ChatPanel: Sends message with image generation enabled
    ChatPanel->>MBChatProvider: Submits message (isImageGeneration: true)
    MBChatProvider->>ai-main-call.ts: Calls createResponseStream with isImageGeneration
    ai-main-call.ts->>OpenAI: Requests image generation (prompt, model)
    OpenAI-->>ai-main-call.ts: Returns generated image (base64)
    ai-main-call.ts-->>MBChatProvider: Returns event-stream with image data
    MBChatProvider-->>ChatPanel: Delivers image response
    ChatPanel-->>User: Displays generated image
Loading

Possibly related PRs

Suggested labels

enhancement, feature, frontend, backend

Poem

In the meadow of code where the chatbots play,
A new brush appears—now images sway!
With toggles and streams, and a context so bright,
Our bots can now paint, both by day and by night.
🐇✨
Just whisper a prompt, let your visions take flight!
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/masterbots.ai/lib/helpers/ai-helpers.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/masterbots.ai/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

apps/masterbots.ai/components/routes/chat/chat-message.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/masterbots.ai/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

apps/masterbots.ai/lib/hooks/use-mb-chat.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/masterbots.ai/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c252059 and 969b339.

📒 Files selected for processing (3)
  • apps/masterbots.ai/components/routes/chat/chat-message.tsx (2 hunks)
  • apps/masterbots.ai/lib/helpers/ai-helpers.ts (2 hunks)
  • apps/masterbots.ai/lib/hooks/use-mb-chat.tsx (10 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/masterbots.ai/lib/helpers/ai-helpers.ts
  • apps/masterbots.ai/lib/hooks/use-mb-chat.tsx
🔇 Additional comments (2)
apps/masterbots.ai/components/routes/chat/chat-message.tsx (2)

118-121: Enhanced logging provides better debugging context.

The updated logging now includes both examples and parts properties, which will provide more comprehensive information when troubleshooting image extraction issues. This is a good improvement for debugging.


133-133: Good fix for potential key collision issues.

Adding the image index (-${i}) to the key generation ensures uniqueness when multiple images from the same message might have identical first 32 characters of their base64 strings. This prevents potential React key collisions and improves component stability.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
apps/masterbots.ai/lib/hooks/use-image.tsx (1)

10-27: Consider adding state persistence.

The ImageGenerationProvider implementation is solid but lacks persistence across sessions. Users will need to re-enable image generation each time they refresh the page.

Consider adding localStorage persistence:

export function ImageGenerationProvider({ children }: { children: React.ReactNode }) {
-  const [isImageGenerationEnabled, setIsImageGenerationEnabled] = useState(false)
+  const [isImageGenerationEnabled, setIsImageGenerationEnabled] = useState(() => {
+    // Check if we're in a browser environment
+    if (typeof window !== 'undefined') {
+      const saved = localStorage.getItem('isImageGenerationEnabled')
+      return saved === 'true' ? true : false
+    }
+    return false
+  })

  const toggleImageGeneration = () => {
+    const newValue = !isImageGenerationEnabled
    setIsImageGenerationEnabled(!isImageGenerationEnabled)
+    // Save to localStorage when changed
+    if (typeof window !== 'undefined') {
+      localStorage.setItem('isImageGenerationEnabled', String(newValue))
+    }
  }
apps/masterbots.ai/app/actions/ai-main-call.ts (1)

38-38: Verify if all imports are used.

The experimental_generateImage import appears to be unused. Consider removing it if it's not needed.

import {
	type Message,
	extractReasoningMiddleware,
	smoothStream,
	streamObject,
	streamText,
	wrapLanguageModel,
-	experimental_generateImage as generateImage,
} from 'ai'

Also applies to: 42-42

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccf3a4a and 5f2c54e.

📒 Files selected for processing (7)
  • apps/masterbots.ai/app/actions/ai-main-call.ts (3 hunks)
  • apps/masterbots.ai/components/layout/providers.tsx (2 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (1 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-panel.tsx (3 hunks)
  • apps/masterbots.ai/lib/hooks/use-image.tsx (1 hunks)
  • apps/masterbots.ai/lib/models.tsx (1 hunks)
  • apps/masterbots.ai/types/types.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (1)
apps/masterbots.ai/lib/models.tsx (1)
  • groupModels (52-62)
apps/masterbots.ai/components/layout/providers.tsx (2)
apps/masterbots.ai/lib/hooks/use-image.tsx (1)
  • ImageGenerationProvider (10-27)
apps/masterbots.ai/lib/hooks/use-mb-chat.tsx (1)
  • MBChatProvider (80-988)
🔇 Additional comments (11)
apps/masterbots.ai/components/routes/chat/chat-combobox.tsx (1)

65-65: Clean code refactoring!

The destructuring assignment has been consolidated into a single line, improving code readability and reducing unnecessary vertical space.

apps/masterbots.ai/lib/models.tsx (1)

29-30: Good addition of DALL-E icon mapping!

The model icon mapping has been extended to associate DALL-E models with the OpenAI icon, which aligns with the image generation feature being implemented.

apps/masterbots.ai/components/layout/providers.tsx (2)

7-7: Added ImageGenerationProvider import

The import aligns with the PR objective of introducing image generation support.


46-48: Proper React context hierarchy integration

The ImageGenerationProvider is correctly positioned just above the MBChatProvider, ensuring that image generation state is available throughout the chat context.

apps/masterbots.ai/types/types.ts (1)

220-221: Added isImageGeneration flag to support new feature

The JSONResponseStream type has been updated with an optional isImageGeneration flag, which is essential for handling image generation responses differently from text responses.

apps/masterbots.ai/components/routes/chat/chat-panel.tsx (3)

23-24: Import additions look good.

The imports for ImageIcon and useImageGeneration hook are correctly added to support the new image generation feature.

Also applies to: 28-28


66-66: Well-structured hook integration.

The destructured values from the useImageGeneration hook follow the same pattern as other feature hooks, maintaining consistency in the codebase.


171-179: Clean UI implementation for image generation toggle.

The implementation of the image generation toggle is consistent with other feature toggles, using the same component structure and styling patterns. The green color for the active state provides good visual distinction from other toggles.

apps/masterbots.ai/lib/hooks/use-image.tsx (2)

1-9: Well-structured context implementation.

The context definition and interface follow React best practices with proper TypeScript typing.


29-35: Hook implementation is correct.

The useImageGeneration hook properly checks if it's being used within the provider context, following React best practices.

Fix the trailing space at the end of the file:

  return context
-} 
+}
apps/masterbots.ai/app/actions/ai-main-call.ts (1)

328-328: Properly destructured isImageGeneration flag.

The isImageGeneration flag is correctly added to the destructured properties from the input JSON.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Bran18 - I've reviewed your changes - here's some feedback:

  • In createResponseStream you import experimental_generateImage but then directly call openai.images.generate—either remove the unused import or consolidate to use your experimental_generateImage helper for consistency.
  • The groupModels call in ChatCombobox now receives IMAGE_MODELS with a different shape than your normal models list—consider extending/filtering the existing models array instead of swapping to a new type so you don’t break the grouping logic.
  • Inside the image generation branch you reference coreMessages, but that variable isn’t defined in this scope; you probably meant to use the earlier messages or rawMessages array.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@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

🧹 Nitpick comments (1)
apps/masterbots.ai/lib/hooks/use-mb-chat.tsx (1)

503-529: Good error handling addition for failed responses.

The new onResponse handler properly checks for error status codes and performs appropriate cleanup, including deleting the thread for new chats. This prevents orphaned threads when API calls fail.

Consider extracting the duplicate thread deletion logic into a reusable function to reduce code duplication:

+const cleanupFailedNewChat = async () => {
+	if (isNewChat) {
+		await deleteThread({
+			threadId,
+			jwt: session?.user?.hasuraJwt,
+			userId: session?.user.id,
+		})
+	}
+}

async onResponse(response: any) {
	if (response.status >= 400) {
		customSonner({ type: 'error', text: response.statusText })
-
-		if (isNewChat) {
-			await deleteThread({
-				threadId,
-				jwt: session?.user?.hasuraJwt,
-				userId: session?.user.id,
-			})
-		}
+		await cleanupFailedNewChat()
	}
},

This same function could be reused in the onError handler and other error scenarios.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b0b30b and 22ed06c.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • apps/masterbots.ai/app/actions/ai-main-call.ts (3 hunks)
  • apps/masterbots.ai/app/api/chat/models/models.ts (1 hunks)
  • apps/masterbots.ai/components/routes/chat/chat-panel.tsx (4 hunks)
  • apps/masterbots.ai/lib/helpers/ai-helpers.ts (1 hunks)
  • apps/masterbots.ai/lib/hooks/use-image.tsx (1 hunks)
  • apps/masterbots.ai/lib/hooks/use-mb-chat.tsx (6 hunks)
  • apps/masterbots.ai/lib/hooks/use-model.tsx (1 hunks)
  • apps/masterbots.ai/package.json (1 hunks)
  • apps/masterbots.ai/types/types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • apps/masterbots.ai/lib/hooks/use-model.tsx
  • apps/masterbots.ai/lib/helpers/ai-helpers.ts
  • apps/masterbots.ai/app/api/chat/models/models.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/masterbots.ai/lib/hooks/use-image.tsx
  • apps/masterbots.ai/types/types.ts
  • apps/masterbots.ai/components/routes/chat/chat-panel.tsx
  • apps/masterbots.ai/app/actions/ai-main-call.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/masterbots.ai/lib/hooks/use-mb-chat.tsx (2)
apps/masterbots.ai/services/hasura/hasura.service.ts (1)
  • deleteThread (1184-1219)
apps/masterbots.ai/auth.ts (1)
  • session (171-186)
🔇 Additional comments (3)
apps/masterbots.ai/lib/hooks/use-mb-chat.tsx (2)

16-16: LGTM!

The import path change for AIModels aligns with the new file structure for organizing model definitions.


230-230:

Details

✅ Verification successful

Verify the AIModels enum contains the expected value.

The implementation correctly sets the isImageGeneration flag based on the selected model. However, ensure that AIModels.OpenAI_Image_Generation is properly defined in the models file.


🏁 Script executed:

#!/bin/bash
# Description: Verify that AIModels.OpenAI_Image_Generation is defined

# Search for the OpenAI_Image_Generation enum value definition
ast-grep --pattern 'enum AIModels {
  $$$
  OpenAI_Image_Generation = $_
  $$$
}'

# Also check with ripgrep as a fallback
rg -A 5 'OpenAI_Image_Generation' --glob '*.ts' --glob '*.tsx'

Length of output: 765


Verified AIModels.OpenAI_Image_Generation Exists

Confirmed that AIModels.OpenAI_Image_Generation is defined in
• apps/masterbots.ai/app/api/chat/models/models.ts (OpenAI_Image_Generation = 'gpt-image-1')
No further action required.

apps/masterbots.ai/package.json (1)

21-21:

Details

✅ Verification successful

Verify compatibility with the OpenAI SDK update.

The version update from 1.2.5 to ^1.3.22 is necessary for the new image generation features. The use of caret range (^) is appropriate for minor version updates.


🌐 Web query:

What are the breaking changes between @ai-sdk/openai version 1.2.5 and 1.3.22?

💡 Result:

Based on the changelog information provided, here are the breaking changes and updates between @ai-sdk/openai version 1.2.5 and 1.3.22:

Breaking Changes

There are no explicitly labeled breaking changes between versions 1.2.5 and 1.3.22 of @ai-sdk/openai. However, several significant features and updates were introduced across these versions.

Feature Additions and Updates

Model Support Additions

  • Added support for new OpenAI models:
    • GPT-4o and GPT-4o-mini models with developer systemMessageMode (v1.3.20)[5]
    • GPT-image-1 model for image generation (v1.3.18 and v1.3.19)[5]
    • o3 and o4-mini models (v1.3.15)[5]
    • GPT-4.5-preview model (v1.1.14)[5]

API Enhancements

  • Support for reasoning summaries added in v1.3.17[5]
  • Updates for responses API in the o4 model in v1.3.16[5]
  • Strict schemas option added to the responses model in v1.2.4[5]
  • Support for responses API added in v1.2.2[5]
  • Raw response body exposed in generateText and generateObject (v1.2.1)[5]

Bug Fixes

  • Fixed a Zod parse error with function in v1.3.21[5]

Azure Support

  • Added Azure image model support in v1.2.0[5]

Patch Changes

All the updates between these versions were released as patch changes, indicating they should maintain backward compatibility. The changelog shows a series of incremental updates from v1.2.1 through v1.3.22, with each version introducing specific improvements or fixes.

Each version bumped dependencies appropriately, with updates to underlying packages like @ai-sdk/provider-utils and @ai-sdk/provider throughout the version range.

Citations:


Dependency update verified—no breaking changes

  • File: apps/masterbots.ai/package.json
    Updated @ai-sdk/openai from 1.2.5 to ^1.3.22
  • Changelog review confirms all releases between 1.2.5 and 1.3.22 are backward-compatible patches and feature additions with no breaking changes.

No further action needed.

@AndlerRL
Copy link
Member

1 similar comment
@AndlerRL
Copy link
Member

@Bran18
Copy link
Contributor Author

Bran18 commented Jun 10, 2025

Closing - This code was not delivering the expected results

@Bran18 Bran18 closed this Jun 10, 2025
@AndlerRL
Copy link
Member

AndlerRL commented Jul 2, 2025

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.

2 participants