import streamlit as st import requests import os # Set page title and layout st.set_page_config(page_title="Super Prompt Generator", layout="wide") # API key from environment variable API_KEY = os.environ.get("NEBIUS_API_KEY") if not API_KEY: st.error("API key not found. Please set the `NEBIUS_API_KEY` environment variable.") # Function to call Nebius API def generate_response(prompt, api_key): api_url = "https://api.studio.nebius.ai/v1/chat/completions" headers = {"Authorization": f"Bearer {api_key}"} payload = { "model": "microsoft/Phi-3.5-mini-instruct", "messages": [ {"role": "system", "content": """You are a prompt enhancer your work is to enhance the prompt without changing the essence and only provide the enhance prompt and nothing else"""}, {"role": "user", "content": prompt} ], "temperature": 0.9, "max_tokens": 200, "top_p": 0.9, "top_k": 50 } response = requests.post(api_url, headers=headers, json=payload) if response.status_code == 200: return response.json() else: st.error(f"Error: {response.status_code}, {response.text}") return None # Custom CSS for centering st.markdown( """ """, unsafe_allow_html=True ) # Centered title #st.markdown('
{assistant_message}