Spaces:
Running
Running
File size: 2,661 Bytes
1fd1980 744a700 49c3b81 e63b380 744a700 1fd1980 49c3b81 9e92d26 49c3b81 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 744a700 1fd1980 49c3b81 1fd1980 744a700 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AI Descriptor Agent</title>
<script type="module" crossorigin src="https://gradio-lite-previews.s3.amazonaws.com/PINNED_HF_HUB/dist/lite.js"></script>
<link rel="stylesheet" href="https://gradio-lite-previews.s3.amazonaws.com/PINNED_HF_HUB/dist/lite.css" />
<style>
body {
background-color: #0f172a;
color: #f8fafc;
font-family: 'Inter', system-ui, -apple-system, sans-serif;
margin: 0;
padding: 20px;
}
</style>
</head>
<body>
<gradio-lite theme="dark">
<gradio-requirements>
openai==1.39.0
</gradio-requirements>
<gradio-file name="app.py" entrypoint>
import gradio as gr
from openai import OpenAI
def run_descriptor_agent(openai_key, user_prompt):
if not openai_key:
return "Please enter your OpenAI API Key first!"
try:
# Initialize the OpenAI client inside the browser environment
client = OpenAI(api_key=openai_key)
# Simple agent descriptor call
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a professional AI Descriptor agent. Provide structured, clear summaries and descriptions based on user requests."},
{"role": "user", "content": user_prompt}
]
)
return response.choices[0].message.content
except Exception as e:
return f"Error: {str(e)}"
# Define the Gradio UI
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="indigo")) as demo:
gr.Markdown("# 🤖 AI Descriptor Agent")
gr.Markdown("This runs entirely in your browser. Your OpenAI key is safe and is not stored anywhere on Hugging Face.")
with gr.Row():
key_input = gr.Textbox(
label="1. Enter your OpenAI API Key",
placeholder="sk-proj-...",
type="password"
)
with gr.Row():
prompt_input = gr.Textbox(
label="2. Ask the Agent anything",
placeholder="Describe what you want me to analyze..."
)
submit_btn = gr.Button("Run Agent", variant="primary")
output_text = gr.Textbox(label="Agent Response", interactive=False)
submit_btn.click(
fn=run_descriptor_agent,
inputs=[key_input, prompt_input],
outputs=output_text
)
demo.launch()
</gradio-file>
</gradio-lite>
</body>
</html> |