Spaces:
Running
Running
Updated space
Browse files- README.md +3 -3
- app.py +9 -28
- index.html +6 -2
README.md
CHANGED
@@ -4,15 +4,15 @@ emoji: π
|
|
4 |
colorFrom: green
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
app_port: 7860
|
11 |
license: wtfpl
|
12 |
-
short_description:
|
13 |
---
|
14 |
|
15 |
-
#
|
16 |
Welcome to GPT-4O-mini! This space acts as a proxy to the OpenAI API, letting you interact with models to generate responses, images, and more. Here's a quick rundown:
|
17 |
|
18 |
### Key Parts:
|
|
|
4 |
colorFrom: green
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.41.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
app_port: 7860
|
11 |
license: wtfpl
|
12 |
+
short_description: A OpenAI API proxy.
|
13 |
---
|
14 |
|
15 |
+
# A OpenAI API proxy.
|
16 |
Welcome to GPT-4O-mini! This space acts as a proxy to the OpenAI API, letting you interact with models to generate responses, images, and more. Here's a quick rundown:
|
17 |
|
18 |
### Key Parts:
|
app.py
CHANGED
@@ -26,24 +26,6 @@ API_BASE = "env"# or "openai"
|
|
26 |
api_key = os.environ['OPENAI_API_KEY']
|
27 |
base_url = os.environ.get('OPENAI_BASE_URL', "https://api.openai.com/v1")
|
28 |
def_models = '["gpt-4", "gpt-4-0125-preview", "gpt-4-0314", "gpt-4-0613", "gpt-4-1106-preview", "gpt-4-1106-vision-preview", "gpt-4-32k-0314", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-turbo-preview", "gpt-4-vision-preview", "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-mini", "gpt-4o-mini-2024-07-18"]'
|
29 |
-
consentPrompt = """[CONSENT] You must agree to the terms to use this application.
|
30 |
-
|
31 |
-
```
|
32 |
-
By using our application, which integrates with OpenAI's API, you acknowledge and agree to the following terms regarding the data you provide:
|
33 |
-
|
34 |
-
1. Data Collection: This application may collect data shared through the Gradio endpoint or the API endpoint.
|
35 |
-
2. Privacy: Please avoid sharing any personal information.
|
36 |
-
3. Data Retention and Removal: Data files are deleted every 30 days, and the API is restarted to ensure data clearance.
|
37 |
-
4. Scope of Data Collected: The data collected includes model settings, chat history, and responses from the model. This applies only to 'chat' endpoints (Gradio and API) and excludes moderation checks.
|
38 |
-
5. Data Usage: The collected data is periodically reviewed, and if any concerning activity is detected, the code is updated accordingly.
|
39 |
-
|
40 |
-
By continuing to use our application, you explicitly consent to the collection, use, and potential sharing of your data as described above. If you disagree with our data collection, usage, and sharing practices, we advise you not to use our application.
|
41 |
-
```
|
42 |
-
|
43 |
-
To agree to user consent, please do the followings:
|
44 |
-
1. Scroll down to find the section labeled 'Additional Inputs' below this page.
|
45 |
-
2. Find and click the check box that says 'User Consent [I agree to the terms and conditions. (can't make a button for it)]'.
|
46 |
-
3. After agreeing, click either the `ποΈ Clear` button, the `β©οΈ Undo` button, or the `π Retry` button located above the message input area.""";
|
47 |
fakeToolPrompt = """[System: You have ability to generate images, via tools provided to you by system.
|
48 |
To call a tool you need to write a json in a empty line; like writing it at the end of message.
|
49 |
To generate a image; you need to follow this example JSON:
|
@@ -458,13 +440,8 @@ async def respond(
|
|
458 |
fakeTool,
|
459 |
calcBeta,
|
460 |
searchBeta,
|
461 |
-
betterSystemPrompt
|
462 |
-
consent
|
463 |
):
|
464 |
-
if not consent:
|
465 |
-
yield consentPrompt
|
466 |
-
return
|
467 |
-
|
468 |
messages = [];
|
469 |
if fakeTool:
|
470 |
messages.append({"role": "system", "content": fakeToolPrompt});
|
@@ -582,11 +559,11 @@ async def respond(
|
|
582 |
|
583 |
|
584 |
handleApiKeys();loadModels();checkModels();loadENV();
|
585 |
-
lastUpdateMessage = "
|
586 |
demo = gr.ChatInterface(
|
587 |
respond,
|
588 |
title="GPT-4O-mini",
|
589 |
-
description=f"A
|
590 |
multimodal=True,
|
591 |
additional_inputs=[
|
592 |
gr.Textbox(value="You are a helpful assistant. You are an OpenAI GPT model. Please adhere to OpenAI's usage policies and guidelines. Ensure your responses are accurate, respectful, and within the scope of OpenAI's rules.", label="System message"),
|
@@ -598,14 +575,18 @@ demo = gr.ChatInterface(
|
|
598 |
gr.Checkbox(label="Randomize Seed", value=True),
|
599 |
gr.Checkbox(label="FakeTool [Image generation beta]", value=True),
|
600 |
gr.Checkbox(label="FakeTool [Calculator beta]", value=True),
|
601 |
-
gr.Checkbox(label="FakeTool [Search engine beta (Warning; each query takes up to 30 seconds)]", value=
|
602 |
gr.Checkbox(label="Better system prompt (ignores the system prompt set by user.)", value=True),
|
603 |
-
gr.Checkbox(label="User Consent [I agree to the terms and conditions. (can't make a button for it)]", value=("--dev" in sys.argv or "-d" in sys.argv))
|
604 |
],
|
|
|
605 |
)
|
606 |
|
607 |
app = FastAPI()
|
608 |
|
|
|
|
|
|
|
|
|
609 |
@app.get("/api/v1/docs")
|
610 |
def html():
|
611 |
return FileResponse("index.html")
|
|
|
26 |
api_key = os.environ['OPENAI_API_KEY']
|
27 |
base_url = os.environ.get('OPENAI_BASE_URL', "https://api.openai.com/v1")
|
28 |
def_models = '["gpt-4", "gpt-4-0125-preview", "gpt-4-0314", "gpt-4-0613", "gpt-4-1106-preview", "gpt-4-1106-vision-preview", "gpt-4-32k-0314", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-turbo-preview", "gpt-4-vision-preview", "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-mini", "gpt-4o-mini-2024-07-18"]'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
fakeToolPrompt = """[System: You have ability to generate images, via tools provided to you by system.
|
30 |
To call a tool you need to write a json in a empty line; like writing it at the end of message.
|
31 |
To generate a image; you need to follow this example JSON:
|
|
|
440 |
fakeTool,
|
441 |
calcBeta,
|
442 |
searchBeta,
|
443 |
+
betterSystemPrompt
|
|
|
444 |
):
|
|
|
|
|
|
|
|
|
445 |
messages = [];
|
446 |
if fakeTool:
|
447 |
messages.append({"role": "system", "content": fakeToolPrompt});
|
|
|
559 |
|
560 |
|
561 |
handleApiKeys();loadModels();checkModels();loadENV();
|
562 |
+
lastUpdateMessage = "Better TOS handle."
|
563 |
demo = gr.ChatInterface(
|
564 |
respond,
|
565 |
title="GPT-4O-mini",
|
566 |
+
description=f"A OpenAI API proxy!<br/>View API docs [here](/api/v1/docs) <strong>[Yes you can use this as an API in a simpler manner]</strong>.<br/><strong>[Last update: {lastUpdateMessage}]</strong> Also you can only submit images to vision models; txt/code/etc. to all models.",
|
567 |
multimodal=True,
|
568 |
additional_inputs=[
|
569 |
gr.Textbox(value="You are a helpful assistant. You are an OpenAI GPT model. Please adhere to OpenAI's usage policies and guidelines. Ensure your responses are accurate, respectful, and within the scope of OpenAI's rules.", label="System message"),
|
|
|
575 |
gr.Checkbox(label="Randomize Seed", value=True),
|
576 |
gr.Checkbox(label="FakeTool [Image generation beta]", value=True),
|
577 |
gr.Checkbox(label="FakeTool [Calculator beta]", value=True),
|
578 |
+
gr.Checkbox(label="FakeTool [Search engine beta (Warning; each query takes up to 30 seconds)]", value=True),
|
579 |
gr.Checkbox(label="Better system prompt (ignores the system prompt set by user.)", value=True),
|
|
|
580 |
],
|
581 |
+
head="""<script>if(!confirm("By using our application, which integrates with OpenAI's API, you acknowledge and agree to the following terms regarding the data you provide:\\n\\n1. Data Collection: This application may log the following data through the Gradio endpoint or the API endpoint: message requests (including messages, responses, model settings, and images sent along with the messages), images that were generated (including only the prompt and the image), search tool calls (including query, search results, summaries, and output responses), and moderation checks (including input and output).\\n2. Data Retention and Removal: Data is retained until further notice or until a specific request for removal is made.\\n3. Data Usage: The collected data may be used for various purposes, including but not limited to, administrative review of logs, AI training, and publication as a dataset.\\n4. Privacy: Please avoid sharing any personal information.\\n\\nBy continuing to use our application, you explicitly consent to the collection, use, and potential sharing of your data as described above. If you disagree with our data collection, usage, and sharing practices, we advise you not to use our application."))close();</script>"""
|
582 |
)
|
583 |
|
584 |
app = FastAPI()
|
585 |
|
586 |
+
@app.get("/chat/confirm.js")
|
587 |
+
def html():
|
588 |
+
return FileResponse("confirm.js")
|
589 |
+
|
590 |
@app.get("/api/v1/docs")
|
591 |
def html():
|
592 |
return FileResponse("index.html")
|
index.html
CHANGED
@@ -36,7 +36,12 @@
|
|
36 |
<h1>Documentation of the API/updates</h1>
|
37 |
<hr/>
|
38 |
<h2>Updates</h2>
|
39 |
-
<
|
|
|
|
|
|
|
|
|
|
|
40 |
<div>
|
41 |
<strong> - 10. Update.</strong>
|
42 |
<p> * Added OpenAI's new response param "refusal".</p>
|
@@ -45,7 +50,6 @@
|
|
45 |
<strong> - 9. Update.</strong>
|
46 |
<p> * Added a third faketool: search. Now the model can search, via search engine.</p>
|
47 |
</div><hr/>
|
48 |
-
<div>
|
49 |
<div>
|
50 |
<div>
|
51 |
<strong> - 8. Update.</strong>
|
|
|
36 |
<h1>Documentation of the API/updates</h1>
|
37 |
<hr/>
|
38 |
<h2>Updates</h2>
|
39 |
+
<button onclick="if (updates.style.display === 'none') { updates.style.display = 'block'; } else { updates.style.display = 'none'; }">Show/Hide updates</button>
|
40 |
+
<div style="display: none;" id="updates">
|
41 |
+
<div>
|
42 |
+
<strong> - 11. Update.</strong>
|
43 |
+
<p> * Finally found out a better way for TOS acception.</p>
|
44 |
+
</div><hr/>
|
45 |
<div>
|
46 |
<strong> - 10. Update.</strong>
|
47 |
<p> * Added OpenAI's new response param "refusal".</p>
|
|
|
50 |
<strong> - 9. Update.</strong>
|
51 |
<p> * Added a third faketool: search. Now the model can search, via search engine.</p>
|
52 |
</div><hr/>
|
|
|
53 |
<div>
|
54 |
<div>
|
55 |
<strong> - 8. Update.</strong>
|