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

Img sharing #353

Merged
merged 25 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ac4959f
add inlineKeyboard for image sharing
fegloff Jan 27, 2024
5205af8
Always hold 1 ONE on user balance
ArtemKolodko Jan 29, 2024
b3b0f59
add imageId to share button
fegloff Jan 29, 2024
85020c0
fix eslint error
fegloff Jan 29, 2024
b2116de
fix prefix command
fegloff Jan 29, 2024
3e2f8a3
Merge branch 'voice-command' into img-sharing
fegloff Jan 29, 2024
81039cc
add inscription logic
fegloff Jan 30, 2024
b10a608
Merge branch 'hold_one_balance' into img-sharing
fegloff Jan 30, 2024
ec45f26
Fix hot wallet withdraw check
ArtemKolodko Jan 30, 2024
331e35a
change call data convertion to hex
fegloff Jan 30, 2024
de9b04c
Merge branch 'hold_one_balance' of https://github.com/harmony-one/Har…
fegloff Jan 30, 2024
be1ee56
Merge branch 'hold_one_balance' into img-sharing
fegloff Jan 30, 2024
c7a7e9d
fix inscription logic + add progress messages
fegloff Jan 30, 2024
edf3713
update inscription logic + fix dalle prefixes
fegloff Feb 1, 2024
7cde7dd
fix a typo
fegloff Feb 1, 2024
c2f75d1
add inscription user info + delete share button logic
fegloff Feb 1, 2024
43bb308
add logger info
fegloff Feb 1, 2024
cfd9d75
Fix hot wallet check on /pay call
ArtemKolodko Feb 1, 2024
1871445
add error log for inscribeImg
fegloff Feb 1, 2024
145ecda
improve error message + censore system for dalle
fegloff Feb 5, 2024
afd31d7
disable inscriptionLottery
fegloff Feb 5, 2024
0f0c0fc
update dalle prefix
fegloff Feb 8, 2024
015525e
update suffix
fegloff Feb 22, 2024
a5a96fc
fix llms getCommandNamePrompt error
fegloff Feb 24, 2024
ba6b02b
fix multiple vision/dalle 2 image inquiries
fegloff Feb 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ function createInitialSessionData (): BotSessionData {
imgSize: config.openAi.dalle.sessionDefault.imgSize,
isEnabled: config.openAi.dalle.isEnabled,
imgRequestQueue: [],
isProcessingQueue: false
isProcessingQueue: false,
imageGenerated: [],
isInscriptionLotteryEnabled: config.openAi.dalle.isInscriptionLotteryEnabled,
imgInquiried: []
},
chatGpt: {
model: config.openAi.chatGpt.model,
Expand Down Expand Up @@ -402,7 +405,6 @@ const onMessage = async (ctx: OnMessageContext): Promise<void> => {
}
for (const config of Object.values(PayableBots)) {
const bot = config.bot

if (!bot.isSupportedEvent(ctx)) {
continue
}
Expand All @@ -428,7 +430,9 @@ const onMessage = async (ctx: OnMessageContext): Promise<void> => {
}
// Any message interacts with ChatGPT (only for private chats or /ask on enabled on group chats)
if (ctx.update.message.chat && (ctx.chat.type === 'private' || ctx.session.openAi.chatGpt.isFreePromptChatGroups)) {
await openAiBot.onEvent(ctx)
await openAiBot.onEvent(ctx, (e) => {
logger.error(e)
})
return
}
if (ctx.update.message.chat) {
Expand Down Expand Up @@ -460,6 +464,13 @@ const onCallback = async (ctx: OnCallBackQueryData): Promise<void> => {
await sdImagesBot.onEvent(ctx, (e) => {
logger.info(e, '// TODO refund payment')
})
return
}

if (openAiBot.isSupportedEvent(ctx)) {
await openAiBot.onEvent(ctx, (e) => {
logger.error(e)
})
}
} catch (ex: any) {
Sentry.captureException(ex)
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
openAi: {
dalle: {
isEnabled: Boolean(parseInt(process.env.IMAGE_GEN_ENABLED ?? '1')),
isInscriptionLotteryEnabled: false,
telegramFileUrl: 'https://api.telegram.org/file/bot',
completions: {
temperature:
Expand Down Expand Up @@ -125,6 +126,8 @@ export default {
holderAddress:
process.env.PAYMENT_HOLDER_ADDRESS ??
'0x9EE59D58606997AAFd2F6Ba46EC64402829f9b6C',
inscriptionDestinationAddress: '0x3abf101D3C31Aec5489C78E8efc86CaA3DF7B053',
minUserOneAmount: parseInt('1'), // always hold 1 ONE on user hot wallet balance to pay fees
whitelist: (process.env.PAYMENT_WHITELIST ?? '')
.split(',')
.map((item) => item.toString().toLowerCase()),
Expand Down
2 changes: 1 addition & 1 deletion src/modules/1country/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const getCommandNamePrompt = (
supportedCommands: any
): { commandName: string, prompt: string } => {
const hasCommand = ctx.hasCommand(
Object.values(supportedCommands).map((command: any) => command.name)
Object.values(supportedCommands).map((command: any) => command)
)
const commandName = hasCommand
? ctx.message?.text?.split(' ')[0].slice(1)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/llms/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export enum SupportedCommands {
}

export const MAX_TRIES = 3
const LLAMA_PREFIX_LIST = ['*']
const BARD_PREFIX_LIST = ['b.', 'B.']
const LLAMA_PREFIX_LIST = ['* ']
const BARD_PREFIX_LIST = ['b. ', 'B. ']

export const isMentioned = (
ctx: OnMessageContext | OnCallBackQueryData
Expand Down
6 changes: 3 additions & 3 deletions src/modules/open-ai/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export enum SupportedCommands {

export const MAX_TRIES = 3

export const DALLE_PREFIX_LIST = ['i. ', ',', 'image ', 'd.', 'img ']
export const CHAT_GPT_PREFIX_LIST = ['a.', '.']
export const NEW_PREFIX_LIST = ['n.', '..']
export const DALLE_PREFIX_LIST = ['i. ', ', ', 'd. ']
export const CHAT_GPT_PREFIX_LIST = ['a. ', '. ']
export const NEW_PREFIX_LIST = ['n. ', '.. ']

export const isMentioned = (
ctx: OnMessageContext | OnCallBackQueryData
Expand Down
Loading
Loading