mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-06 05:42:33 +00:00
Rename Grok AI -> Grok
This commit is contained in:
@@ -188,7 +188,7 @@ function makeGrokMember(groupMemberId = 7777) {
|
||||
groupMemberId,
|
||||
memberContactId: GROK_CONTACT_ID,
|
||||
memberStatus: GroupMemberStatus.Connected,
|
||||
memberProfile: {displayName: "Grok AI"},
|
||||
memberProfile: {displayName: "Grok"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ function makeGroupInfo(groupId: number, opts: Partial<any> = {}): any {
|
||||
}
|
||||
|
||||
function makeUser(userId: number) {
|
||||
return {userId, profile: {displayName: userId === MAIN_USER_ID ? "Ask SimpleX Team" : "Grok AI"}}
|
||||
return {userId, profile: {displayName: userId === MAIN_USER_ID ? "Ask SimpleX Team" : "Grok"}}
|
||||
}
|
||||
|
||||
function makeChatItem(opts: {
|
||||
@@ -358,7 +358,7 @@ function teamMemberMessage(text: string, contactId = TEAM_MEMBER_1_ID, groupId =
|
||||
}
|
||||
|
||||
function grokResponseMessage(text: string, groupId = CUSTOMER_GROUP_ID): any {
|
||||
const ci = makeChatItem({dir: "groupRcv", text, memberId: "grok-member", memberContactId: GROK_CONTACT_ID, memberDisplayName: "Grok AI"})
|
||||
const ci = makeChatItem({dir: "groupRcv", text, memberId: "grok-member", memberContactId: GROK_CONTACT_ID, memberDisplayName: "Grok"})
|
||||
return {
|
||||
type: "newChatItems" as const,
|
||||
user: makeUser(MAIN_USER_ID),
|
||||
@@ -677,6 +677,21 @@ describe("Grok Conversation", () => {
|
||||
expect(grokApi.calls.length).toBe(0)
|
||||
})
|
||||
|
||||
test("Grok per-message: history includes prior Grok sent response as assistant", async () => {
|
||||
addCustomerMessageToHistory("How do I create a group?", GROK_LOCAL_GROUP_ID)
|
||||
addBotMessage("To create a group, tap + then New Group.", GROK_LOCAL_GROUP_ID)
|
||||
addCustomerMessageToHistory("How do I invite members?", GROK_LOCAL_GROUP_ID)
|
||||
grokApi.willRespond("Open the group and tap Invite.")
|
||||
await bot.onGrokNewChatItems(grokViewCustomerMessage("How do I invite members?"))
|
||||
|
||||
expect(grokApi.calls.length).toBe(1)
|
||||
expect(grokApi.calls[0].message).toBe("How do I invite members?")
|
||||
expect(grokApi.calls[0].history).toEqual([
|
||||
{role: "user", content: "How do I create a group?"},
|
||||
{role: "assistant", content: "To create a group, tap + then New Group."},
|
||||
])
|
||||
})
|
||||
|
||||
test("Grok ignores non-customer messages", async () => {
|
||||
chat.groups.set(GROK_LOCAL_GROUP_ID, makeGroupInfo(GROK_LOCAL_GROUP_ID))
|
||||
const ci = makeChatItem({dir: "groupRcv", text: "Team message", memberId: "not-customer", memberContactId: TEAM_MEMBER_1_ID})
|
||||
|
||||
@@ -76,7 +76,7 @@ async function main(): Promise<void> {
|
||||
welcomeMessage,
|
||||
},
|
||||
commands: [
|
||||
...(grokEnabled ? [{type: "command" as const, keyword: "grok", label: "Ask Grok AI"}] : []),
|
||||
...(grokEnabled ? [{type: "command" as const, keyword: "grok", label: "Ask Grok"}] : []),
|
||||
{type: "command", keyword: "team", label: "Switch to team"},
|
||||
],
|
||||
useBotProfile: true,
|
||||
@@ -101,14 +101,14 @@ async function main(): Promise<void> {
|
||||
if (grokEnabled) {
|
||||
log("Resolving Grok profile...")
|
||||
const users = await chat.apiListUsers()
|
||||
grokUser = users.find(u => u.user.profile.displayName === "Grok AI")?.user ?? null
|
||||
grokUser = users.find(u => u.user.profile.displayName === "Grok" || u.user.profile.displayName === "Grok AI")?.user ?? null
|
||||
if (!grokUser) {
|
||||
log("Creating Grok profile...")
|
||||
grokUser = await chat.apiCreateActiveUser({displayName: "Grok AI", fullName: "", image: grokImage})
|
||||
grokUser = await chat.apiCreateActiveUser({displayName: "Grok", fullName: "", image: grokImage})
|
||||
// apiCreateActiveUser sets Grok as active — switch back to main
|
||||
await chat.apiSetActiveUser(mainUser.userId)
|
||||
} else {
|
||||
const grokProfile: T.Profile = {displayName: "Grok AI", fullName: "", image: grokImage}
|
||||
const grokProfile: T.Profile = {displayName: "Grok", fullName: "", image: grokImage}
|
||||
const currentProfile = util.fromLocalProfile(grokUser.profile)
|
||||
if (currentProfile.image !== grokProfile.image || currentProfile.displayName !== grokProfile.displayName || currentProfile.fullName !== grokProfile.fullName) {
|
||||
log("Grok profile changed, updating...")
|
||||
|
||||
Reference in New Issue
Block a user