Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
+
from gpt4all import GPT4All
|
| 4 |
+
|
| 5 |
+
st.set_page_config(page_title="AutoGPT with Streamlit", layout="wide")
|
| 6 |
+
|
| 7 |
+
st.title("🤖 AutoGPT Agent (Docker + Streamlit)")
|
| 8 |
+
st.write("Powered by **DeepSeek + GPT4All**")
|
| 9 |
+
|
| 10 |
+
# Sidebar setup
|
| 11 |
+
st.sidebar.header("Settings")
|
| 12 |
+
model_choice = st.sidebar.selectbox("Choose Model", ["DeepSeek", "GPT4All"])
|
| 13 |
+
goal = st.text_area("Enter your AI Goal:", placeholder="e.g., Research 5 AI trends and summarize")
|
| 14 |
+
|
| 15 |
+
if st.button("Run Agent"):
|
| 16 |
+
if model_choice == "DeepSeek":
|
| 17 |
+
model_name = "deepseek-ai/deepseek-coder-1.3b-base"
|
| 18 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 19 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 20 |
+
inputs = tokenizer(goal, return_tensors="pt")
|
| 21 |
+
output = model.generate(**inputs, max_new_tokens=200)
|
| 22 |
+
result = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 23 |
+
|
| 24 |
+
elif model_choice == "GPT4All":
|
| 25 |
+
gpt4all = GPT4All("gpt4all-lora-quantized.bin")
|
| 26 |
+
with gpt4all.chat_session():
|
| 27 |
+
result = gpt4all.generate(goal, max_tokens=200)
|
| 28 |
+
|
| 29 |
+
else:
|
| 30 |
+
result = "No model selected."
|
| 31 |
+
|
| 32 |
+
st.subheader("Agent Output")
|
| 33 |
+
st.write(result)
|