Skip to content

Conversation

@whereisfarukk
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @whereisfarukk, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the capabilities of the VlmRun node by introducing a robust 'Chat Completion' feature. This enhancement allows users to leverage advanced conversational AI, supporting diverse input types like text, images, videos, and files, and providing precise control over output formatting through JSON schemas. The changes aim to broaden the node's utility for complex, multi-modal AI workflows.

Highlights

  • New Chat Completion Operation: A new 'Chat Completion' operation has been added to the VlmRun node, enabling users to interact with an OpenAI-compatible chat API.
  • Multi-modal Input Support: The new chat completion feature supports multi-modal inputs, allowing users to include text, image URLs, video URLs, and file URLs within their chat prompts.
  • Structured Output Control: Users can now specify the desired response format, including options for simple JSON object output or detailed JSON schema-guided responses, enhancing control over AI output.
  • API Integration and Error Handling: The VlmRunClient has been updated to integrate with a new /openai/chat/completions endpoint and includes enhanced error logging for better debugging.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a 'Chat Completion' operation, enabling structured output capabilities. The implementation is comprehensive, adding new types, API service methods, and node properties. My review focuses on improving code quality by addressing code duplication, strengthening validation, and removing debug statements that could leak information. Overall, this is a great feature addition.

Comment on lines 702 to 751
// Process image URLs
const imageUrls: string[] = [];
if (inputType === 'image') {
const imageUrlsParam = this.getNodeParameter('imageUrls', i) as IDataObject;
if (imageUrlsParam && imageUrlsParam.url) {
const urlEntries = Array.isArray(imageUrlsParam.url) ? imageUrlsParam.url : [imageUrlsParam.url];
for (const entry of urlEntries) {
if (entry && typeof entry === 'object' && entry.url) {
const url = entry.url as string;
if (url && url.trim()) {
imageUrls.push(url.trim());
}
}
}
}
}

// Process video URLs
const videoUrls: string[] = [];
if (inputType === 'video') {
const videoUrlsParam = this.getNodeParameter('videoUrls', i) as IDataObject;
if (videoUrlsParam && videoUrlsParam.url) {
const urlEntries = Array.isArray(videoUrlsParam.url) ? videoUrlsParam.url : [videoUrlsParam.url];
for (const entry of urlEntries) {
if (entry && typeof entry === 'object' && entry.url) {
const url = entry.url as string;
if (url && url.trim()) {
videoUrls.push(url.trim());
}
}
}
}
}

// Process file URLs
const fileUrls: string[] = [];
if (inputType === 'file') {
const fileUrlsParam = this.getNodeParameter('fileUrls', i) as IDataObject;
if (fileUrlsParam && fileUrlsParam.url) {
const urlEntries = Array.isArray(fileUrlsParam.url) ? fileUrlsParam.url : [fileUrlsParam.url];
for (const entry of urlEntries) {
if (entry && typeof entry === 'object' && entry.url) {
const url = entry.url as string;
if (url && url.trim()) {
fileUrls.push(url.trim());
}
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for processing URLs from imageUrls, videoUrls, and fileUrls parameters is duplicated. To improve code maintainability and reduce redundancy, this logic can be extracted into a helper function.

                        const getUrlsFromParam = (paramName: string): string[] => {
							const urls: string[] = [];
							const param = this.getNodeParameter(paramName, i) as IDataObject;
							if (param && param.url) {
								const urlEntries = Array.isArray(param.url) ? param.url : [param.url];
								for (const entry of urlEntries) {
									if (entry && typeof entry === 'object' && entry.url) {
										const url = entry.url as string;
										if (url && url.trim()) {
											urls.push(url.trim());
										}
									}
								}
							}
							return urls;
						};

						// Process URLs
						const imageUrls: string[] = inputType === 'image' ? getUrlsFromParam('imageUrls') : [];
						const videoUrls: string[] = inputType === 'video' ? getUrlsFromParam('videoUrls') : [];
						const fileUrls: string[] = inputType === 'file' ? getUrlsFromParam('fileUrls') : [];

Comment on lines 841 to 846
if (!message.content) {
throw new NodeOperationError(
this.getNode(),
'Text message content cannot be empty.',
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current validation for text message content allows strings that contain only whitespace. It would be more robust to treat such strings as empty.

                                if (!message.content || !message.content.trim()) {
									throw new NodeOperationError(
										this.getNode(),
										'Text message content cannot be empty.',
									);
								}


response = await ApiService.chatCompletion(this, messages, model, undefined, responseFormat);

console.log(JSON.stringify(response, null, 2));
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This console.log statement appears to be for debugging. It should be removed before merging to avoid cluttering the logs in a production environment.

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