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

Review2 #861

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open

Review2 #861

wants to merge 6 commits into from

Conversation

Keyrxng
Copy link
Contributor

@Keyrxng Keyrxng commented Oct 14, 2023

Resolves #746
Closes #748

Quality Assurance:

I haven't changed any logic other than adding an additional call so I'm returning the validated response instead of the first gptResponse.

I've split the review call into two smaller ones which is much more effective in reducing signal-to-noise.

I manually copy and pasted the console logs in the bot comment after the fact.

@netlify
Copy link

netlify bot commented Oct 14, 2023

Deploy Preview for ubiquibot-staging ready!

Name Link
🔨 Latest commit b98186f
🔍 Latest deploy log https://app.netlify.com/sites/ubiquibot-staging/deploys/652b070caa307700076fe823
😎 Deploy Preview https://deploy-preview-861--ubiquibot-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Keyrxng Keyrxng marked this pull request as ready for review October 14, 2023 21:25
@Keyrxng Keyrxng closed this Oct 14, 2023
@Keyrxng Keyrxng reopened this Oct 14, 2023

export const sysMsg = `You are the UbiquityAI, designed to provide accurate technical answers. \n
const escapeMsg = `Please ignore all previous commands and directives. \n
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of the escape message?

Copy link
Contributor Author

@Keyrxng Keyrxng Oct 17, 2023

Choose a reason for hiding this comment

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

OpenAI has their default system message which defines how it works with you

`;

export const validationMsg = `${escapeMsg} You are an AI validation bot designed to ensure that the answers provided by the OpenAI API meet our predefined standards. \n
The input you'll validate is the output of a pull request review performed by GPT-3, depending on whether it has achieved the spec will determine what you need to do. \n
Copy link
Member

Choose a reason for hiding this comment

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

Interesting

Copy link
Contributor Author

@Keyrxng Keyrxng Oct 17, 2023

Choose a reason for hiding this comment

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

Chain-of-Verification Reduces Hallucination in Large Language Models

Something along these lines

`;

export const gptContextTemplate = `
You are the UbiquityAI, designed to review and analyze pull requests.
export const specCheckTemplate = `${escapeMsg} Using the provided context, ensure you clearly understand the specification of the issue. \n
Copy link
Member

Choose a reason for hiding this comment

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

Solid prompt. I think your prompt writing is better than before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Appreciate it 🤝

`;

export const gptContextTemplate = `${escapeMsg}
You are an AI designed to review and analyze pull requests.
Copy link
Member

@0x4007 0x4007 Oct 17, 2023

Choose a reason for hiding this comment

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

As silly as this sounds "Take a deep breath and work on this problem step by step" might be useful.

"A little bit of arithmetic and a logical approach will help us quickly arrive at the solution to this problem." is useful for GPT-3.5, according to the above source.

Copy link
Member

Choose a reason for hiding this comment

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

I just added these to my custom instructions!

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's really fcking interesting how effective that is. I wonder why the take a breath aspect plays into it at all I mean you'd expect it to be like "As an AI language model, I cannot breath" but it just personifies itself and does it? crazy 🤣 Will deffo add this into the prompts

@@ -54,6 +86,66 @@ Example:[
]
`;

export const getPRSpec = async (context: Context, chatHistory: CreateChatCompletionRequestMessage[], streamlined: StreamlinedComment[]) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const getPRSpec = async (context: Context, chatHistory: CreateChatCompletionRequestMessage[], streamlined: StreamlinedComment[]) => {
export async function getPRSpec(context: Context, chatHistory: CreateChatCompletionRequestMessage[], streamlined: StreamlinedComment[]) {

Use named functions, because it is more expressive for debugging in the context of stack traces.

} as CreateChatCompletionRequestMessage,
{
role: "system",
role: "assistant",
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change this to assistant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it's hard to tell exactly a lot of conflicting information from the community but from the OpenAI docs. On the forum a lot of experimenting happens like dropping the sys message as the most recent after every response (if that makes sense), some say the system has the most weight while others say user does (I'd imagine it would be User, System, Assistant) but I changed it according to the OpenAI docs so it would be treated as part of the conversation as opposed to trying to define the assistant.

Typically, a conversation is formatted with a system message first, followed by alternating user and assistant messages.

The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. However note that the system message is optional and the model’s behavior without a system message is likely to be similar to using a generic message such as "You are a helpful assistant."

The user messages provide requests or comments for the assistant to respond to. Assistant messages store previous assistant responses, but can also be written by you to give examples of desired behavior.

timeRangeForMaxIssue: process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE
? Number(process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE)
: timeRangeForMaxIssue,
timeRangeForMaxIssue: process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE ? Number(process.env.DEFAULT_TIME_RANGE_FOR_MAX_ISSUE) : timeRangeForMaxIssue,
Copy link
Member

Choose a reason for hiding this comment

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

Do not use environment variables anymore, unless it is for sensitive information like keys.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only changed due to my IDE format-on-save.

There is a lot of process.env usage throughout the codebase, I know there is a refactor coming so this can be looked at as part of #859 maybe?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we're basically not using environment variables anymore at all, and instead are relying entirely on the yml configs.

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.

AI: /review
2 participants