Team Ai
Apppublic

jaothan/podman_llamacpp_python

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py51 linesDownload Raw Back to base
1import subprocess2import sys3 4# Function to install a package using pip5def install(package):6    subprocess.check_call([sys.executable, "-m", "pip", "install", package])7 8# Install Streamlit if it's not already installed9try:10    import streamlit as st11except ImportError:12    print("Streamlit is not installed. Installing now...")13    install("streamlit")14    import streamlit as st15 16# Streamlit app code17st.set_page_config(page_title="Hello World App")18st.title("Hello, World!")19st.write("This is a Streamlit app that says 'Hello, World!'.")20 21# Add some interactivity (optional)22user_name = st.text_input("Enter your name:")23if user_name:24    st.write(f"Hello, {user_name}!")25 26try:27    import Flask, request, jsonify 28except ImportError:29    print("Flask is not installed. Installing now...")30    install("flask")31    from flask import Flask, request, jsonify32 33app = Flask(__name__)34 35@app.route("/generate", methods=["POST"])36def generate():37    data = request.json38    prompt = data.get("prompt", "")39    # Simulate a response from the model40    response = f"Generated response for: {prompt}"41    return jsonify({"response": response})42 43if __name__ == "__main__":44    app.run(host="0.0.0.0", port=8000)45 46#Run the server:47#```bash48##python model_server.py49#```50 51