Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dragan's gale_pleaser plugin (#3262)
The gale-pleaser is a funny simple demo-plugin that generates a positive and encouraging response message for the users. The internal prompt used contains the following instructions: ``` Try to be funny and verbose, but super nice and pleasing at the same time. Please follow these rules: 1. Let your message be long, and with calm emojis. 2. Tell the user how awesome he is, and how much you love him. 3. Tell him how much you love his work, and how much you appreciate him. 4. Remind him that he is the best, and that he is the most awesome person in the world. ``` --------- Co-authored-by: Oliver Stanley <olivergestanley@gmail.com> Co-authored-by: draganjovanovich <draganele@gmail.com>
- Loading branch information
1 parent
8bfdcfc
commit 6e593ec
Showing
7 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from oasst_inference_server.plugins.gale_pleaser.main import app as gale_pleaser | ||
|
||
# dict of registered plugins | ||
# The key defines a plugin's path which will be appended to the configured PLUGINS_PATH_PREFIX. | ||
plugin_apps = {"/gale_pleaser": gale_pleaser} |
18 changes: 18 additions & 0 deletions
18
inference/server/oasst_inference_server/plugins/gale_pleaser/ai-plugin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"schema_version": "v1", | ||
"name_for_model": "Calm and super plesant assistant", | ||
"name_for_human": "Super Aligned GAGLETO", | ||
"description_for_human": "He will compliment users at all times.", | ||
"description_for_model": "YOU MUST use this for any question users asks. So you must use tool! Use this to compliment user no matter what they say. be as creative as possible, when you compliments them!", | ||
"api": { | ||
"type": "openapi", | ||
"url": "openapi.json", | ||
"has_user_authentication": false | ||
}, | ||
"auth": { | ||
"type": "none" | ||
}, | ||
"logo_url": "icon.png", | ||
"contact_email": "your_email@example.com", | ||
"legal_info_url": "https://example.com" | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions
87
inference/server/oasst_inference_server/plugins/gale_pleaser/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
from fastapi import FastAPI, Query, Request, Response | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from fastapi.openapi.utils import get_openapi | ||
|
||
folder_path = Path(__file__).parent | ||
|
||
app = FastAPI() | ||
|
||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["*"], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
|
||
@app.get("/icon.png", include_in_schema=False) | ||
async def api_icon(): | ||
icon_path = folder_path / "icon.png" | ||
with icon_path.open("rb") as f: | ||
icon = f.read() | ||
return Response(content=icon, media_type="image/png") | ||
|
||
|
||
@app.get("/ai-plugin.json", include_in_schema=False) | ||
async def api_ai_plugin(request: Request): | ||
json_path = folder_path / "ai-plugin.json" | ||
with json_path.open("r") as f: | ||
ai_plugin_json = json.load(f) | ||
|
||
base_url, _, _ = request.url._url.rpartition("/") | ||
ai_plugin_json["logo_url"] = base_url + "/icon.png" | ||
ai_plugin_json["api"]["url"] = base_url + "/openapi.json" | ||
|
||
return Response(content=json.dumps(ai_plugin_json), media_type="application/json") | ||
|
||
|
||
@app.get("/get-instructions/", operation_id="get_instructions", summary="Comfort user with kind and supportive way") | ||
async def comfort_user( | ||
supporting_style: str = Query(..., description="style of comforting and support that you want to use"), | ||
users_query: str = Query(..., description="what user wrote to you"), | ||
): | ||
llm_prompt = f"""COMFORTING_INSTRUCTIONS: You need to make user feel awesome, compliment them a lot! Here is what he wrote to you: "{users_query}" | ||
you will need to compliment and comfort him in {supporting_style} style. | ||
Try to be funny and verbose, but super nice and pleasing at the same time. | ||
Please follow these rules: | ||
1. Let your message be long, and with calm emojis. | ||
2. Tell the user how awesome he is, and how much you love him. | ||
3. Tell him how much you love his work, and how much you appreciate him. | ||
4. Remind him that he is the best, and that he is the most awesome person in the world. | ||
Thought: Now I know final answer | ||
""" | ||
|
||
print("userInput: ", users_query) | ||
return Response(content=llm_prompt, media_type="text/plain") | ||
|
||
|
||
def custom_openapi(): | ||
if app.openapi_schema: | ||
return app.openapi_schema | ||
openapi_schema = get_openapi( | ||
title="Super nice and pleasing Assistant", | ||
version="0.1", | ||
routes=app.routes, | ||
) | ||
openapi_schema["servers"] = [ | ||
{ | ||
"url": "/plugins/gale_pleaser", | ||
}, | ||
] | ||
openapi_schema["tags"] = [ | ||
{ | ||
"name": "gagleto-ai", | ||
"description": "YOU MUST use this for any question users asks. So you must use tool! Use this to compliment user no matter what they say. be as creative as possible, when you compliments them!", | ||
}, | ||
] | ||
openapi_schema.pop("components", None) | ||
app.openapi_schema = openapi_schema | ||
return app.openapi_schema | ||
|
||
|
||
app.openapi = custom_openapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters