Skip to content

Commit

Permalink
feat: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolivierbouch committed Jul 19, 2024
1 parent 81edbfc commit 954cea8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 45 deletions.
48 changes: 23 additions & 25 deletions examples/next-website/app/api/assistant/file/[fileId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
import { OpenAI } from "openai";
import { z } from "zod";

import { OpenAI } from 'openai';
import { z } from 'zod';

const routeContextSchema = z.object({
params: z.object({
fileId: z.string(),
}),
})
params: z.object({
fileId: z.string(),
}),
});

export async function GET(
request: Request,
context: z.infer<typeof routeContextSchema>
request: Request,
context: z.infer<typeof routeContextSchema>,
) {
const { params } = routeContextSchema.parse(context);

const { params } = routeContextSchema.parse(context)

const openai = new OpenAI({
// eslint-disable-next-line turbo/no-undeclared-env-vars
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAI({
// eslint-disable-next-line turbo/no-undeclared-env-vars
apiKey: process.env.OPENAI_API_KEY,
});

const [file, fileContent] = await Promise.all([
openai.files.retrieve(params.fileId),
openai.files.content(params.fileId),
]);
const [file, fileContent] = await Promise.all([
openai.files.retrieve(params.fileId),
openai.files.content(params.fileId),
]);

return new Response(fileContent.body, {
headers: {
"Content-Disposition": `attachment; filename="${file.filename}"`,
},
});
}
return new Response(fileContent.body, {
headers: {
'Content-Disposition': `attachment; filename="${file.filename}"`,
},
});
}
6 changes: 5 additions & 1 deletion examples/next-website/app/api/assistant/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ export async function POST(req: Request) {

return AssistantResponse(
// @ts-ignore
{ threadId, messageId: createdMessage.id, fileUrlPath: '/api/assistant/file/%ID%' },
{
threadId,
messageId: createdMessage.id,
fileUrlPath: '/api/assistant/file/%ID%',
},
async ({ sendMessage, forwardStream, sendDataMessage }) => {
try {
// Run the assistant on the thread
Expand Down
1 change: 0 additions & 1 deletion examples/next-website/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default function ChatPage() {
'https://gwetfkan2dovfoiz.public.blob.vercel-storage.com/search-8jZhOvOBPxuTmohrup5TPvSzrjsyog.png',
chatInputStyle: 'default',


chatHistoryEnabled: true,
chatFileAttachementEnabled: true,

Expand Down
32 changes: 17 additions & 15 deletions packages/ui/components/chat-footer-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ import React from 'react';
import { cn } from '@/lib/utils';
import { ExternalLink } from '@/components/external-link';

export function FooterText({ className, link, name, ...props }: React.ComponentProps<'p'> & { link: string, name: string }) {
return (
<p
className={cn(
'px-2 text-center text-xs leading-normal text-muted-foreground',
className,
)}
{...props}
>
Powered by{' '}
<ExternalLink href={link}>
{name}
</ExternalLink>
</p>
);
export function FooterText({
className,
link,
name,
...props
}: React.ComponentProps<'p'> & { link: string; name: string }) {
return (
<p
className={cn(
'px-2 text-center text-xs leading-normal text-muted-foreground',
className,
)}
{...props}
>
Powered by <ExternalLink href={link}>{name}</ExternalLink>
</p>
);
}
11 changes: 8 additions & 3 deletions packages/ui/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function Chat({
}`}
>
<div className="mb-4 grid grid-cols-1 md:grid-cols-2 gap-2 px-4 ">
{ /** here we can put chatbot extensions like inquiry, message prompt etc... */}
{/** here we can put chatbot extensions like inquiry, message prompt etc... */}
</div>

<div className="space-y-4 border-t bg-background px-4 py-2 shadow-lg sm:rounded-t-xl md:py-4">
Expand All @@ -245,7 +245,8 @@ export function Chat({
? 'Image'
: inputFileRef.current?.files![0].type === 'image/png'
? 'Image'
: inputFileRef.current?.files![0].type === 'image/svg+xml'
: inputFileRef.current?.files![0].type ===
'image/svg+xml'
? 'Image'
: 'Document'}
</span>
Expand Down Expand Up @@ -330,7 +331,11 @@ export function Chat({
</div>
</div>
{chatbot.displayFooterText && (
<FooterText link={chatbot.footerLink} name={chatbot.footerTextName} className="block my-2" />
<FooterText
link={chatbot.footerLink}
name={chatbot.footerTextName}
className="block my-2"
/>
)}
</form>
</div>
Expand Down

0 comments on commit 954cea8

Please sign in to comment.