game1 / app.py
biya-2007's picture
Update app.py
de8c72a verified
raw
history blame
1.04 kB
import streamlit as st
from transformers import pipeline
# Title and description
st.set_page_config(page_title="AI Puzzle Solver", layout="centered")
st.title("🧠 AI Puzzle Solver Game")
st.write("Enter any riddle or logic puzzle, and the AI will try to solve it!")
# Load Hugging Face model
@st.cache_resource
def load_model():
return pipeline("text-generation", model="mistralai/Mistral-7B-Instruct", max_new_tokens=100)
generator = load_model()
# User input
puzzle_input = st.text_area("Enter your puzzle or riddle:")
# Solve button
if st.button("Solve Puzzle"):
if puzzle_input.strip() == "":
st.warning("Please enter a puzzle to solve.")
else:
with st.spinner("Thinking..."):
prompt = f"Solve this riddle or puzzle: {puzzle_input}\nAnswer:"
result = generator(prompt)[0]['generated_text']
# Extract the answer after "Answer:"
answer = result.split("Answer:")[-1].strip()
st.success("βœ… AI's Answer:")
st.markdown(f"**{answer}**")