from typing import List, Dict, Optional from cust_types import ( Code, Prompt, AppType, File, Space, Tutorial, App, WebApp, GradioApp, StreamlitApp, ReactApp, Code, ) def createLlamaPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt for a Llama model to create a web application. """ prompt = f""" I need you to help me create a {app_type} web application. The application name is: {app_name} The application description is: {app_description} The application features are: {app_features} The application dependencies are: {app_dependencies} The application space is: {app_space} The application tutorial is: {app_tutorial} Please generate the code for the application. """ return Prompt(prompt=prompt) def createSpace( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Space: """ Generates a space for a web application. """ space = f""" {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} """ return Space(space=space) def isPythonOrGradioAppPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt to determine if a web application is a Python or Gradio application. """ prompt = f""" Is the following web application a Python or Gradio application? {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} Please answer with either "Python" or "Gradio". """ return Prompt(prompt=prompt) def isReactAppPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt to determine if a web application is a React application. """ prompt = f""" Is the following web application a React application? {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} Please answer with either "Yes" or "No". """ return Prompt(prompt=prompt) def isStreamlitAppPrompt( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> Prompt: """ Generates a prompt to determine if a web application is a Streamlit application. """ prompt = f""" Is the following web application a Streamlit application? {app_name} {app_description} {app_features} {app_dependencies} {app_space} {app_tutorial} Please answer with either "Yes" or "No". """ return Prompt(prompt=prompt) def getWebApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> WebApp: """ Generates code for a web application. """ code = f"""
{app_description}
""" return WebApp(code=code, language="html") def getGradioApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> GradioApp: """ Generates code for a Gradio application. """ code = f""" import gradio as gr def greet(name): return f"Hello, {name}!" demo = gr.Interface(greet, "text", "text") if __name__ == "__main__": demo.launch() """ return GradioApp(code=code, language="python") def getReactApp( app_type: AppType, app_name: str, app_description: str, app_features: List[str], app_dependencies: List[str], app_space: Optional[Space] = None, app_tutorial: Optional[Tutorial] = None, ) -> ReactApp: """ Generates code for a React application. """ code = f""" import React from 'react'; function App() {{ return ({app_description}