Skip to content

Commit

Permalink
fix the build
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvg committed Jul 2, 2024
1 parent 36d83b7 commit 9d4c9a8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,7 @@ import { type BamlProjectsGroupings, loadExampleProjects } from '@/lib/loadProje
import { useEffect, useState } from 'react'

export const ExploreProjects = () => {
const [projectGroups, setProjectGroups] = useState<BamlProjectsGroupings | null>(null)

useEffect(() => {
const fetchProjects = async () => {
const projects = await loadExampleProjects()
setProjectGroups(projects)
}
fetchProjects()
}, [])

return (
<div className='flex flex-col w-full h-full'>
<SheetHeader>
<SheetTitle className='text-2xl'>Prompt Fiddle Examples</SheetTitle>
<SheetDescription className='text-base'>
Prompt Fiddle uses BAML -- a configuration language for LLM functions. Here are some example projects to get
you started.
</SheetDescription>
</SheetHeader>

<div className='overflow-y-auto'>
{projectGroups ? (
<div className='flex flex-col gap-y-4'>
<ExampleCarousel title='Intros' projects={projectGroups.intros} />
{/* <ExampleCarousel title="Advanced Prompt Syntax" projects={projectGroups.advancedPromptSyntax} /> */}
<ExampleCarousel title='Prompt Engineering' projects={projectGroups.promptEngineering} />
</div>
) : (
<div>Loading...</div>
)}
</div>
</div>
)
return null
}

const ExampleCarousel = ({ title, projects }: { title: string; projects: BAMLProject[] }) => {
Expand Down
4 changes: 2 additions & 2 deletions typescript/fiddle-frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default function RootLayout({
<ThemeProvider attribute='class' defaultTheme='dark' enableSystem={false} disableTransitionOnChange={true}>
<JotaiProvider>
<Suspense fallback={<div>Loading...</div>}>{children}</Suspense>
<div className='fixed left-0 bottom-1/2 w-[12%] px-1 items-center justify-center flex'>
{/* <div className='fixed left-0 bottom-1/2 w-[12%] px-1 items-center justify-center flex'>
<BrowseSheet />
</div>
</div> */}
</JotaiProvider>
<Toaster />
</ThemeProvider>
Expand Down
11 changes: 11 additions & 0 deletions typescript/fiddle-frontend/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Link from 'next/link'

export default function NotFound() {
return (
<div>
<h2>Not Found</h2>
<p>Could not find requested resource</p>
<Link href='/'>Return Home</Link>
</div>
)
}
75 changes: 12 additions & 63 deletions typescript/fiddle-frontend/lib/loadProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ async function loadExampleProject(
projectId: string,
): Promise<BAMLProject | undefined> {
// Combine all projects into a single array
const exampleProjects = [
...groupings.intros,
...groupings.advancedPromptSyntax,
...groupings.promptEngineering,
...groupings.allProjects,
]
const exampleProjects = [...groupings.allProjects]
if (groupings.newProject) {
exampleProjects.push(groupings.newProject)
}

// Search for the project by id
const proj = exampleProjects.find((project) => project.id === projectId)
Expand Down Expand Up @@ -99,9 +97,7 @@ const getProjectFiles = async (projectPath: string): Promise<EditorFile[]> => {

export type BamlProjectsGroupings = {
allProjects: BAMLProject[]
intros: BAMLProject[]
advancedPromptSyntax: BAMLProject[]
promptEngineering: BAMLProject[]
newProject: BAMLProject
}

export async function loadExampleProjects(): Promise<BamlProjectsGroupings> {
Expand All @@ -115,60 +111,13 @@ export async function loadExampleProjects(): Promise<BamlProjectsGroupings> {
files: [],
},
],
intros: [
{
id: 'new-project',
name: 'New Project',
description: 'New project',
filePath: '/new-project/',
files: [],
},
{
id: 'extract-resume',
name: 'Introduction to BAML',
description: 'A simple LLM function extract a resume',
filePath: '/intro/extract-resume/',
files: [],
},
{
id: 'classify-message',
name: 'ClassifyMessage',
description: 'Classify a message from a user',
filePath: '/intro/classify-message/',
files: [],
},
{
id: 'chat-roles',
name: 'ChatRoles',
description: 'Use a sequence of system and user messages',
filePath: '/intro/chat-roles/',
files: [],
},
// {
// id: 'images',
// name: 'Using Vision / Image APIs',
// description: 'Extract resume from image',
// filePath: '/intro/images/',
// files: [],
// },
],
advancedPromptSyntax: [],
promptEngineering: [
{
id: 'chain-of-thought',
name: 'Chain of Thought',
description: 'Using chain of thought to improve results and reduce hallucinations',
filePath: '/prompt-engineering/chain-of-thought/',
files: [],
},
{
id: 'symbol-tuning',
name: 'Symbol Tuning',
filePath: '/prompt-engineering/symbol-tuning/',
description: 'Use symbol tuning to remove biases on schema property names',
files: [],
},
],
newProject: {
id: 'new-project',
name: 'New Project',
description: 'New project',
filePath: '/new-project/',
files: [],
},
}
return exampleProjects
}
8 changes: 0 additions & 8 deletions typescript/fiddle-frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['jotai-devtools', '@baml/playground-common', '@gloo-ai/baml-schema-wasm-web', '@baml/common'],
rewrites: async () => {
return [
{
source: '/anthropic/:path*',
destination: 'https://api.anthropic.com/:path*',
},
]
},
webpack(config, { isServer, dev }) {
config.experiments = {
...config.experiments,
Expand Down
1 change: 0 additions & 1 deletion typescript/fiddle-frontend/pages/api/[...path].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import httpProxy from 'http-proxy'
import { NextApiRequest, NextApiResponse } from 'next'
import url from 'url'

const API_URL = process.env.API_URL // The actual URL of your API

Expand Down

0 comments on commit 9d4c9a8

Please sign in to comment.