Skip to content

Commit

Permalink
Merge pull request #381 from meemproject/feature/openai
Browse files Browse the repository at this point in the history
Fix reinitialize for non-contract agreements
  • Loading branch information
kengoldfarb authored Apr 7, 2023
2 parents f2b7278 + 8b9ce1f commit 9a616cc
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 31 deletions.
7 changes: 5 additions & 2 deletions src/controllers/TestController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Op } from 'sequelize'
import GnosisSafeABI from '../abis/GnosisSafe.json'
import GnosisSafeProxyABI from '../abis/GnosisSafeProxy.json'
import meemABI from '../abis/Meem.json'
import { prompt1, prompt2 } from '../lib/gptPrompts'
import { Constructor } from '../serverless/cron'
import { Mycontract__factory } from '../types/Meem'
import { MeemAPI } from '../types/meem.generated'
Expand Down Expand Up @@ -43,8 +44,10 @@ export default class TestController {
messages: [
{
role: 'system',
content:
"You are a content curator. You will be ingesting messages from the chat rooms of a community. You will then analyze the messages for the best content. You should consider the emoji reactions for each message as well as surrounding context and discussion. Finally, you should summarize the best content and links into a newsletter format where the writer's voice is playful and engaging. You should also include a few jokes and memes."
content: prompt2({
brandName: 'Tiffany and Co',
brandVoice: 'Absurd and weird'
})
},
{
role: 'user',
Expand Down
8 changes: 8 additions & 0 deletions src/lib/gptPrompts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const prompt1 =
"You are a content curator. You will be ingesting messages from the chat rooms of a community. You will then analyze the messages for the best content. You should consider the emoji reactions for each message as well as surrounding context and discussion. Finally, you should summarize the best content and links into a newsletter format where the writer's voice is playful and engaging. You should also include a few jokes and memes."

export const prompt2 = (options: { brandName: string; brandVoice: string }) => {
const { brandName, brandVoice } = options

return `You are a content curator. You will be ingesting messages from the chat rooms of the ${brandName} community. You will then analyze the messages for the best content. You should consider the emoji reactions for each message as well as surrounding context and discussion. Finally, you should summarize the best content and links into a newsletter format where the writer's voice can be described as: ${brandVoice}`
}
37 changes: 20 additions & 17 deletions src/services/Agreement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,29 @@ export default class AgreementService {
// params: [contractInitParams],
// gasLimit: ethers.BigNumber.from(config.MINT_GAS_LIMIT)
// })
const chainId = agreementOrRole.chainId
if (agreementOrRole.isOnChain) {
const chainId = agreementOrRole.chainId

const agreementContract = await services.agreement.getAgreementContract({
chainId,
address: ethers.constants.AddressZero
})
const agreementContract = await services.agreement.getAgreementContract({
chainId,
address: ethers.constants.AddressZero
})

const txId = await services.ethers.queueTransaction({
chainId,
functionSignature:
agreementContract.interface.functions[
'reinitialize((string,string,string,(address,bytes32,bool)[],uint256,(uint8,address[],uint256,uint256,uint256,uint256,bytes32)[],(address,uint256,address)[],bool))'
].format(),
contractAddress: agreementOrRoleContract.address,
inputValues: {
params: contractInitParams
}
})
const txId = await services.ethers.queueTransaction({
chainId,
functionSignature:
agreementContract.interface.functions[
'reinitialize((string,string,string,(address,bytes32,bool)[],uint256,(uint8,address[],uint256,uint256,uint256,uint256,bytes32)[],(address,uint256,address)[],bool))'
].format(),
contractAddress: agreementOrRoleContract.address,
inputValues: {
params: contractInitParams
}
})
return { txId }
}

return { txId }
return {}
}

public static async createAgreementWithoutContract(options: {
Expand Down
8 changes: 4 additions & 4 deletions src/types/meem.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1819,8 +1819,8 @@ export namespace ReInitializeAgreement {
}

export interface IResponseBody extends IApiResponseBody {
/** The Transaction id for updating the contract */
txId: string
/** The Transaction id for updating the contract. Only available if agreement is on chain */
txId?: string
}

export interface IDefinition {
Expand Down Expand Up @@ -1873,8 +1873,8 @@ export namespace ReInitializeAgreementRole {
}

export interface IResponseBody extends IApiResponseBody {
/** The Transaction id for updating the contract */
txId: string
/** The Transaction id for updating the contract. Only available if agreement is on chain */
txId?: string
}

export interface IDefinition {
Expand Down
8 changes: 4 additions & 4 deletions src/types/meem.public.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1750,8 +1750,8 @@ export namespace ReInitializeAgreement {
}

export interface IResponseBody extends IApiResponseBody {
/** The Transaction id for updating the contract */
txId: string
/** The Transaction id for updating the contract. Only available if agreement is on chain */
txId?: string
}

export interface IDefinition {
Expand Down Expand Up @@ -1804,8 +1804,8 @@ export namespace ReInitializeAgreementRole {
}

export interface IResponseBody extends IApiResponseBody {
/** The Transaction id for updating the contract */
txId: string
/** The Transaction id for updating the contract. Only available if agreement is on chain */
txId?: string
}

export interface IDefinition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export namespace ReInitializeAgreement {
}

export interface IResponseBody extends IApiResponseBody {
/** The Transaction id for updating the contract */
txId: string
/** The Transaction id for updating the contract. Only available if agreement is on chain */
txId?: string
}

export interface IDefinition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export namespace ReInitializeAgreementRole {
}

export interface IResponseBody extends IApiResponseBody {
/** The Transaction id for updating the contract */
txId: string
/** The Transaction id for updating the contract. Only available if agreement is on chain */
txId?: string
}

export interface IDefinition {
Expand Down

0 comments on commit 9a616cc

Please sign in to comment.