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

Feat/project #18

Open
wants to merge 158 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
19db2dd
added landing page
amandal-cn Sep 3, 2024
9e42d96
added landing page and dashboard
amandal-cn Sep 3, 2024
6f4b79a
added project overview input form
amandal-cn Sep 4, 2024
5cd4972
added header
amandal-cn Sep 4, 2024
6374b6f
Add projects crud
aprusty-cn Sep 4, 2024
d8505ba
added workspace
amandal-cn Sep 5, 2024
171eaf3
improved the look of the artifact list
amandal-cn Sep 5, 2024
aebac39
integrated codeeditor with the workspace
amandal-cn Sep 5, 2024
2314f08
updated main page
amandal-cn Sep 6, 2024
8551969
Merge branch 'apis' of https://github.com/trilogy-group/llamacoder in…
aprusty-cn Sep 6, 2024
d4ef840
Merge
aprusty-cn Sep 6, 2024
4bd4a15
improved the chat interface
amandal-cn Sep 6, 2024
fc384bc
refactored UpdateArtifact
amandal-cn Sep 6, 2024
3e450c9
Add routing between pages
aprusty-cn Sep 6, 2024
a1887dd
Add my projects button
aprusty-cn Sep 6, 2024
cef21fb
added chat context and support viewing attachments
amandal-cn Sep 6, 2024
b260298
improved the file viewer modal's look
amandal-cn Sep 6, 2024
19dc802
fixed the attachment click issue (was sending message)
amandal-cn Sep 6, 2024
13fab2a
show error message on sending empty message
amandal-cn Sep 6, 2024
9bb7fa7
fixed height issue for chat context
amandal-cn Sep 6, 2024
b0fc270
Added the copy buttons over hovered message
amandal-cn Sep 6, 2024
ccf996f
added border color to differentiate between user and assistant messages
amandal-cn Sep 6, 2024
84ba94a
Add create project fucntionality
aprusty-cn Sep 6, 2024
8e0f555
Add loading indicators in dashboard
aprusty-cn Sep 6, 2024
30c77d8
Support delete and status
aprusty-cn Sep 6, 2024
718dc75
Add project title
aprusty-cn Sep 9, 2024
e9ad274
Style changes
aprusty-cn Sep 9, 2024
d879c8a
Add simple landing page with login/signup + routing
rishabh-ti Sep 6, 2024
81bbd0b
removed deprecated config for rendering images
rishabh-ti Sep 6, 2024
49ac6c4
Add FGA client
rishabh-ti Sep 9, 2024
10187b7
Functionality updates
aprusty-cn Sep 9, 2024
80abca4
remove auth buttons from old header
rishabh-ti Sep 9, 2024
3f77196
Merge conflicts
aprusty-cn Sep 9, 2024
be58be8
Add FGA API
rishabh-ti Sep 9, 2024
948be8c
added context and dispatch event functionality
amandal-cn Sep 9, 2024
c1e41ee
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 9, 2024
7efe25b
Fix listObjects & add test page
rishabh-ti Sep 9, 2024
6369a27
Add project authz
aprusty-cn Sep 9, 2024
c89352d
Handle authz errors in the frontend
aprusty-cn Sep 9, 2024
982147a
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 9, 2024
c7b2974
fixed merge issues
amandal-cn Sep 9, 2024
ec92348
Fix ts errors
aprusty-cn Sep 9, 2024
eca0d92
fixed layout issue
amandal-cn Sep 9, 2024
8aec5ef
integrate project crud with its api client
amandal-cn Sep 9, 2024
a82f4be
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 9, 2024
d266bbf
fixed project apis
amandal-cn Sep 9, 2024
cd1105b
fixed workspace
amandal-cn Sep 9, 2024
90ed99b
added apis for artifacts
amandal-cn Sep 9, 2024
21f5d16
fixed publishing of artifacts
amandal-cn Sep 9, 2024
8ef7460
added capability to stream message
amandal-cn Sep 9, 2024
701f44b
added status field to each artifact
amandal-cn Sep 9, 2024
649a664
added parsing of code, dependencies and name
amandal-cn Sep 9, 2024
2e914a6
fixed render issue
amandal-cn Sep 9, 2024
5256e1e
fixed the rerendering issue in code editor
amandal-cn Sep 9, 2024
568f463
fixed re-rendering issue in the code editor
amandal-cn Sep 9, 2024
31e2962
fixed the status message rendering
amandal-cn Sep 9, 2024
068c558
added key
amandal-cn Sep 10, 2024
6873299
fixed the height issue of the workspace
amandal-cn Sep 10, 2024
2e18349
fixed rendering of messages
amandal-cn Sep 10, 2024
cbae231
added remark-gfm
amandal-cn Sep 10, 2024
198faeb
chat session updates on chaning artifact
amandal-cn Sep 10, 2024
de30b9c
disabled pinning of selected artifact
amandal-cn Sep 10, 2024
1e03252
improved the rendering of chat history
amandal-cn Sep 10, 2024
ee266d4
added code viewer capability
amandal-cn Sep 10, 2024
ebd3d2e
minimized delay in artifaction generation
amandal-cn Sep 10, 2024
8e043ed
removed unnecessary code
amandal-cn Sep 10, 2024
d928f7b
Add share modal
aprusty-cn Sep 10, 2024
af3d662
removed user since we will be using autho0 user
amandal-cn Sep 10, 2024
5882165
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 10, 2024
da0dc39
fixed build and eslint issues
amandal-cn Sep 10, 2024
2b6d44a
Share with user
aprusty-cn Sep 10, 2024
36d4a76
fixed code editor rendering issues
amandal-cn Sep 10, 2024
c8f80a5
minor fix
amandal-cn Sep 10, 2024
7ed046a
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 10, 2024
0703803
fixed code viewer and code editor
amandal-cn Sep 10, 2024
2cd55f9
fixed workspace
amandal-cn Sep 10, 2024
e6a6737
reduced delay between code and rendering
amandal-cn Sep 10, 2024
3a924ca
minimized latency in code rendering
amandal-cn Sep 10, 2024
7c57788
fixed artifacts list
amandal-cn Sep 10, 2024
5141e0b
delete with custom confirmation dialog
amandal-cn Sep 10, 2024
eb4604a
showing confirmation dialog at the center
amandal-cn Sep 10, 2024
7b3dcd9
fixed width of artifact name
amandal-cn Sep 10, 2024
6d10136
showing artifact info on hovering over artifact
amandal-cn Sep 10, 2024
db7ba96
fixed the styling of confirmation dialog
amandal-cn Sep 10, 2024
1942b3c
fixed status icon for artifacts
amandal-cn Sep 10, 2024
f42885c
fixed the menu for artifacts
amandal-cn Sep 10, 2024
c1184b2
added alert
amandal-cn Sep 10, 2024
d50b6b1
temporarily disabled tools
amandal-cn Sep 10, 2024
e5d1aff
fixed the styling for alert
amandal-cn Sep 10, 2024
588f580
fixed rerendering issues for artifacts with error
amandal-cn Sep 10, 2024
aed3a4d
fixed rendering issue
amandal-cn Sep 10, 2024
f1278de
fixed the duplicate issue
amandal-cn Sep 10, 2024
32e0585
added reset button
amandal-cn Sep 10, 2024
902a822
fixed reset button issues
amandal-cn Sep 11, 2024
f6b1b96
fixed refresh button
amandal-cn Sep 11, 2024
fd91503
combined update for project and selected artifact
amandal-cn Sep 11, 2024
0e2016a
capability to take attachments
amandal-cn Sep 11, 2024
262c66c
separated static configs
amandal-cn Sep 11, 2024
ec46897
fixed initial message rendering issue
amandal-cn Sep 11, 2024
2806a63
remove the local attachments on loading the artifacts
amandal-cn Sep 11, 2024
ef04b12
refactored processing of chat history
amandal-cn Sep 11, 2024
e8324a4
added capability to update artifacts
amandal-cn Sep 11, 2024
9951075
fixed required libraries issue
amandal-cn Sep 11, 2024
a2c8ac0
put restriction on the type of supported files
amandal-cn Sep 11, 2024
35c8207
Users with access list
aprusty-cn Sep 10, 2024
fdc6dd7
Access list edit access
aprusty-cn Sep 11, 2024
5a02022
added capability to compose
amandal-cn Sep 11, 2024
9c75aad
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 11, 2024
9183ae0
Add access level checks for workspace
trunapushpa Sep 11, 2024
e3e7ec9
Restrict access for shared projects
trunapushpa Sep 11, 2024
5154e64
Share based on current access level
trunapushpa Sep 11, 2024
5dc0cb3
Remove extra
aprusty-cn Sep 11, 2024
c83bdb7
Add share functionality to the dashboard
aprusty-cn Sep 11, 2024
40d657f
added auto fix button and status tracking for each artifact
amandal-cn Sep 11, 2024
f8a5090
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 11, 2024
06e165c
fixed sharing
amandal-cn Sep 11, 2024
ff14bf8
fixed the progress bar in the landing page
amandal-cn Sep 11, 2024
6bbaf8e
added loading message for dashboard
amandal-cn Sep 11, 2024
05220fc
Change createby
aprusty-cn Sep 11, 2024
459bc29
improved dashboard
amandal-cn Sep 11, 2024
1436034
Show contributors
aprusty-cn Sep 11, 2024
c3d73ba
fixed the styling for dashboard and projects
amandal-cn Sep 11, 2024
0f04957
Merge branch 'feat/project' of github-amandal-cn:trilogy-group/llamac…
amandal-cn Sep 11, 2024
e188a96
fixed build issues
amandal-cn Sep 11, 2024
dcef597
fixed issue with passing empty available components
amandal-cn Sep 11, 2024
d9abffd
fixed code gen issues
amandal-cn Sep 11, 2024
a3e7564
fixed api url issue
amandal-cn Sep 11, 2024
3ef42fd
added support for multiple models and warning for incomplete code
amandal-cn Sep 12, 2024
84222ad
added instruction for sticking to using fetch for api calls
amandal-cn Sep 12, 2024
b3bc98d
Feat/versioning (#17)
rishabh-ti Sep 12, 2024
fda1ebb
Remove explicit maxTokens in gpt4o
rishabh-ti Sep 13, 2024
268c079
Add Posthog (#19)
rishabh-ti Sep 13, 2024
9d8309f
fixed the header
amandal-cn Sep 13, 2024
f5160de
improved the project header
amandal-cn Sep 13, 2024
083fa21
added button to go to dashboard
amandal-cn Sep 13, 2024
a6c2a4d
enabled sharing functionality
amandal-cn Sep 13, 2024
0eda59f
enabled copy button
amandal-cn Sep 13, 2024
67c12f5
updated dependencies
amandal-cn Sep 13, 2024
3ae9441
fixed project header
amandal-cn Sep 13, 2024
c513b70
fixed infinite fga calls
amandal-cn Sep 14, 2024
bcf8165
customized view based on access level
amandal-cn Sep 14, 2024
a970f16
improved the look for edit access model
amandal-cn Sep 14, 2024
d790a66
improved the look for share modal
amandal-cn Sep 14, 2024
d304b90
added capability to publish
amandal-cn Sep 14, 2024
8857be5
fixed status icon for published artifacts
amandal-cn Sep 14, 2024
14630e1
remove temp dir
amandal-cn Sep 14, 2024
4d6bf37
added support for more text files and images
amandal-cn Sep 14, 2024
cb93140
added support for pdf-js
amandal-cn Sep 14, 2024
100388c
support for amr64
amandal-cn Sep 14, 2024
96d9180
added support for docx
amandal-cn Sep 14, 2024
879c6d9
Added api documentation (#21)
amandal-cn Sep 17, 2024
28a6dcd
Adding pipeline
aprusty-cn Sep 17, 2024
8d9307b
Update readme
aprusty-cn Sep 17, 2024
c2ac207
Use Authorization in swagger
rishabh-ti Sep 18, 2024
c7fd4a9
fixed issue where on empty projects it goes into loop
amandal-cn Sep 18, 2024
34ee9a9
Fix swagger page
aprusty-cn Sep 18, 2024
e79f1af
Cleanup
aprusty-cn Sep 18, 2024
9345c2d
Feat/migrate okta fga (#20)
rishabh-ti Sep 19, 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
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules/
.next
.env
*.env
.next
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ yarn-error.log*
next-env.d.ts

node_modules
temp
temp/
8 changes: 7 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"plugins": ["prettier-plugin-tailwindcss"]
"plugins": ["prettier-plugin-tailwindcss"],
"arrowParens": "always",
"printWidth": 140,
"trailingComma": "es5",
"semi": false,
"useTabs": true,
"singleQuote": true
}
44 changes: 1 addition & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1 @@
<a href="https://www.llamacoder.io">
<img alt="Llama Coder" src="./public/og-image.png">
<h1 align="center">Llama Coder</h1>
</a>

<p align="center">
An open source Claude Artifacts – generate small apps with one prompt. Powered by Llama 3 405B & Together.ai.
</p>

## Tech stack

- [Llama 3.1 405B](https://ai.meta.com/blog/meta-llama-3-1/) from Meta for the LLM
- [Together AI](https://dub.sh/together-ai/?utm_source=example-app&utm_medium=llamacoder&utm_campaign=llamacoder-app-signup) for LLM inference
- [Sandpack](https://sandpack.codesandbox.io/) for the code sandbox
- Next.js app router with Tailwind
- Helicone for observability
- Plausible for website analytics

## Cloning & running

1. Clone the repo: `git clone https://github.com/Nutlope/llamacoder`
2. Create a `.env` file and add your [Together AI API key](https://dub.sh/together-ai/?utm_source=example-app&utm_medium=llamacoder&utm_campaign=llamacoder-app-signup): `TOGETHER_API_KEY=`
3. Run `npm install` and `npm run dev` to install dependencies and run locally

## Future Tasks

- [ ] Add dynamic OG images to the specific generations & include the prompt
- [ ] Add more dynamic OG images for playwright
- [ ] Address issue of ability to publish the same app repeatedly
- [ ] Try chain of thought reasoning to see if it works better overall
- [ ] Encourage best practices by making the input and textarea & having pills to generate apps w/ good prompts
- [ ] Save previous versions so people can go back and forth between the generated ones
- [ ] Could be nice to show a "featured apps" route on the site on `/featured`. Have a `/id/${prompt}` dynamic route that can display a bunch of nice example apps in the sandbox ready to go
- [ ] Support more languages starting with Python, check out E2B
- [ ] Try finetuning a smaller model on good prompts from 405b or GPT-4/Claude
- [ ] Add dark mode to the site overall, nice design change
- [ ] Think about how to have 405B correct itself (sometimes it makes up imports)
- [ ] New route for updateCode that only sends the latest generated code + the modify request
- [ ] Fix bug where if a user edits the code, then does a change, it doesn't use the edited code
- [ ] Add rate limiting with redis upstash if the traffic gets too high
- [ ] Try to add a consistent component library like shadcn
- [ ] Apply code diffs directly instead of asking the model to generate the code from scratch
- [ ] Add the ability to upload things like a screenshot for it to start from that
## Ti-Artifacts
258 changes: 258 additions & 0 deletions app/(main)/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
'use client'

import Alert from '@/components/Alert'
import ConfirmationDialog from '@/components/ConfirmationDialog'
import CreateProjectButton from '@/components/CreateProjectButton'
import EmptyProjectMessage from '@/components/EmptyProjectMessage'
import HeaderV2 from '@/components/HeaderV2'
import ProjectList from '@/components/ProjectList'
import ProjectOverviewInputForm from '@/components/ProjectOverviewInputForm'
import ProjectShareModal from '@/components/ProjectShareModal'
import { useAppContext } from '@/contexts/AppContext'
import { AccessLevel, Project } from '@/types/Project'
import { projectApi } from '@/utils/apiClients/Project'
import { useUser } from '@auth0/nextjs-auth0/client'
import { CircularProgress } from '@mui/material'
import axios from 'axios'
import { useRouter } from 'next/navigation'
import React, { useState } from 'react'

const Dashboard: React.FC = () => {
const { user, error: userError, isLoading: userLoading } = useUser()
const { projects, projectsLoading, projectsError, refreshProjects } = useAppContext()
const [showCreateForm, setShowCreateForm] = useState(false)
const [isCreatingProject, setIsCreatingProject] = useState(false)
const [showShareModal, setShowShareModal] = useState(false)
const [selectedProject, setSelectedProject] = useState<Project | null>(null)
const [alert, setAlert] = useState<{
type: 'error' | 'info' | 'warning' | 'success'
message: string
} | null>(null)
const [showDeleteConfirmation, setShowDeleteConfirmation] = useState(false)
const [projectToDelete, setProjectToDelete] = useState<Project | null>(null)

const router = useRouter()

// useEffect(() => {
// if (!projectsLoading && !projectsError && projects.length === 0) {
// refreshProjects();
// }
// }, [projectsLoading, projectsError, projects.length, refreshProjects]);

const handleCreateProject = async (description: string) => {
setIsCreatingProject(true)
try {
const titleResponse = await axios.post('/api/genai/title', {
description,
})
const generatedTitle = titleResponse.data.title

const newProject: Partial<Project> = {
title: generatedTitle,
description: description,
thumbnail: '',
context: [],
status: 'Inactive',
}

const createdProject = await projectApi.createProject(newProject)
await refreshProjects()
setShowCreateForm(false)
router.push(`/workspaces/${createdProject.id}`)
} catch (error) {
console.error('Error creating project:', error)
setAlert({
type: 'error',
message: 'Failed to create project. Please try again.',
})
} finally {
setIsCreatingProject(false)
}
}

const handleShareClick = (project: Project): void => {
setSelectedProject(project)
setShowShareModal(true)
}

const handleProjectDeleted = async (deletedProject: Project): Promise<void> => {
try {
await projectApi.deleteProject(deletedProject.id)
setAlert({ type: 'success', message: 'Project deleted successfully.' })
await refreshProjects()
} catch (error) {
console.error('Error deleting project:', error)
setAlert({
type: 'error',
message: 'Failed to delete project. Please try again.',
})
}
}

const handleDeleteClick = (project: Project): void => {
setProjectToDelete(project)
setShowDeleteConfirmation(true)
}

const handleDeleteConfirm = async () => {
if (projectToDelete) {
await handleProjectDeleted(projectToDelete)
setShowDeleteConfirmation(false)
setProjectToDelete(null)
}
}

const handleDeleteCancel = () => {
setShowDeleteConfirmation(false)
setProjectToDelete(null)
}

const handleUpdateAccessLevel = async (email: string, accessLevel: AccessLevel | 'revoke') => {
console.log('Adding contributor:', email, accessLevel)
if (!selectedProject) {
setAlert({
type: 'error',
message: 'Failed to add contributor. Please try again.',
})
return
}
const { success } = await projectApi.shareProject(selectedProject?.id, email, accessLevel)
if (!success) {
setAlert({
type: 'error',
message: 'Failed to add contributor. Please try again.',
})
return
}
if (accessLevel === 'revoke') {
setSelectedProject((prevProject) => {
if (!prevProject) return null
return {
...prevProject,
contributors: prevProject?.contributors?.filter((contributor) => contributor.email !== email),
}
})
} else {
setSelectedProject((prevProject) => {
if (!prevProject) return null
return {
...prevProject,
contributors: prevProject?.contributors?.map((contributor) =>
contributor.email === email ? { ...contributor, accessLevel } : contributor
),
}
})
}
}

const handleAddContributor = async (email: string, accessLevel: AccessLevel | 'revoke') => {
console.log('Adding contributor:', email, accessLevel)
if (!selectedProject) {
setAlert({
type: 'error',
message: 'Failed to add contributor. Please try again.',
})
return
}
const { success } = await projectApi.shareProject(selectedProject?.id, email, accessLevel)
if (!success) {
setAlert({
type: 'error',
message: 'Failed to add contributor. Please try again.',
})
return
}
if (accessLevel === 'revoke') {
return
} else {
setSelectedProject((prevProject) => {
if (!prevProject) return null
return {
...prevProject,
contributors: [...(prevProject.contributors || []), { email, accessLevel }],
}
})
}
}

if (userLoading) {
return (
<div className="flex min-h-screen items-center justify-center">
<CircularProgress size={60} />
</div>
)
}

if (projectsLoading) {
return (
<div className="flex h-screen flex-col items-center justify-center bg-gray-50">
<CircularProgress size={64} />
<h2 className="mb-2 mt-4 text-2xl font-semibold text-gray-700">Loading your projects...</h2>
</div>
)
}

if (userError) {
router.push('/api/auth/login')
}

return (
<div className="flex min-h-screen flex-col">
<HeaderV2 user={user} />
<main className="mt-24 w-full flex-1">
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
{projects.length > 0 ? (
<>
<div className="mb-8 mt-8 flex items-center justify-between">
<h2 className="text-4xl font-bold text-gray-800">Your Projects</h2>
<CreateProjectButton onClick={() => setShowCreateForm(true)} showSearch={projects.length > 0} />
</div>
<ProjectList
projects={projects}
onProjectDeleted={handleProjectDeleted}
onShareClick={handleShareClick}
onDeleteClick={handleDeleteClick}
/>
</>
) : (
<EmptyProjectMessage onCreateProject={() => setShowCreateForm(true)} />
)}
</div>
</main>

{showCreateForm && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-30 p-4 backdrop-blur-[2px]">
{isCreatingProject ? (
<div className="flex flex-col items-center justify-center bg-gray-50 p-10">
<CircularProgress size={64} />
<h2 className="mb-4 ml-10 mr-10 mt-6 text-2xl font-semibold text-gray-700">Creating your project...</h2>
</div>
) : (
<ProjectOverviewInputForm onCancel={() => setShowCreateForm(false)} onNext={handleCreateProject} />
)}
</div>
)}
{alert && <Alert type={alert.type} message={alert.message} onClose={() => setAlert(null)} />}
{showShareModal && selectedProject && (
<ProjectShareModal
isOpen={showShareModal}
onClose={() => setShowShareModal(false)}
project={selectedProject}
onUpdateAccessLevel={handleUpdateAccessLevel}
onAddContributor={handleAddContributor}
/>
)}
{showDeleteConfirmation && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 p-4">
<ConfirmationDialog
message={<p>Are you sure you want to delete this project? This action cannot be undone.</p>}
onConfirm={handleDeleteConfirm}
onCancel={handleDeleteCancel}
/>
</div>
)}
</div>
)
}

export default Dashboard
5 changes: 5 additions & 0 deletions app/(main)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Dashboard from '../dashboard';

export default function DashboardPage() {
return <Dashboard />;
}
Loading