-
Notifications
You must be signed in to change notification settings - Fork 834
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
AI Chat: Conversation API implementation #23067
Conversation
d62a722
to
76116fa
Compare
76116fa
to
df35431
Compare
3e2a4a4
to
8f2b644
Compare
{"role": "user", "type": "userText", "content": "Hello World"}, | ||
{"role": "user", "type": "requestRewrite", "content": "Use a funny tone"} |
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.
@evq this is one area that I don't think is covered by the existing events - rewriting text in place. This is what I came up with, let me know if you want to change the event format
trigger: | ||
"Triggered by user sending a prompt." | ||
data: | ||
"Will generate a text that attempts to match the user gave it" |
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.
Not entirely clear.
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.
I've pushed an improvement:
semantics {
sender: "AI Chat"
description:
"This is used to communicate with Brave's AI Conversation API"
"on behalf of the user interacting with different browser AI"
"features."
trigger:
"Triggered by user interactions such as submitting an AI Chat"
"conversation message, or requesting a text rewrite."
data:
"Conversational messages input by the user as well as associated"
"content or user text to be rewritten. Can contain PII."
destination: WEBSITE
}
request->headers.SetHeader(entry.first, entry.second); | ||
} | ||
} | ||
|
||
if (!payload.empty()) { | ||
DVLOG(4) << "Payload type " << payload_content_type << ":"; | ||
DVLOG(4) << payload; |
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.
are we logging the page content on the command line here? Mightn't these contain PII?
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.
Perhaps but this is debug builds only and verbose flag level 4. Is that acceptable?
I've pushed a commit that enables delta updates for in-progress chat messages as per server counterpart at https://github.com/brave/aichat/pull/182/commits/3919d31036c1058bebd0514cfdbaf9c8bca51269 |
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.
I'm still looking at engine_consumer_conversation_api.cc and its unittest, but figure I should post comments for others I have locally first.
components/ai_chat/core/browser/engine/engine_consumer_llama.cc
Outdated
Show resolved
Hide resolved
components/ai_chat/core/browser/engine/engine_consumer_conversation_api.h
Show resolved
Hide resolved
components/ai_chat/core/browser/engine/conversation_api_client.cc
Outdated
Show resolved
Hide resolved
components/ai_chat/core/browser/engine/engine_consumer_conversation_api.cc
Outdated
Show resolved
Hide resolved
65cc514
to
d98e697
Compare
[puLL-Merge] - brave/brave-core@23067 DescriptionThis PR makes changes to support the new Brave Conversation API for AI Chat features. It adds a new ChangesChangesai_chat_render_view_context_menu_browsertest.cc:
conversation_api_client.cc, conversation_api_client.h:
conversation_api_client_unittest.cc:
conversation_driver.cc:
engine_consumer.h:
engine_consumer_conversation_api.cc, engine_consumer_conversation_api.h:
engine_consumer_conversation_api_unittest.cc:
features.cc, features.h:
api_request_helper.cc:
Security Hotspots
Let me know if you have any other questions! |
std::optional<CredentialCacheEntry> credential_ = std::nullopt; | ||
}; | ||
|
||
TEST_F(ConversationAPIUnitTest, PremiumHeaders) { |
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.
PerformRequest_PremiumHeaders and add the same prefix for other test cases.
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.
Modified the test names (and now squashed all follow-ups now). Thanks for the review!
Also support delta updates
d97b659
to
d0ab661
Compare
testing::Mock::VerifyAndClearExpectations(credential_manager_.get()); | ||
} | ||
|
||
TEST_F(ConversationAPIUnitTest, FailNoConversationEvents) { |
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.
Please add PerformRequest preix to this one too.
Resolves brave/brave-browser#37575
This requires the folllowing AI Chat feature parameter to be enabled (disabled by default):
conversation_api
. It can be enabled by CLI via--enable-features=AIChat:conversation_api\/true
It is default disabled until the server side is ready and this implementation is verified with it.
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: