Upload 14 files
#1
by
YIIB
- opened
- .gitattributes +2 -0
- Gemini_Generated_Image_xj579kxj579kxj57.png +3 -0
- Supabase Performance Security Lints (kxgrcnxnkhctzxzcugca).csv +22 -0
- YIIB6I9 Cqcpzxllc clock-playback-controls.zip +3 -0
- build_with_Llama_3_2.ipynb (1).txt +0 -0
- build_with_Llama_3_2.ipynb.txt +0 -0
- code (1).txt Gemini API key .txt +15 -0
- prod-ca-2021.crt +23 -0
- prompts.py +259 -0
- supabase-schema-kxgrcnxnkhctzxzcugca (7).png +0 -0
- sync-sync.pdf +3 -0
- transactions.csv +8 -0
- twilio_2FA_recovery_code (1).txt account number .txt +1 -0
- twilio_2FA_recovery_code.txt +1 -0
- yiib_6_i_9.jsx.js +335 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
Gemini_Generated_Image_xj579kxj579kxj57.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
sync-sync.pdf filter=lfs diff=lfs merge=lfs -text
|
Gemini_Generated_Image_xj579kxj579kxj57.png
ADDED
|
Git LFS Details
|
Supabase Performance Security Lints (kxgrcnxnkhctzxzcugca).csv
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name,title,level,facing,categories,description,detail,remediation,metadata,cache_key
|
| 2 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.activities\` has a foreign key \`activities_repository_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""activities"",""type"":""table"",""schema"":""public"",""fkey_name"":""activities_repository_id_fkey"",""fkey_columns"":[4]}",unindexed_foreign_keys_public_activities_activities_repository_id_fkey
|
| 3 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.activities\` has a foreign key \`activities_target_user_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""activities"",""type"":""table"",""schema"":""public"",""fkey_name"":""activities_target_user_id_fkey"",""fkey_columns"":[5]}",unindexed_foreign_keys_public_activities_activities_target_user_id_fkey
|
| 4 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.chat_participants\` has a foreign key \`chat_participants_user_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""chat_participants"",""type"":""table"",""schema"":""public"",""fkey_name"":""chat_participants_user_id_fkey"",""fkey_columns"":[3]}",unindexed_foreign_keys_public_chat_participants_chat_participants_user_id_fkey
|
| 5 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.chats\` has a foreign key \`chats_created_by_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""chats"",""type"":""table"",""schema"":""public"",""fkey_name"":""chats_created_by_fkey"",""fkey_columns"":[6]}",unindexed_foreign_keys_public_chats_chats_created_by_fkey
|
| 6 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.messages\` has a foreign key \`messages_chat_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""messages"",""type"":""table"",""schema"":""public"",""fkey_name"":""messages_chat_id_fkey"",""fkey_columns"":[2]}",unindexed_foreign_keys_public_messages_messages_chat_id_fkey
|
| 7 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.messages\` has a foreign key \`messages_reply_to_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""messages"",""type"":""table"",""schema"":""public"",""fkey_name"":""messages_reply_to_fkey"",""fkey_columns"":[6]}",unindexed_foreign_keys_public_messages_messages_reply_to_fkey
|
| 8 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.messages\` has a foreign key \`messages_sender_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""messages"",""type"":""table"",""schema"":""public"",""fkey_name"":""messages_sender_id_fkey"",""fkey_columns"":[3]}",unindexed_foreign_keys_public_messages_messages_sender_id_fkey
|
| 9 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.notifications\` has a foreign key \`notifications_actor_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""notifications"",""type"":""table"",""schema"":""public"",""fkey_name"":""notifications_actor_id_fkey"",""fkey_columns"":[7]}",unindexed_foreign_keys_public_notifications_notifications_actor_id_fkey
|
| 10 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.notifications\` has a foreign key \`notifications_repository_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""notifications"",""type"":""table"",""schema"":""public"",""fkey_name"":""notifications_repository_id_fkey"",""fkey_columns"":[8]}",unindexed_foreign_keys_public_notifications_notifications_repository_id_fkey
|
| 11 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.repositories\` has a foreign key \`repositories_fork_parent_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""repositories"",""type"":""table"",""schema"":""public"",""fkey_name"":""repositories_fork_parent_id_fkey"",""fkey_columns"":[7]}",unindexed_foreign_keys_public_repositories_repositories_fork_parent_id_fkey
|
| 12 |
+
unindexed_foreign_keys,Unindexed foreign keys,INFO,EXTERNAL,"[""PERFORMANCE""]","Identifies foreign key constraints without a covering index, which can impact database performance.",Table \`public.users\` has a foreign key \`users_user_id_fkey\` without a covering index. This can lead to suboptimal query performance.,https://supabase.com/docs/guides/database/database-linter?lint=0001_unindexed_foreign_keys,"{""name"":""users"",""type"":""table"",""schema"":""public"",""fkey_name"":""users_user_id_fkey"",""fkey_columns"":[2]}",unindexed_foreign_keys_public_users_users_user_id_fkey
|
| 13 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_repositories_user_id\` on table \`public.repositories\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""repositories"",""type"":""table"",""schema"":""public""}",unused_index_public_repositories_idx_repositories_user_id
|
| 14 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_repository_files_repository_id\` on table \`public.repository_files\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""repository_files"",""type"":""table"",""schema"":""public""}",unused_index_public_repository_files_idx_repository_files_repository_id
|
| 15 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_commits_repository_id\` on table \`public.commits\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""commits"",""type"":""table"",""schema"":""public""}",unused_index_public_commits_idx_commits_repository_id
|
| 16 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_commits_user_id\` on table \`public.commits\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""commits"",""type"":""table"",""schema"":""public""}",unused_index_public_commits_idx_commits_user_id
|
| 17 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_stars_user_id\` on table \`public.stars\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""stars"",""type"":""table"",""schema"":""public""}",unused_index_public_stars_idx_stars_user_id
|
| 18 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_stars_repository_id\` on table \`public.stars\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""stars"",""type"":""table"",""schema"":""public""}",unused_index_public_stars_idx_stars_repository_id
|
| 19 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_follows_follower_id\` on table \`public.follows\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""follows"",""type"":""table"",""schema"":""public""}",unused_index_public_follows_idx_follows_follower_id
|
| 20 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_follows_following_id\` on table \`public.follows\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""follows"",""type"":""table"",""schema"":""public""}",unused_index_public_follows_idx_follows_following_id
|
| 21 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_notifications_user_id\` on table \`public.notifications\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""notifications"",""type"":""table"",""schema"":""public""}",unused_index_public_notifications_idx_notifications_user_id
|
| 22 |
+
unused_index,Unused Index,INFO,EXTERNAL,"[""PERFORMANCE""]",Detects if an index has never been used and may be a candidate for removal.,Index \`idx_activities_user_id\` on table \`public.activities\` has not been used,https://supabase.com/docs/guides/database/database-linter?lint=0005_unused_index,"{""name"":""activities"",""type"":""table"",""schema"":""public""}",unused_index_public_activities_idx_activities_user_id
|
YIIB6I9 Cqcpzxllc clock-playback-controls.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2cd6ab2190d0a6bf6f5e0ffcf65900be1560c690c3dd03ad4154bd55d2cfe0c
|
| 3 |
+
size 16529
|
build_with_Llama_3_2.ipynb (1).txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
build_with_Llama_3_2.ipynb.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
code (1).txt Gemini API key .txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent" \
|
| 2 |
+
-H 'Content-Type: application/json' \
|
| 3 |
+
-H 'X-goog-api-key: GEMINI_API_KEY' \
|
| 4 |
+
-X POST \
|
| 5 |
+
-d '{
|
| 6 |
+
"contents": [
|
| 7 |
+
{
|
| 8 |
+
"parts": [
|
| 9 |
+
{
|
| 10 |
+
"text": "Explain how AI works in a few words"
|
| 11 |
+
}
|
| 12 |
+
]
|
| 13 |
+
}
|
| 14 |
+
]
|
| 15 |
+
}'
|
prod-ca-2021.crt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN CERTIFICATE-----
|
| 2 |
+
MIIDxDCCAqygAwIBAgIUbLxMod62P2ktCiAkxnKJwtE9VPYwDQYJKoZIhvcNAQEL
|
| 3 |
+
BQAwazELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB0RlbHdhcmUxEzARBgNVBAcMCk5l
|
| 4 |
+
dyBDYXN0bGUxFTATBgNVBAoMDFN1cGFiYXNlIEluYzEeMBwGA1UEAwwVU3VwYWJh
|
| 5 |
+
c2UgUm9vdCAyMDIxIENBMB4XDTIxMDQyODEwNTY1M1oXDTMxMDQyNjEwNTY1M1ow
|
| 6 |
+
azELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB0RlbHdhcmUxEzARBgNVBAcMCk5ldyBD
|
| 7 |
+
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the terms described in the LICENSE file in
|
| 5 |
+
# the root directory of this source tree.
|
| 6 |
+
|
| 7 |
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 8 |
+
# All rights reserved.
|
| 9 |
+
#
|
| 10 |
+
# This source code is licensed under the terms described in the LICENSE file in
|
| 11 |
+
# top-level folder for each specific model found within the models/ directory at
|
| 12 |
+
# the top-level of this source tree.
|
| 13 |
+
|
| 14 |
+
import textwrap
|
| 15 |
+
from typing import List
|
| 16 |
+
|
| 17 |
+
from llama_models.datatypes import (
|
| 18 |
+
BuiltinTool,
|
| 19 |
+
RawMessage,
|
| 20 |
+
StopReason,
|
| 21 |
+
ToolCall,
|
| 22 |
+
ToolPromptFormat,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
from ..prompt_format import (
|
| 26 |
+
# llama3_1_e2e_tool_call_dialog,
|
| 27 |
+
TextCompletionContent,
|
| 28 |
+
UseCase,
|
| 29 |
+
llama3_1_builtin_tool_call_dialog,
|
| 30 |
+
llama3_1_custom_tool_call_dialog,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def wolfram_alpha_response():
|
| 35 |
+
return textwrap.dedent(
|
| 36 |
+
"""
|
| 37 |
+
{
|
| 38 |
+
"queryresult": {
|
| 39 |
+
"success": true,
|
| 40 |
+
"inputstring": "100th decimal of pi",
|
| 41 |
+
"pods": [
|
| 42 |
+
{
|
| 43 |
+
"title": "Input interpretation",
|
| 44 |
+
"subpods": [
|
| 45 |
+
{
|
| 46 |
+
"title": "",
|
| 47 |
+
"plaintext": "100th digit | \u03c0"
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"title": "Nearby digits",
|
| 53 |
+
"subpods": [
|
| 54 |
+
{
|
| 55 |
+
"title": "",
|
| 56 |
+
"plaintext": "...86208998628034825342117067982148086513282306647093..."
|
| 57 |
+
}
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"title": "Result",
|
| 62 |
+
"primary": true,
|
| 63 |
+
"subpods": [
|
| 64 |
+
{
|
| 65 |
+
"title": "",
|
| 66 |
+
"plaintext": "7"
|
| 67 |
+
}
|
| 68 |
+
]
|
| 69 |
+
}
|
| 70 |
+
]
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
"""
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def usecases() -> List[UseCase | str]:
|
| 78 |
+
return [
|
| 79 |
+
textwrap.dedent(
|
| 80 |
+
"""
|
| 81 |
+
# Llama 3.1 - Prompt Formats
|
| 82 |
+
## Tokens
|
| 83 |
+
Here is a list of special tokens that are supported by Llama 3.1:
|
| 84 |
+
- `<|begin_of_text|>`: Specifies the start of the prompt
|
| 85 |
+
- `<|end_of_text|>`: Model will cease to generate more tokens. This token is generated only by the base models.
|
| 86 |
+
- `<|finetune_right_pad_id|>`: This token is used for padding text sequences to the same length in a batch.
|
| 87 |
+
- `<|start_header_id|>` and `<|end_header_id|>`: These tokens enclose the role for a particular message. The possible roles are: [system, user, assistant and tool]
|
| 88 |
+
- `<|eom_id|>`: End of message. A message represents a possible stopping point for execution where the model can inform the executor that a tool call needs to be made. This is used for multi-step interactions between the model and any available tools. This token is emitted by the model when the Environment: ipython instruction is used in the system prompt, or if the model calls for a built-in tool.
|
| 89 |
+
- `<|eot_id|>`: End of turn. Represents when the model has determined that it has finished interacting with the user message that initiated its response. This is used in two scenarios:
|
| 90 |
+
- at the end of a direct interaction between the model and the user
|
| 91 |
+
- at the end of multiple interactions between the model and any available tools
|
| 92 |
+
This token signals to the executor that the model has finished generating a response.
|
| 93 |
+
- `<|python_tag|>`: Is a special tag used in the model's response to signify a tool call.
|
| 94 |
+
"""
|
| 95 |
+
),
|
| 96 |
+
textwrap.dedent(
|
| 97 |
+
"""
|
| 98 |
+
There are 4 different roles that are supported by Llama 3.1
|
| 99 |
+
- `system`: Sets the context in which to interact with the AI model. It typically includes rules, guidelines, or necessary information that helps the model respond effectively.
|
| 100 |
+
- `user`: Represents the human interacting with the model. It includes the inputs, commands, and questions to the model.
|
| 101 |
+
- `tool`: A new role introduced in Llama 3.1. This role is used to mark messages with the output of a tool call when sent back to the model from the executor. (The actual token used by the model for this role is "ipython".)
|
| 102 |
+
- `assistant`: Represents the response generated by the AI model based on the context provided in the `system`, `tool` and `user` prompts.
|
| 103 |
+
"""
|
| 104 |
+
),
|
| 105 |
+
UseCase(
|
| 106 |
+
title="Llama 3.1 Base Model",
|
| 107 |
+
description="Text completion for Llama 3.1 base model uses this format.",
|
| 108 |
+
dialogs=[TextCompletionContent(content="Color of sky is blue but sometimes can also be")],
|
| 109 |
+
notes="Note start special tag",
|
| 110 |
+
),
|
| 111 |
+
"## Llama 3.1 Instruct Model",
|
| 112 |
+
UseCase(
|
| 113 |
+
title="User and assistant conversation",
|
| 114 |
+
description="Here is a regular multi-turn user assistant conversation and how its formatted.",
|
| 115 |
+
dialogs=[
|
| 116 |
+
[
|
| 117 |
+
RawMessage(role="system", content="You are a helpful assistant"),
|
| 118 |
+
RawMessage(
|
| 119 |
+
role="user",
|
| 120 |
+
content="Answer who are you in the form of jeopardy?",
|
| 121 |
+
),
|
| 122 |
+
]
|
| 123 |
+
],
|
| 124 |
+
notes="",
|
| 125 |
+
),
|
| 126 |
+
"## Tool Calling Formats",
|
| 127 |
+
textwrap.dedent(
|
| 128 |
+
"""
|
| 129 |
+
The three built-in tools (brave_search, wolfram_alpha, and code interpreter) can be turned on using the system prompt:
|
| 130 |
+
- Brave Search: Tool call to perform web searches.
|
| 131 |
+
- Wolfram Alpha: Tool call to perform complex mathematical calculations.
|
| 132 |
+
- Code Interpreter: Enables the model to output python code.
|
| 133 |
+
"""
|
| 134 |
+
),
|
| 135 |
+
UseCase(
|
| 136 |
+
title="Builtin Tool Calling",
|
| 137 |
+
description=textwrap.dedent(
|
| 138 |
+
"""
|
| 139 |
+
Here is an example of a conversation using brave search
|
| 140 |
+
"""
|
| 141 |
+
),
|
| 142 |
+
dialogs=[llama3_1_builtin_tool_call_dialog()],
|
| 143 |
+
notes=textwrap.dedent(
|
| 144 |
+
"""
|
| 145 |
+
- Just including Environment: ipython turns on code interpreter; therefore, you don't need to specify code interpretation on the Tools: line. The model can generate python code which is interpreted by the executor, with the result provided back to the model.
|
| 146 |
+
- The message body of the assistant response starts with a special tag <|python_tag|>
|
| 147 |
+
- As alluded to above, in such an environment, the model can generate <|eom_id|> instead of just the standard <|eot_id|> . The latter indicates the turn is finished, while the former indicates continued multi-step reasoning. That is, the model is expecting a continuation message with the output of the tool call.
|
| 148 |
+
- The model tool call response is of the form `tool.call(query="...")` wher tool is `brave_search` or `wolfram_alpha`
|
| 149 |
+
"""
|
| 150 |
+
),
|
| 151 |
+
),
|
| 152 |
+
UseCase(
|
| 153 |
+
title="Builtin Code Interpreter",
|
| 154 |
+
description="Here is an actual example of model responding with code",
|
| 155 |
+
dialogs=[
|
| 156 |
+
[
|
| 157 |
+
RawMessage(role="system", content="Environment: ipython"),
|
| 158 |
+
RawMessage(
|
| 159 |
+
role="user",
|
| 160 |
+
content="Write code to check if number is prime, use that to see if the number 7 is prime",
|
| 161 |
+
),
|
| 162 |
+
],
|
| 163 |
+
],
|
| 164 |
+
notes=textwrap.dedent(
|
| 165 |
+
"""
|
| 166 |
+
- Model starts with <|python_tag|> and continues writing python code that it needs to be executed
|
| 167 |
+
- No explicit mention of code_interpreter in system prompt. `Environment: ipython` implicitly enables it.
|
| 168 |
+
"""
|
| 169 |
+
),
|
| 170 |
+
),
|
| 171 |
+
UseCase(
|
| 172 |
+
title="Built-in tools full interaction",
|
| 173 |
+
description="Here is a full interaction with the built-in tools including the tool response and the final assistant response.",
|
| 174 |
+
dialogs=[
|
| 175 |
+
[
|
| 176 |
+
RawMessage(
|
| 177 |
+
role="system",
|
| 178 |
+
content="Environment: ipython\nTools: brave_search, wolfram_alpha\n",
|
| 179 |
+
),
|
| 180 |
+
RawMessage(role="user", content="What is the 100th decimal of pi?"),
|
| 181 |
+
RawMessage(
|
| 182 |
+
role="assistant",
|
| 183 |
+
content="",
|
| 184 |
+
stop_reason=StopReason.end_of_message,
|
| 185 |
+
tool_calls=[
|
| 186 |
+
ToolCall(
|
| 187 |
+
call_id="tool_call_id",
|
| 188 |
+
tool_name=BuiltinTool.wolfram_alpha,
|
| 189 |
+
arguments={"query": "100th decimal of pi"},
|
| 190 |
+
)
|
| 191 |
+
],
|
| 192 |
+
),
|
| 193 |
+
RawMessage(
|
| 194 |
+
role="tool",
|
| 195 |
+
content=wolfram_alpha_response(),
|
| 196 |
+
),
|
| 197 |
+
],
|
| 198 |
+
],
|
| 199 |
+
notes=textwrap.dedent(
|
| 200 |
+
"""
|
| 201 |
+
- Note the `<|python_tag|>` in the assistant response.
|
| 202 |
+
- Role is `tool` for the wolfram alpha response that is passed back to the model.
|
| 203 |
+
- Final message from assistant has <|eot_id|> tag.
|
| 204 |
+
"""
|
| 205 |
+
),
|
| 206 |
+
),
|
| 207 |
+
"## Zero shot tool calling",
|
| 208 |
+
UseCase(
|
| 209 |
+
title="JSON based tool calling",
|
| 210 |
+
description=textwrap.dedent(
|
| 211 |
+
"""
|
| 212 |
+
Llama models can now output custom tool calls from a single message to allow easier tool calling.
|
| 213 |
+
The following prompts provide an example of how custom tools can be called from the output of the model.
|
| 214 |
+
It's important to note that the model itself does not execute the calls; it provides structured output to facilitate calling by an executor.
|
| 215 |
+
"""
|
| 216 |
+
),
|
| 217 |
+
dialogs=[llama3_1_custom_tool_call_dialog()],
|
| 218 |
+
notes=textwrap.dedent(
|
| 219 |
+
"""
|
| 220 |
+
- JSON format for providing tools needs name, description and parameters
|
| 221 |
+
- Model responds with `<|python_tag|>` and `<|eom_id|>` as `Environment: ipython` was in the system prompt
|
| 222 |
+
- Instructions for tools added as a user message
|
| 223 |
+
- Only single tool calls are supported as of now
|
| 224 |
+
"""
|
| 225 |
+
),
|
| 226 |
+
),
|
| 227 |
+
# FIXME: This is not working yet as expected
|
| 228 |
+
# UseCase(
|
| 229 |
+
# title="E2E tool call example",
|
| 230 |
+
# description=textwrap.dedent(
|
| 231 |
+
# """
|
| 232 |
+
# Here is an example showing the whole multi-step turn by taking custom tool outputs and passing back to the model.
|
| 233 |
+
# """
|
| 234 |
+
# ),
|
| 235 |
+
# dialogs=[
|
| 236 |
+
# llama3_1_e2e_tool_call_dialog(
|
| 237 |
+
# tool_prompt_format=ToolPromptFormat.function_tag
|
| 238 |
+
# )
|
| 239 |
+
# ],
|
| 240 |
+
# notes="",
|
| 241 |
+
# ),
|
| 242 |
+
"## Example of a user defined tool calling",
|
| 243 |
+
UseCase(
|
| 244 |
+
title="`<function>` based tool calling",
|
| 245 |
+
description=textwrap.dedent(
|
| 246 |
+
"""
|
| 247 |
+
Here is an example of how you could also write custom instructions for model to do zero shot tool calling.
|
| 248 |
+
In this example, we define a custom tool calling format using the `<function>` tag.
|
| 249 |
+
"""
|
| 250 |
+
),
|
| 251 |
+
dialogs=[llama3_1_custom_tool_call_dialog(ToolPromptFormat.function_tag)],
|
| 252 |
+
notes=textwrap.dedent(
|
| 253 |
+
"""
|
| 254 |
+
- In this case, model does NOT respond with `<|python_tag|>` and ends with `<|eot_id|>`
|
| 255 |
+
- Instructions for tools added as a user message
|
| 256 |
+
"""
|
| 257 |
+
),
|
| 258 |
+
),
|
| 259 |
+
]
|
supabase-schema-kxgrcnxnkhctzxzcugca (7).png
ADDED
|
sync-sync.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:277cdaa9e7a1d309336fd65159cc45d9639a040a6999b551999955c70be827a4
|
| 3 |
+
size 1477910
|
transactions.csv
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ID,Date,Description,Amount,Type,Category
|
| 2 |
+
1,2024-07-22,"Monthly Salary",5000,income,Income
|
| 3 |
+
2,2024-07-21,"Groceries from SuperMart",150,expense,Food & Dining
|
| 4 |
+
3,2024-07-20,"Netflix Subscription",15,expense,Entertainment
|
| 5 |
+
4,2024-07-20,"Electricity Bill",75,expense,Utilities
|
| 6 |
+
5,2024-07-19,"Dinner with friends",60,expense,Food & Dining
|
| 7 |
+
6,2024-07-18,"New shoes",120,expense,Shopping
|
| 8 |
+
7,2024-07-15,"Rent Payment",1200,expense,Housing
|
twilio_2FA_recovery_code (1).txt account number .txt
ADDED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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
| 2 |
+
import { Editor } from "@monaco-editor/react";
|
| 3 |
+
import { motion } from "framer-motion";
|
| 4 |
+
import { Download, Wand2, GitBranch, Eye, Layers, Loader2, Bug } from "lucide-react";
|
| 5 |
+
import JSZip from "jszip";
|
| 6 |
+
// NOTE: Use default import for file-saver to avoid ESM named-export errors in some bundlers/CDNs
|
| 7 |
+
import saveAs from "file-saver";
|
| 8 |
+
|
| 9 |
+
// --- shadcn/ui ---
|
| 10 |
+
import { Button } from "@/components/ui/button";
|
| 11 |
+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
| 12 |
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
|
| 13 |
+
import { Textarea } from "@/components/ui/textarea";
|
| 14 |
+
import { Switch } from "@/components/ui/switch";
|
| 15 |
+
import { Label } from "@/components/ui/label";
|
| 16 |
+
|
| 17 |
+
// --- Minimal in-browser sandbox that behaves like a tiny Lovable preview ---
|
| 18 |
+
// We keep a virtual FS with three files and render them into an iframe using a Blob URL.
|
| 19 |
+
|
| 20 |
+
const DEFAULT_HTML = `<!doctype html>
|
| 21 |
+
<html>
|
| 22 |
+
<head>
|
| 23 |
+
<meta charset="utf-8" />
|
| 24 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 25 |
+
<title>My App</title>
|
| 26 |
+
<link rel="stylesheet" href="style.css" />
|
| 27 |
+
</head>
|
| 28 |
+
<body>
|
| 29 |
+
<div id="app"></div>
|
| 30 |
+
<script src="script.js"></script>
|
| 31 |
+
</body>
|
| 32 |
+
</html>`;
|
| 33 |
+
|
| 34 |
+
const DEFAULT_CSS = `:root{--fg:#111827;--bg:#ffffff;--brand:#6366f1}
|
| 35 |
+
*{box-sizing:border-box} body{font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,\n Cantarell,Noto Sans,sans-serif;margin:0;background:var(--bg);color:var(--fg)}
|
| 36 |
+
.container{max-width:960px;margin:40px auto;padding:24px}
|
| 37 |
+
.button{background:var(--brand);color:#fff;border:none;border-radius:12px;padding:12px 16px;cursor:pointer}
|
| 38 |
+
.card{border:1px solid #e5e7eb;border-radius:20px;padding:20px;box-shadow:0 10px 30px rgba(0,0,0,.05)}
|
| 39 |
+
`;
|
| 40 |
+
|
| 41 |
+
const DEFAULT_JS = `const el = document.getElementById('app');
|
| 42 |
+
el.innerHTML = \`
|
| 43 |
+
<div class="container">
|
| 44 |
+
<div class="card">
|
| 45 |
+
<h1>✨ Hello from your Lovable‑style sandbox</h1>
|
| 46 |
+
<p>Edit <code>index.html</code>, <code>style.css</code>, or <code>script.js</code> and see changes live.</p>
|
| 47 |
+
<button class="button" id="btn">Click me</button>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
\`;
|
| 51 |
+
|
| 52 |
+
document.getElementById('btn').addEventListener('click', ()=>{
|
| 53 |
+
alert('It\\'s working!');
|
| 54 |
+
});
|
| 55 |
+
`;
|
| 56 |
+
|
| 57 |
+
// Compose an HTML document with inline <style> and <script type="module"> blocks
|
| 58 |
+
function composeHtml(html, css, js) {
|
| 59 |
+
const withCss = html.replace("</head>", `<style>${css}</style></head>`);
|
| 60 |
+
const withJs = withCss.replace("</body>", `<script type="module">\n${js}\n</script></body>`);
|
| 61 |
+
return withJs;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
function useBlobPreview({ html, css, js }) {
|
| 65 |
+
const urlRef = useRef(null);
|
| 66 |
+
const srcDoc = useMemo(() => composeHtml(html, css, js), [html, css, js]);
|
| 67 |
+
|
| 68 |
+
useEffect(() => {
|
| 69 |
+
if (urlRef.current) URL.revokeObjectURL(urlRef.current);
|
| 70 |
+
const blob = new Blob([srcDoc], { type: 'text/html' });
|
| 71 |
+
const url = URL.createObjectURL(blob);
|
| 72 |
+
urlRef.current = url;
|
| 73 |
+
return () => { if (urlRef.current) URL.revokeObjectURL(urlRef.current); };
|
| 74 |
+
}, [srcDoc]);
|
| 75 |
+
|
| 76 |
+
return urlRef.current;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// --- Heuristic AI scaffolder (offline) ---
|
| 80 |
+
// In production, replace with your AI API call; for now we synthesize boilerplates deterministically from the prompt.
|
| 81 |
+
async function mockGenerateFromPrompt(prompt) {
|
| 82 |
+
await new Promise(r => setTimeout(r, 700));
|
| 83 |
+
const p = prompt.toLowerCase();
|
| 84 |
+
const wantsAuth = /auth|login|signup|sign up|account/.test(p);
|
| 85 |
+
const wantsTodo = /todo|task|kanban|list/.test(p);
|
| 86 |
+
const wantsChat = /chat|message|support|assistant/.test(p);
|
| 87 |
+
|
| 88 |
+
const html = `<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>${escapeHtml(prompt)}</title><link rel="stylesheet" href="style.css"/></head><body><div class="container"><div class="card"><h1>${escapeHtml(prompt)}</h1><div id="root"></div></div></div><script src="script.js"></script></body></html>`;
|
| 89 |
+
|
| 90 |
+
let css = DEFAULT_CSS + (wantsKanban(p) ? `\n.board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}` : '');
|
| 91 |
+
|
| 92 |
+
let js = `const root = document.getElementById('root');\n`;
|
| 93 |
+
if (wantsTodo) {
|
| 94 |
+
js += `let items = [];\nconst ui = () => {\n root.innerHTML = \`<div style="display:flex;gap:8px;margin-bottom:12px"><input id="in" placeholder="Add task"/><button class="button" id="add">Add</button></div><ul>\${items.map((t,i)=>\`<li>\${t} <button data-i=\${i} class=button style="padding:4px 8px;border-radius:8px">x</button></li>\`).join('')}</ul>\`;\n document.getElementById('add').onclick = ()=>{ const v = (document.getElementById('in')).value.trim(); if(v){ items.push(v); ui(); } };\n document.querySelectorAll('[data-i]').forEach(b=> b.onclick = ()=>{ items.splice(+b.dataset.i,1); ui(); });\n}; ui();\n`;
|
| 95 |
+
} else if (wantsChat) {
|
| 96 |
+
js += `let messages = [{role:'system',content:'Welcome!'}];\nconst ui = () => {\n root.innerHTML = \`<div class=card><div id=log style="min-height:160px">\${messages.map(m=>\`<p><strong>\${m.role}:</strong> \${m.content}</p>\`).join('')}</div><div style="display:flex;gap:8px;margin-top:12px"><input id=msg placeholder="Type..."/><button id=send class=button>Send</button></div></div>\`;\n document.getElementById('send').onclick = ()=>{ const v=(document.getElementById('msg')).value.trim(); if(!v) return; messages.push({role:'user',content:v}); messages.push({role:'assistant',content:'(demo reply) '+v}); ui(); };\n}; ui();\n`;
|
| 97 |
+
} else {
|
| 98 |
+
js += DEFAULT_JS;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
if (wantsAuth) {
|
| 102 |
+
js += `\n// Fake auth UI\nconst banner = document.createElement('div');\nbanner.className='card'; banner.style.marginTop='16px';\nbanner.innerHTML = '<h2>Auth (demo)</h2><p>Replace with real auth provider.</p>';\nroot.after(banner);\n`;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
return { html, css, js };
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function wantsKanban(p){ return /kanban|board|columns/.test(p); }
|
| 109 |
+
function escapeHtml(s){ return s.replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"','\'':'''}[c])); }
|
| 110 |
+
|
| 111 |
+
// Fallback downloader if file-saver default import is unavailable in runtime
|
| 112 |
+
function downloadBlob(blob, filename){
|
| 113 |
+
try {
|
| 114 |
+
if (typeof saveAs === 'function') return saveAs(blob, filename);
|
| 115 |
+
} catch (_) {}
|
| 116 |
+
const a = document.createElement('a');
|
| 117 |
+
const url = URL.createObjectURL(blob);
|
| 118 |
+
a.href = url; a.download = filename; a.style.display = 'none';
|
| 119 |
+
document.body.appendChild(a); a.click();
|
| 120 |
+
setTimeout(()=>{ document.body.removeChild(a); URL.revokeObjectURL(url); }, 0);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
export default function App() {
|
| 124 |
+
const [prompt, setPrompt] = useState("Build a todo app with auth and live preview");
|
| 125 |
+
const [files, setFiles] = useState({
|
| 126 |
+
html: DEFAULT_HTML,
|
| 127 |
+
css: DEFAULT_CSS,
|
| 128 |
+
js: DEFAULT_JS,
|
| 129 |
+
});
|
| 130 |
+
const [active, setActive] = useState("html");
|
| 131 |
+
const [autoRun, setAutoRun] = useState(true);
|
| 132 |
+
const [isGenerating, setIsGenerating] = useState(false);
|
| 133 |
+
const [testResults, setTestResults] = useState([]);
|
| 134 |
+
const iframeUrl = useBlobPreview({ html: files.html, css: files.css, js: files.js });
|
| 135 |
+
|
| 136 |
+
// Autorun toggle is intentionally passive: preview refreshes whenever files change
|
| 137 |
+
useEffect(() => { if (!autoRun) {/* reserved for future pause logic */} }, [files, autoRun]);
|
| 138 |
+
|
| 139 |
+
const updateFile = (key, value) => setFiles(prev => ({ ...prev, [key]: value }));
|
| 140 |
+
|
| 141 |
+
const onGenerate = async () => {
|
| 142 |
+
setIsGenerating(true);
|
| 143 |
+
try {
|
| 144 |
+
const out = await mockGenerateFromPrompt(prompt);
|
| 145 |
+
setFiles({ html: out.html, css: out.css, js: out.js });
|
| 146 |
+
setActive("html");
|
| 147 |
+
} finally {
|
| 148 |
+
setIsGenerating(false);
|
| 149 |
+
}
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
const onDownloadZip = async () => {
|
| 153 |
+
const zip = new JSZip();
|
| 154 |
+
zip.file("index.html", files.html);
|
| 155 |
+
zip.file("style.css", files.css);
|
| 156 |
+
zip.file("script.js", files.js);
|
| 157 |
+
const blob = await zip.generateAsync({ type: "blob" });
|
| 158 |
+
downloadBlob(blob, "lovable-clone-mvp.zip");
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
// --- Self tests ---
|
| 162 |
+
const runTests = async () => {
|
| 163 |
+
const results = [];
|
| 164 |
+
|
| 165 |
+
const assert = (name, pass, details = "") => results.push({ name, pass, details });
|
| 166 |
+
|
| 167 |
+
// Test 1: saveAs existence (without invoking downloads)
|
| 168 |
+
assert("file-saver default import is a function", typeof saveAs === 'function');
|
| 169 |
+
|
| 170 |
+
// Test 2: composeHtml injects style and module script
|
| 171 |
+
const testDoc = composeHtml("<html><head></head><body></body></html>", "body{margin:0}", "console.log('ok')");
|
| 172 |
+
assert("composeHtml injects <style> before </head>", /<style>[\s\S]*<\/style><\/head>/.test(testDoc));
|
| 173 |
+
assert("composeHtml injects <script type=module> before </body>", /<script type=\"module\">[\s\S]*<\/script><\/body>/.test(testDoc));
|
| 174 |
+
|
| 175 |
+
// Test 3: JSZip produces non-empty blob
|
| 176 |
+
const z = new JSZip(); z.file("a.txt", "hello");
|
| 177 |
+
const zb = await z.generateAsync({ type: 'blob' });
|
| 178 |
+
assert("JSZip generates a Blob", zb instanceof Blob);
|
| 179 |
+
assert("Generated ZIP size > 0", zb.size > 0, `size=${zb.size}`);
|
| 180 |
+
|
| 181 |
+
// Test 4: mock generator variations
|
| 182 |
+
const t1 = await mockGenerateFromPrompt("todo app");
|
| 183 |
+
assert("Generator returns HTML", typeof t1.html === 'string' && t1.html.includes('<!doctype html>'));
|
| 184 |
+
const t2 = await mockGenerateFromPrompt("simple chat app");
|
| 185 |
+
assert("Chat template contains demo reply hook", /\(demo reply\)/.test(t2.js));
|
| 186 |
+
const t3 = await mockGenerateFromPrompt("include auth");
|
| 187 |
+
assert("Auth banner injected", /Auth \(demo\)/.test(t3.js));
|
| 188 |
+
|
| 189 |
+
setTestResults(results);
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
return (
|
| 193 |
+
<div className="min-h-screen bg-white">
|
| 194 |
+
<div className="mx-auto max-w-7xl p-4 sm:p-6">
|
| 195 |
+
<motion.div initial={{ opacity: 0, y: -10 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.4 }}>
|
| 196 |
+
<header className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
| 197 |
+
<h1 className="text-2xl sm:text-3xl font-semibold tracking-tight">💜 Lovable‑style Builder (MVP)</h1>
|
| 198 |
+
<div className="flex items-center gap-3">
|
| 199 |
+
<Button variant="outline" onClick={onDownloadZip}><Download className="mr-2 h-4 w-4"/>Export ZIP</Button>
|
| 200 |
+
<Button variant="default" onClick={onGenerate} disabled={isGenerating}>
|
| 201 |
+
{isGenerating ? <Loader2 className="mr-2 h-4 w-4 animate-spin"/> : <Wand2 className="mr-2 h-4 w-4"/>}
|
| 202 |
+
Generate
|
| 203 |
+
</Button>
|
| 204 |
+
</div>
|
| 205 |
+
</header>
|
| 206 |
+
</motion.div>
|
| 207 |
+
|
| 208 |
+
<div className="mt-6 grid grid-cols-1 lg:grid-cols-5 gap-4">
|
| 209 |
+
<Card className="lg:col-span-2">
|
| 210 |
+
<CardHeader>
|
| 211 |
+
<CardTitle className="text-lg">Describe your app</CardTitle>
|
| 212 |
+
</CardHeader>
|
| 213 |
+
<CardContent className="space-y-3">
|
| 214 |
+
<Textarea value={prompt} onChange={(e)=>setPrompt(e.target.value)} placeholder="e.g. Build a CRM dashboard with login, kanban board and chat" className="min-h-[120px]"/>
|
| 215 |
+
<div className="flex items-center gap-3">
|
| 216 |
+
<Button onClick={onGenerate} disabled={isGenerating}>
|
| 217 |
+
{isGenerating ? <Loader2 className="mr-2 h-4 w-4 animate-spin"/> : <Wand2 className="mr-2 h-4 w-4"/>}
|
| 218 |
+
Generate App
|
| 219 |
+
</Button>
|
| 220 |
+
<div className="flex items-center gap-2 ml-auto">
|
| 221 |
+
<Switch id="autorun" checked={autoRun} onCheckedChange={setAutoRun}/>
|
| 222 |
+
<Label htmlFor="autorun">Live preview</Label>
|
| 223 |
+
</div>
|
| 224 |
+
</div>
|
| 225 |
+
</CardContent>
|
| 226 |
+
</Card>
|
| 227 |
+
|
| 228 |
+
<Card className="lg:col-span-3">
|
| 229 |
+
<CardHeader>
|
| 230 |
+
<CardTitle className="text-lg flex items-center gap-2"><Layers className="h-5 w-5"/> Code Editor</CardTitle>
|
| 231 |
+
</CardHeader>
|
| 232 |
+
<CardContent>
|
| 233 |
+
<Tabs value={active} onValueChange={setActive} className="w-full">
|
| 234 |
+
<TabsList className="grid w-full grid-cols-3">
|
| 235 |
+
<TabsTrigger value="html">index.html</TabsTrigger>
|
| 236 |
+
<TabsTrigger value="css">style.css</TabsTrigger>
|
| 237 |
+
<TabsTrigger value="js">script.js</TabsTrigger>
|
| 238 |
+
</TabsList>
|
| 239 |
+
<TabsContent value="html">
|
| 240 |
+
<Monaco filename="index.html" language="html" value={files.html} onChange={(v)=>updateFile('html', v ?? '')} />
|
| 241 |
+
</TabsContent>
|
| 242 |
+
<TabsContent value="css">
|
| 243 |
+
<Monaco filename="style.css" language="css" value={files.css} onChange={(v)=>updateFile('css', v ?? '')} />
|
| 244 |
+
</TabsContent>
|
| 245 |
+
<TabsContent value="js">
|
| 246 |
+
<Monaco filename="script.js" language="javascript" value={files.js} onChange={(v)=>updateFile('js', v ?? '')} />
|
| 247 |
+
</TabsContent>
|
| 248 |
+
</Tabs>
|
| 249 |
+
</CardContent>
|
| 250 |
+
</Card>
|
| 251 |
+
</div>
|
| 252 |
+
|
| 253 |
+
<div className="mt-4 grid grid-cols-1 lg:grid-cols-5 gap-4">
|
| 254 |
+
<Card className="lg:col-span-2 order-2 lg:order-1">
|
| 255 |
+
<CardHeader>
|
| 256 |
+
<CardTitle className="text-lg flex items-center gap-2"><GitBranch className="h-5 w-5"/> Next steps</CardTitle>
|
| 257 |
+
</CardHeader>
|
| 258 |
+
<CardContent className="space-y-3 text-sm">
|
| 259 |
+
<ul className="list-disc ml-5 space-y-2">
|
| 260 |
+
<li><strong>AI backend:</strong> Replace <code>mockGenerateFromPrompt</code> with an API route that calls your provider.</li>
|
| 261 |
+
<li><strong>Projects & auth:</strong> Persist files per user (Postgres/Supabase). Add OAuth with NextAuth.</li>
|
| 262 |
+
<li><strong>Realtime collaboration:</strong> Add <code>yjs</code> + <code>y-websocket</code> or Supabase Realtime to sync files across sessions.</li>
|
| 263 |
+
<li><strong>Deploy:</strong> Build adapters for Vercel/Netlify. Ship <code>vercel.json</code> on export.</li>
|
| 264 |
+
<li><strong>Billing:</strong> Stripe subscriptions; gate AI calls and deployments by plan.</li>
|
| 265 |
+
</ul>
|
| 266 |
+
</CardContent>
|
| 267 |
+
</Card>
|
| 268 |
+
|
| 269 |
+
<Card className="lg:col-span-3 order-1 lg:order-2">
|
| 270 |
+
<CardHeader>
|
| 271 |
+
<CardTitle className="text-lg flex items-center gap-2"><Eye className="h-5 w-5"/> Live Preview</CardTitle>
|
| 272 |
+
</CardHeader>
|
| 273 |
+
<CardContent>
|
| 274 |
+
<div className="rounded-2xl overflow-hidden border">
|
| 275 |
+
{iframeUrl ? (
|
| 276 |
+
<iframe title="preview" src={iframeUrl} className="w-full h-[540px]" />
|
| 277 |
+
) : (
|
| 278 |
+
<div className="p-6 text-sm text-gray-500">Preparing preview…</div>
|
| 279 |
+
)}
|
| 280 |
+
</div>
|
| 281 |
+
</CardContent>
|
| 282 |
+
</Card>
|
| 283 |
+
</div>
|
| 284 |
+
|
| 285 |
+
{/* Self-test panel */}
|
| 286 |
+
<div className="mt-4">
|
| 287 |
+
<Card>
|
| 288 |
+
<CardHeader>
|
| 289 |
+
<CardTitle className="text-lg flex items-center gap-2"><Bug className="h-5 w-5"/> Self‑tests</CardTitle>
|
| 290 |
+
</CardHeader>
|
| 291 |
+
<CardContent>
|
| 292 |
+
<div className="flex items-center gap-3 mb-3">
|
| 293 |
+
<Button variant="outline" onClick={runTests}>Run tests</Button>
|
| 294 |
+
</div>
|
| 295 |
+
{testResults.length > 0 && (
|
| 296 |
+
<ul className="space-y-1 text-sm">
|
| 297 |
+
{testResults.map((t, i) => (
|
| 298 |
+
<li key={i} className={t.pass ? "text-green-700" : "text-red-700"}>
|
| 299 |
+
{t.pass ? "✓" : "✗"} {t.name}{t.details ? ` — ${t.details}` : ""}
|
| 300 |
+
</li>
|
| 301 |
+
))}
|
| 302 |
+
</ul>
|
| 303 |
+
)}
|
| 304 |
+
</CardContent>
|
| 305 |
+
</Card>
|
| 306 |
+
</div>
|
| 307 |
+
|
| 308 |
+
</div>
|
| 309 |
+
</div>
|
| 310 |
+
);
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
function Monaco({ filename, language, value, onChange }){
|
| 314 |
+
return (
|
| 315 |
+
<div className="h-[420px] rounded-xl overflow-hidden border">
|
| 316 |
+
<Editor
|
| 317 |
+
path={filename}
|
| 318 |
+
height="420px"
|
| 319 |
+
defaultLanguage={language}
|
| 320 |
+
language={language}
|
| 321 |
+
value={value}
|
| 322 |
+
onChange={onChange}
|
| 323 |
+
options={{
|
| 324 |
+
fontSize: 14,
|
| 325 |
+
minimap: { enabled: false },
|
| 326 |
+
roundedSelection: true,
|
| 327 |
+
scrollBeyondLastLine: false,
|
| 328 |
+
automaticLayout: true,
|
| 329 |
+
wordWrap: 'on',
|
| 330 |
+
tabSize: 2,
|
| 331 |
+
}}
|
| 332 |
+
/>
|
| 333 |
+
</div>
|
| 334 |
+
);
|
| 335 |
+
}
|