Spaces:
Sleeping
Sleeping
File size: 944 Bytes
089fa7f ed5f9f2 089fa7f ed5f9f2 3c6c7a6 089fa7f ed5f9f2 089fa7f 033322a 8015028 ed5f9f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
from code_editor import code_editor
import random
import time
import requests
import os
API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
headers = {"Authorization": f"Bearer {os.environ.get('API_KEY')}"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
st.markdown(f":blue_background[Create] Code With AI")
st.write("Real-time Code Generation & Code Editor")
lang = st.selectbox("Choose Language", ["Python", "Javascript", "HTML", "C++", "CS", "Markdown", "Java", "C", "Go", "Ruby"])
code = code_editor("Your Code Here", height=[1, 200], lang=lang)
if st.button("Run AI"):
output = query({
"inputs": f"Can you please correct and improve this code, as output give only updated code; code to correct and improve: {code}",
})
if output:
code = code_editor(output, height=[1, 200], lang=lang) |