Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,12 @@ class GPT5Model:
|
|
11 |
def __init__(self, api_key):
|
12 |
self.api_key = api_key
|
13 |
self.system_prompt = "You are GPT-5, the most advanced AI model available. Answer accurately, intelligently, and helpfully."
|
|
|
14 |
|
15 |
def generate_response(self, prompt):
|
|
|
|
|
|
|
16 |
headers = {
|
17 |
"Authorization": f"Bearer {self.api_key}",
|
18 |
"Content-Type": "application/json"
|
@@ -24,6 +28,9 @@ class GPT5Model:
|
|
24 |
}
|
25 |
import requests
|
26 |
response = requests.post("https://api.pplx.ai/v1/generate", json=data, headers=headers)
|
|
|
|
|
|
|
27 |
return response.json()["choices"][0]["text"].strip()
|
28 |
""",
|
29 |
"gpt5_utils.py": """
|
@@ -58,12 +65,12 @@ def generate_response(prompt):
|
|
58 |
|
59 |
# Create Gradio interface
|
60 |
with gr.Blocks() as demo:
|
61 |
-
gr.Markdown("# GPT5 Model Interface")
|
62 |
with gr.Row():
|
63 |
with gr.Column():
|
64 |
prompt = gr.Textbox(label="Enter your prompt (1 character only)", placeholder="Enter a single character")
|
65 |
generate_btn = gr.Button("Generate Response")
|
66 |
-
output = gr.Textbox(label="Generated Response")
|
67 |
|
68 |
generate_btn.click(generate_response, inputs=prompt, outputs=output)
|
69 |
|
|
|
11 |
def __init__(self, api_key):
|
12 |
self.api_key = api_key
|
13 |
self.system_prompt = "You are GPT-5, the most advanced AI model available. Answer accurately, intelligently, and helpfully."
|
14 |
+
self.locked = False
|
15 |
|
16 |
def generate_response(self, prompt):
|
17 |
+
if self.locked:
|
18 |
+
return "Access locked. Only one prompt is allowed per session."
|
19 |
+
|
20 |
headers = {
|
21 |
"Authorization": f"Bearer {self.api_key}",
|
22 |
"Content-Type": "application/json"
|
|
|
28 |
}
|
29 |
import requests
|
30 |
response = requests.post("https://api.pplx.ai/v1/generate", json=data, headers=headers)
|
31 |
+
|
32 |
+
# Lock after first request
|
33 |
+
self.locked = True
|
34 |
return response.json()["choices"][0]["text"].strip()
|
35 |
""",
|
36 |
"gpt5_utils.py": """
|
|
|
65 |
|
66 |
# Create Gradio interface
|
67 |
with gr.Blocks() as demo:
|
68 |
+
gr.Markdown("# GPT5 Model Interface (One Prompt Only)")
|
69 |
with gr.Row():
|
70 |
with gr.Column():
|
71 |
prompt = gr.Textbox(label="Enter your prompt (1 character only)", placeholder="Enter a single character")
|
72 |
generate_btn = gr.Button("Generate Response")
|
73 |
+
output = gr.Textbox(label="Generated Response", interactive=False)
|
74 |
|
75 |
generate_btn.click(generate_response, inputs=prompt, outputs=output)
|
76 |
|