Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,15 +2,27 @@ import streamlit as st
|
|
| 2 |
from code_editor import code_editor
|
| 3 |
import random
|
| 4 |
import time
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
word = None
|
| 9 |
-
while l:
|
| 10 |
-
word = random.choice(words)
|
| 11 |
-
time.sleep(5)
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
st.write("Real-time Code Generation & Code Editor")
|
| 15 |
lang = st.select_box("Choose Language", ["Python", "Javascript", "HTML", "C++", "C#", "Markdown", "Java", "C", "Go", "Ruby"])
|
| 16 |
-
code = code_editor("# Your Code Here", height=[1, 200], lang=lang)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from code_editor import code_editor
|
| 3 |
import random
|
| 4 |
import time
|
| 5 |
+
import requests
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
+
API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 9 |
+
headers = {"Authorization": f"Bearer {os.environ.get("API_KEY")}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
def query(payload):
|
| 12 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 13 |
+
return response.json()
|
| 14 |
+
|
| 15 |
+
output = query({
|
| 16 |
+
"inputs": "Can you please let us know more details about your ",
|
| 17 |
+
})
|
| 18 |
+
|
| 19 |
+
st.markdown(f":blue_background[Create] Code With AI")
|
| 20 |
st.write("Real-time Code Generation & Code Editor")
|
| 21 |
lang = st.select_box("Choose Language", ["Python", "Javascript", "HTML", "C++", "C#", "Markdown", "Java", "C", "Go", "Ruby"])
|
| 22 |
+
code = code_editor("# Your Code Here", height=[1, 200], lang=lang)
|
| 23 |
+
if st.button("Run AI"):
|
| 24 |
+
output = query({
|
| 25 |
+
"inputs": f"Can you please correct and improve this code, as output give only updated code; code to correct and improve: {code}",
|
| 26 |
+
})
|
| 27 |
+
if output:
|
| 28 |
+
code = code_editor(output, height=[1, 200], lang=lang)
|