Skip to content

Commit

Permalink
chore: remove "tip writer"
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhooks committed Jan 9, 2024
1 parent 5051865 commit 5f24274
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 152 deletions.
22 changes: 0 additions & 22 deletions apps/course-builder-web/src/app/tips/_components/tip-assistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export function TipAssistant({tip}: {tip: Tip}) {

const textareaRef = useRef<HTMLTextAreaElement>(null)

const {mutateAsync: generateTitle, status: generateTitleStatus} =
api.tips.generateTitle.useMutation()

useSocket({
room: tip._id,
onMessage: (messageEvent) => {
Expand Down Expand Up @@ -54,7 +51,6 @@ export function TipAssistant({tip}: {tip: Tip}) {
ref={textareaRef}
className="w-full rounded-none border-0 border-b px-5 py-4 pr-10"
placeholder="Type a message..."
disabled={generateTitleStatus === 'loading'}
rows={4}
onKeyDown={async (event) => {
if (event.key === 'Enter' && !event.shiftKey) {
Expand Down Expand Up @@ -97,24 +93,6 @@ export function TipAssistant({tip}: {tip: Tip}) {
<EnterIcon className="w-4" />
</Button>
</div>

<div className="p-5">
<h3 className="flex pb-3 text-lg font-bold">Actions</h3>
<Button
type="button"
disabled={generateTitleStatus === 'loading'}
variant="secondary"
onClick={async (event) => {
event.preventDefault()
await generateTitle({tipId: tip._id})
}}
>
<SparkleIcon className="-ml-1 mr-1 w-3" /> suggest title{' '}
{generateTitleStatus === 'loading' && (
<LoaderIcon className="w-3 animate-spin" />
)}
</Button>
</div>
</div>
</div>
)
Expand Down
102 changes: 0 additions & 102 deletions apps/course-builder-web/src/inngest/functions/ai/tip-writer.ts

This file was deleted.

2 changes: 0 additions & 2 deletions apps/course-builder-web/src/inngest/inngest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
import {transcriptReady} from '@/inngest/functions/transcript-ready'
import {videoUploaded} from '@/inngest/functions/video-uploaded'
import {addSrtToMuxAsset} from '@/inngest/functions/mux/add-srt-to-mux-asset'
import {tipTitleAndSummaryWriter} from '@/inngest/functions/ai/tip-writer'
import {userCreated} from '@/inngest/functions/user-created'
import {weeklySignupDigest} from '@/inngest/functions/notify/creator/weekly-signups'
import {userSignupAdminEmail} from '@/inngest/functions/notify/creator/user-signup'
Expand All @@ -26,7 +25,6 @@ export const inngestConfig = {
transcriptReady,
videoUploaded,
addSrtToMuxAsset,
tipTitleAndSummaryWriter,
userCreated,
weeklySignupDigest,
userSignupAdminEmail,
Expand Down
3 changes: 0 additions & 3 deletions apps/course-builder-web/src/inngest/inngest.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {EventSchemas, Inngest} from 'inngest'
import {
type AI_TIP_WRITING_REQUESTED_EVENT,
type AI_WRITING_COMPLETED_EVENT,
type AI_WRITING_REQUESTED_EVENT,
type AITipWritingRequested,
type AIWritingRequestCompleted,
type AIWritingRequested,
ARTICLE_CHAT_EVENT,
Expand Down Expand Up @@ -58,7 +56,6 @@ type Events = {
[VIDEO_UPLOADED_EVENT]: VideoUploaded
[POST_CREATION_REQUESTED_EVENT]: PostCreationRequested
[MUX_SRT_READY_EVENT]: MuxSrtReady
[AI_TIP_WRITING_REQUESTED_EVENT]: AITipWritingRequested
[USER_CREATED_EVENT]: UserCreated
[POSTMARK_WEBHOOK_EVENT]: PostmarkWebhook
[CLOUDINARY_WEBHOOK_EVENT]: CloudinaryWebhook
Expand Down
24 changes: 1 addition & 23 deletions apps/course-builder-web/src/trpc/api/routers/tips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import slugify from '@sindresorhus/slugify'

import {customAlphabet} from 'nanoid'
import {inngest} from '@/inngest/inngest.server'
import {AI_TIP_WRITING_REQUESTED_EVENT, TIP_CHAT_EVENT} from '@/inngest/events'
import {TIP_CHAT_EVENT} from '@/inngest/events'
import {toChicagoTitleCase} from '@/utils/chicagor-title'
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 5)

Expand Down Expand Up @@ -161,28 +161,6 @@ export const tipsRouter = createTRPCRouter({
{returnDocuments: true},
)

return await getTip(input.tipId)
}),
generateTitle: protectedProcedure
.input(
z.object({
tipId: z.string(),
}),
)
.mutation(async ({ctx, input}) => {
const session = await getServerAuthSession()
const ability = getAbility({user: session?.user})
if (!ability.can('create', 'Content')) {
throw new Error('Unauthorized')
}

await inngest.send({
name: AI_TIP_WRITING_REQUESTED_EVENT,
data: {
tipId: input.tipId,
},
})

return await getTip(input.tipId)
}),
})

1 comment on commit 5f24274

@vercel
Copy link

@vercel vercel bot commented on 5f24274 Jan 9, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.