Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from groq import Groq
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="Q-Audit – Qubic Smart Contract Auditor", page_icon="🛡️")
|
| 5 |
+
st.title("🛡️ Q-Audit – C++ Smart Contract Auditor for Qubic")
|
| 6 |
+
|
| 7 |
+
client = Groq(api_key="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")
|
| 8 |
+
|
| 9 |
+
user_code = st.text_area("Paste your Qubic C++ Smart Contract Code:")
|
| 10 |
+
|
| 11 |
+
if st.button("🔍 Run AI Audit"):
|
| 12 |
+
if user_code.strip() == "":
|
| 13 |
+
st.warning("Please paste some code first.")
|
| 14 |
+
else:
|
| 15 |
+
with st.spinner("Analyzing with Groq AI..."):
|
| 16 |
+
prompt = f"Audit this C++ smart contract for bugs, risks, or improvements:\n\n{user_code}"
|
| 17 |
+
completion = client.chat.completions.create(
|
| 18 |
+
model="llama3-70b-8192",
|
| 19 |
+
messages=[{"role": "user", "content": prompt}],
|
| 20 |
+
temperature=0.5,
|
| 21 |
+
)
|
| 22 |
+
st.subheader("🧠 AI Feedback:")
|
| 23 |
+
st.write(completion.choices[0].message.content)
|
| 24 |
+
|
| 25 |
+
if st.button("📝 Save to Qubic"):
|
| 26 |
+
st.success("✅ (Mock) Code submitted to Qubic smart contract.")
|