This project is a Golang-based tool that utilizes OpenAI's GPT-3.5-turbo model to generate code and folder structures for a given topic. The project automates the process of creating a new Golang project by taking user input, generating the corresponding code and folder structure, and setting up the project directory.
- Dynamic Code Generation: Automatically generates Golang code based on the provided topic.
- Folder Structure Creation: Builds a project folder structure tailored to the given topic.
- Integration with OpenAI API: Uses the GPT-3.5-turbo model for generating code and folder structures.
- Environment Variable Management: Loads the OpenAI API key from a
.env
file.
-
Golang installed on your system.
-
A valid OpenAI API key.
-
A
.env
file in the project root directory with the following content:API_KEY=your_openai_api_key
- nput Topic: The user provides a topic for which the project needs to be generated.
- API Request: The topic is sent to OpenAI’s GPT-3.5-turbo model via an API request.
- Response Handling: The model returns generated code and folder structure as a response.
- File Writing: The code is saved in code/code.go, and the folder structure is saved in code/output.txt.
- Folder Structure Creation: The folder structure is created in the project/ directory.
-
Clone the Repository:
git clone https://github.com/yourusername/ai-golang-generator.git cd ai-golang-generator
-
Set Up Environment Variables:
Create a
.env
file in the root directory:API_KEY=your_openai_api_key
-
Run the Application:
Execute the following command to start the application:
go run main.go
-
Enter a Topic:
When prompted, enter the topic for which you want to generate the project:
Enter a topic: ecommerce platform
-
View Generated Files:
- The generated code will be in
code/code.go
. - The folder structure will be detailed in
code/output.txt
. - The folder structure will created under the
project/ directory
.
- The generated code will be in