Spaces:
Running
Running
acecalisto3
commited on
Commit
•
5896153
1
Parent(s):
86363d9
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import subprocess
|
4 |
-
import random
|
5 |
-
import string
|
6 |
from huggingface_hub import cached_download, hf_hub_url
|
7 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
8 |
import black
|
@@ -22,9 +20,12 @@ def chat_interface(input_text):
|
|
22 |
"""
|
23 |
# Load the appropriate language model from Hugging Face
|
24 |
model_name = 'google/flan-t5-xl' # Choose a suitable model
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
28 |
|
29 |
# Generate chatbot response
|
30 |
response = generator(input_text, max_length=50, num_return_sequences=1, do_sample=True)[0]['generated_text']
|
@@ -167,7 +168,7 @@ if st.button("Run"):
|
|
167 |
|
168 |
# Code Editor Interface
|
169 |
st.header("Code Editor")
|
170 |
-
code_editor = st.text_area("Write your code:",
|
171 |
if st.button("Format & Lint"):
|
172 |
formatted_code, lint_message = code_editor_interface(code_editor)
|
173 |
st.code(formatted_code, language="python")
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import subprocess
|
|
|
|
|
4 |
from huggingface_hub import cached_download, hf_hub_url
|
5 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
6 |
import black
|
|
|
20 |
"""
|
21 |
# Load the appropriate language model from Hugging Face
|
22 |
model_name = 'google/flan-t5-xl' # Choose a suitable model
|
23 |
+
try:
|
24 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
26 |
+
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
27 |
+
except EnvironmentError as e:
|
28 |
+
return f'Error loading model: {e}'
|
29 |
|
30 |
# Generate chatbot response
|
31 |
response = generator(input_text, max_length=50, num_return_sequences=1, do_sample=True)[0]['generated_text']
|
|
|
168 |
|
169 |
# Code Editor Interface
|
170 |
st.header("Code Editor")
|
171 |
+
code_editor = st.text_area("Write your code:", height=300)
|
172 |
if st.button("Format & Lint"):
|
173 |
formatted_code, lint_message = code_editor_interface(code_editor)
|
174 |
st.code(formatted_code, language="python")
|