-
Notifications
You must be signed in to change notification settings - Fork 59.3k
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
add dalle3 model #5173
add dalle3 model #5173
Conversation
@lloydzhou is attempting to deploy a commit to the NextChat Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe recent changes enhance the Changes
Poem
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 as PR comments)
Additionally, you can add 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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
app/icons/size.svg
is excluded by!**/*.svg
Files selected for processing (5)
- app/client/platforms/openai.ts (5 hunks)
- app/components/chat.tsx (4 hunks)
- app/constant.ts (3 hunks)
- app/store/chat.ts (2 hunks)
- app/utils.ts (1 hunks)
Additional comments not posted (17)
app/utils.ts (1)
269-271
: LGTM!The
isDalle3
function is a straightforward and efficient addition to the utility module.app/constant.ts (4)
149-149
: LGTM!The addition of
ImagePath
toOpenaiPath
is a straightforward enhancement that aligns with the existing structure.
159-160
: LGTM!The addition of the
ImagePath
method to theAzure
object is well-structured and consistent with the existingChatPath
method.
161-161
: LGTM!The update to
ExampleEndpoint
inAzure
reflects a more generalized and flexible endpoint structure.
263-263
: LGTM!The addition of
"dall-e-3"
to theopenaiModels
array is a straightforward enhancement that aligns with the goal of integrating DALL-E 3 image generation capabilities.app/client/platforms/openai.ts (6)
62-67
: LGTM!The
DalleRequestPayload
interface is well-defined and includes relevant properties for DALL-E 3 requests.
112-126
: LGTM!The modification to the
extractMessage
method to handle DALL-E 3 responses is straightforward and enhances the method's functionality.
140-176
: LGTM!The modifications to the
chat
method are well-structured and ensure appropriate handling of both DALL-E 3 and other models.
181-181
: LGTM!The adjustment to the
shouldStream
variable handling is logical and ensures appropriate management of streaming based on the model type.
207-215
: LGTM!The update to the path selection for API requests ensures that the correct endpoint is used based on the model type, enhancing the method's functionality.
142-142
: LGTM!The usage of the
_isDalle3
function within thechat
method is appropriate and ensures correct control flow based on the model type.app/store/chat.ts (2)
29-29
: Import statement forisDalle3
looks good.The import statement is correctly added and follows the project's import conventions.
545-548
: Usage ofisDalle3
insummarizeSession
method looks good.The logic correctly integrates the
isDalle3
function to skip summarization for the DALL-E 3 model.app/components/chat.tsx (4)
40-40
: Import statement forSizeIcon
looks good.The import statement is correctly added and follows the project's import conventions.
486-489
: State and array definitions for size selection look good.The
showSizeSelector
state anddalle3Sizes
array are correctly defined and used.
634-641
: Conditional rendering logic for size selector looks good.The size selector is correctly rendered based on whether the current model is DALL-E 3.
642-659
: Size selection handling logic looks good.The logic correctly updates the current session's configuration and provides appropriate user feedback through a toast notification.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- app/client/api.ts (2 hunks)
- app/client/platforms/openai.ts (6 hunks)
- app/components/chat.tsx (4 hunks)
- app/store/config.ts (2 hunks)
- app/typing.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- app/components/chat.tsx
Additional comments not posted (9)
app/typing.ts (1)
11-11
: LGTM!The new type
DalleSize
is well-defined and provides a structured way to handle specific image sizes.app/store/config.ts (2)
2-2
: LGTM!The new import statement for
DalleSize
is correctly added.
64-64
: LGTM!The addition of the
size
property to theDEFAULT_CONFIG
export is correctly typed asDalleSize
and provides a default value of"1024x1024"
.app/client/api.ts (2)
9-9
: LGTM!The new import statement for
DalleRequestPayload
is correctly added.
45-45
: LGTM!The addition of the optional
size
property to theLLMConfig
interface is correctly typed asDalleRequestPayload["size"]
, enhancing the flexibility of the API.app/client/platforms/openai.ts (4)
63-68
: InterfaceDalleRequestPayload
looks good.The interface is well-defined and correctly includes properties for the model, prompt, number of images, and size.
113-127
: Changes toextractMessage
function look good.The function correctly handles DALL-E 3 model responses by returning an image URL when the response contains image data.
141-179
: Changes tochat
function look good.The function correctly includes logic to handle DALL-E 3 model requests and constructs a
DalleRequestPayload
if the model is DALL-E 3. The control flow bifurcation and payload construction logic are correct.
210-218
: Changes topath
function look good.The function correctly handles different paths for DALL-E 3 and other models, ensuring the correct endpoint is used based on the model type.
Your build has completed! |
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/client/platforms/openai.ts (8 hunks)
Additional comments not posted (11)
app/client/platforms/openai.ts (11)
14-18
: Imports look good.The new imports related to image processing (
preProcessImageContent
,uploadImage
,base64Image2Blob
) are necessary for handling DALL-E 3 image responses.
20-20
: Import for DalleSize looks good.The import for
DalleSize
is necessary for defining the size parameter in DALL-E 3 requests.
41-41
: Alias import forisDalle3
looks good.The alias import for
isDalle3
is necessary for checking the model type in thechat
method.
67-73
: New interfaceDalleRequestPayload
looks good.The interface correctly defines the structure for DALL-E 3 requests, including properties for
model
,prompt
,response_format
,n
, andsize
.
117-137
: Handling DALL-E 3 image responses inextractMessage
looks good.The method correctly handles DALL-E 3 image responses by checking for image data, uploading base64 images if necessary, and returning the image URL.
151-166
: Handling DALL-E 3 requests inchat
method looks good.The method correctly constructs a
DalleRequestPayload
when the model is DALL-E 3, using the last message's content as the prompt and setting appropriate parameters.
188-191
: Conditional addition ofmax_tokens
for vision models looks good.The method correctly adds the
max_tokens
parameter for vision models when the model includes "preview".
196-196
: HandlingshouldStream
for DALL-E 3 requests looks good.The method correctly disables streaming for DALL-E 3 requests.
222-230
: Path selection for DALL-E 3 requests looks good.The method correctly selects the appropriate API path for DALL-E 3 requests based on the model type.
242-242
: Increased request timeout for DALL-E 3 requests looks good.The method correctly doubles the request timeout for DALL-E 3 requests due to the slower processing time.
373-373
: CallingextractMessage
for non-streaming requests looks good.The method correctly calls
extractMessage
to handle the response for non-streaming requests.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/client/platforms/openai.ts (8 hunks)
Additional comments not posted (5)
app/client/platforms/openai.ts (5)
14-18
: New imports approved.The new imports from "@/app/utils/chat" and "@/app/typing" are necessary for the added functionalities and are correctly used in the code.
Also applies to: 20-20
67-73
: New interfaceDalleRequestPayload
approved.The interface correctly defines the structure for DALL-E 3 model requests with all necessary properties.
117-138
: Changes toextractMessage
method approved.The method correctly handles DALL-E 3 model responses, including image URL extraction and base64 image conversion.
Line range hint
196-242
:
Changes to fetch request inchat
method approved.The fetch request correctly handles DALL-E 3 specific logic, including timeout adjustments.
151-191
: Changes tochat
method approved.The method correctly constructs the request payload for DALL-E 3 and integrates well with the existing structure.
However, ensure that all function calls to
chat
handle the new DALL-E 3 logic correctly.
Can only one image be returned at a time? Is it possible to return 4 images and then choose one for optimization? |
π» εζ΄η±»ε | Change Type
π εζ΄θ―΄ζ | Description of Change
π θ‘₯ε δΏ‘ζ― | Additional Information
Summary by CodeRabbit
New Features
Bug Fixes