Spaces:
Running
Running
acecalisto3
commited on
Commit
•
5bdcc75
1
Parent(s):
52cf5c0
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import docker
|
|
9 |
from huggingface_hub import HfApi, create_repo
|
10 |
import importlib
|
11 |
import os
|
12 |
-
from transformers import
|
13 |
|
14 |
# Initialize Flask app
|
15 |
app = Flask(__name__)
|
@@ -121,15 +121,12 @@ plugin_manager.load_plugins()
|
|
121 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/CodeGPT-small-py", clean_up_tokenization_spaces=True)
|
122 |
|
123 |
# Initialize the model
|
124 |
-
model =
|
125 |
|
126 |
# Initialize the pipeline
|
127 |
code_generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
128 |
|
129 |
# AI Assistant
|
130 |
-
model = AutoModelForSequenceClassification.from_pretrained("microsoft/CodeGPT-small-py")
|
131 |
-
codex_pipeline = pipeline("text-generation", model=model)
|
132 |
-
|
133 |
hf_api = HfApi()
|
134 |
|
135 |
def generate_app(user_idea, project_name):
|
@@ -142,7 +139,7 @@ def generate_app(user_idea, project_name):
|
|
142 |
|
143 |
# Generate code using Codex
|
144 |
prompt = f"""Create a simple Streamlit app for the project named '{project_name}'. The app should display the following summary: '{summary}'."""
|
145 |
-
generated_code =
|
146 |
|
147 |
# Save the generated code to a file in the project directory
|
148 |
with open(os.path.join(project_path, "app.py"), "w") as f:
|
|
|
9 |
from huggingface_hub import HfApi, create_repo
|
10 |
import importlib
|
11 |
import os
|
12 |
+
from transformers import AutoModelForCausalLM, pipeline, AutoTokenizer
|
13 |
|
14 |
# Initialize Flask app
|
15 |
app = Flask(__name__)
|
|
|
121 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/CodeGPT-small-py", clean_up_tokenization_spaces=True)
|
122 |
|
123 |
# Initialize the model
|
124 |
+
model = AutoModelForCausalLM.from_pretrained("microsoft/CodeGPT-small-py") # Use a public model
|
125 |
|
126 |
# Initialize the pipeline
|
127 |
code_generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
128 |
|
129 |
# AI Assistant
|
|
|
|
|
|
|
130 |
hf_api = HfApi()
|
131 |
|
132 |
def generate_app(user_idea, project_name):
|
|
|
139 |
|
140 |
# Generate code using Codex
|
141 |
prompt = f"""Create a simple Streamlit app for the project named '{project_name}'. The app should display the following summary: '{summary}'."""
|
142 |
+
generated_code = code_generator(prompt, max_length=516)[0]['generated_text']
|
143 |
|
144 |
# Save the generated code to a file in the project directory
|
145 |
with open(os.path.join(project_path, "app.py"), "w") as f:
|