GenAI CLI
TL;DR - Create Microservice from Natural Language Prompt using CLI
API Logic Server / GenAI provides CLI commands that accepts a Natural Language prompt (e.g, CRM system), and produces:
- a Microservice: an Admin App and a JSON:API
- a project you can download and customize in your IDE using rules and python
- deploy as a container using automatically generated scripts.
API Logic Server / GenAI uses:
- GenAI services for data model creation, and
- API Logic Server for project creation.
You can also use GenAI services via the GenAI WebSite.
Overview
To use GenAI to create projects
- Establish your virtual environment (suggestion: use the Manager)
- Provide a prompt in either a file (
als genai
), or a CLI argument (als genai-create
):
als genai --using=system/genai/examples/genai_demo/genai_demo.prompt
# or, provide the prompt in an **quoted** argument:
als genai-create --project-name='customer_orders' --using='customer orders'
Projects are created in the currrent working directory, here, the manager.
Conversations vs. resubmit
You can review created projects by using the app, and/or reviewing the data model. Of course, it's simple to resubmit a new prompt and re-create the project.
However, this will be completely new rendition of your idea, and it may change things you like about the project. Conversations enable you to keep what you already have, while making desired changed.
When you create a project, the API Logic Server / GenAI saves your prompt and response in a conversatation-directory. Conversations are saved in 2 different conversations-directories:
-
the manager's
system/genai/temp/<project>
directory -
the created project's
doc
directory.
You can iterate interative prompts, or by adding files to the manager's system/genai/temp/<project>
directory.
Conversations - Interative
The figure below creates and iterates a project, using the manager:
als genai-create -project-name=conv —-using='customer orders'
als genai-iterate —-project-name=conv —using='add payments'
Conversations - Files
Alternatively, you can iterate projects by adding files to Manager's temp directory:
als genai-create --project-name=conv --using='customer orders'
echo "add payments" | cat >> system/genai/temp/conv/conv_002.prompt
als genai --using=system/genai/temp/conv
The project name can be provided with the --project-name
argument (as of release 11.02.01). If omitted, it is defaulted to the last node of the directory name, here, conv.
This will recreate the project based on the existing context. See the next section, below.
Customized Project Sync
In the prior section, the result was a recreated project. If you have customized the project, you can preserve your customizations as follows:
- Copy
database/models.py
anddb.sqlite
from the GenAI to your customized project -
In your customized project, use
als rebuild-from-model
- For further information, see Database Design Changes.
Appendices
GenAI and API Logic Server
GenAI is part of API Logic Server. As shown below:
-
API Logic Server can create microservices (Admin Apps, APIs, and Logic) from databases.
-
It can also create microservices from database models (
als create --from-model=my_model.py
) -
GenAI
- Use ChatGPT APIs, and creates a model file from the response
- Submits that to
als create --from-model=my_model.py
Error Revovery
AI results are not consistent, so you may sometimes need to correct errors and resume. This requires a bit of background about genai processing.
GemAI Processing
genai
processing is shown below (internal steps denoted in grey):
-
You create your.prompt file, and invoke
als genai --using=your.prompt
. genai then creates your project as follows:a. Submits your prompt to the
ChatGPT API
b. Writes the response to file, so you can correct and retry if anything goes wrong
c. Extracts model.py from the response
d. Invokes
als create-from-model
, which creates the database and your project -
Your created project is opened in your IDE, ready to execute and customize.
a. Review
Sample-Genai.md
, Explore Customizations.
Recovery options
AI somtimes fails - here's how to recover after your correct the response or the model file.
From the Model File
You can find the models file at system/genai/temp/model.py
. You can correct the model file, and then run:
als create --project-name=genai_demo --from-model=system/genai/temp/create_db_models.py --db-url=sqlite
From the Response
Or, correct the chatgpt response, and