import requests import gradio as gr # Configuration (Update this with your ngrok URL) API_URL = "https://5b9f-154-161-168-18.ngrok-free.app/v1/chat/completions" HEADERS = {"Content-Type": "application/json"} # Store the last prompt last_prompt = "" def generate(prompt): """Generation function with prompt storage""" global last_prompt last_prompt = prompt try: response = requests.post( API_URL, headers=HEADERS, json={ "model": "TinyLlama-1.1B-Chat-v1.0", "messages": [{"role": "user", "content": prompt}], "max_tokens": 256, "temperature": 0.7 }, timeout=30 ) return response.json()['choices'][0]['message']['content'] except Exception as e: return f"Error: {str(e)}" def regenerate(): """Regenerate response using last prompt""" if last_prompt: return generate(last_prompt) return "No previous prompt to regenerate" # Gradio UI with gr.Blocks(title="Karlson Achegeba GPT", theme=gr.themes.Soft(primary_hue="blue")) as app: with gr.Column(elem_classes=["center-container"]): # Header gr.Markdown("""
My very first trained model