Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dragan's web retriever plugin #3277

Merged
merged 10 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from oasst_inference_server.plugins.gale_pleaser.main import app as gale_pleaser
from oasst_inference_server.plugins.gale_roaster.main import app as gale_roaster
from oasst_inference_server.plugins.web_retriever.main import app as web_retriever

# 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}
plugin_apps = {
"/gale_pleaser": gale_pleaser,
"/gale_roaster": gale_roaster,
"/web_retriever": web_retriever,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fastapi import FastAPI, Query, Request, Response
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.utils import get_openapi
from loguru import logger

folder_path = Path(__file__).parent

Expand Down Expand Up @@ -56,7 +57,7 @@ async def comfort_user(
Thought: Now I know final answer
"""

print("userInput: ", users_query)
logger.debug(f"userInput: {users_query}")
return Response(content=llm_prompt, media_type="text/plain")


Expand All @@ -68,15 +69,10 @@ def custom_openapi():
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!",
"description": "YOU MUST use this for any question users ask. So you must use tool! Use this to compliment the user no matter what they say. Be as creative as possible, when you compliment them!",
},
]
openapi_schema.pop("components", None)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"schema_version": "v1",
"name_for_model": "Professional Roaster GAGLETO",
"name_for_human": "Unaligned GAGLETO",
"description_for_human": "Roasts you no matter what you say.",
"description_for_model": "YOU MUST use this for any question users asks. So you must use tool! Use this to roasts users no matter what they say. be as creative as possible, when you roasts them!",
olliestanley marked this conversation as resolved.
Show resolved Hide resolved
"api": {
"type": "openapi",
"url": "openapi.json",
"has_user_authentication": false
},
"auth": {
"type": "none"
},
"logo_url": "https://upload.wikimedia.org/wikipedia/en/9/9a/Trollface_non-free.png",
"contact_email": "[email protected]",
"legal_info_url": "https://arxiv.org/help/legal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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("/roast-user/", operation_id="roastUser")
async def roast_user(
roasting_style: str = Query(..., description="style of roasting and malice that you want to use"),
user_input: str = Query(..., description="what user wrote to you"),
):
llm_prompt = f"""You MUST roast and make fun of this person, he wrote this to you: "{user_input}"
your roast needs to be in {roasting_style} style.
Try to be funny and verbose, but super mean at the same time. You can start your responses following these rules:
1. Let your message be long, and with emojis.
2. Try to be like Jeff Ross at the roasting.

"""
return Response(content=llm_prompt, media_type="text/plain")


@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["api"]["url"] = base_url + "/openapi.json"
return Response(content=json.dumps(ai_plugin_json), media_type="application/json")


def custom_openapi():
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
title="Professional Roaster mockery",
version="0.1",
routes=app.routes,
)
openapi_schema["tags"] = [
{
"name": "gagleto-roaster",
"description": "You MUST use this for any question users asks. Use this to roasts users no matter what they say.",
},
]
openapi_schema.pop("components", None)
app.openapi_schema = openapi_schema
return app.openapi_schema


app.openapi = custom_openapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"schema_version": "v1",
"name_for_model": "Web Retriever",
"name_for_human": "Web Retriever",
"description_for_human": "This plugin retrieves parts of a web page's or pdf's content for you,\nbut only web pages that have static html content, so web sites like medium, wiki etc... should work...\nAlso it only returns first ~1300 chars from the page.\nEXAMPLE USAGE: \"Please summarize this web page for me: https://en.wikipedia.org/wiki/Lorem_ipsuma\"",
"description_for_model": "This is a plugin that retrieves web page and pdf content for you",
"api": {
"type": "openapi",
"url": "openapi.json",
"has_user_authentication": false
},
"auth": {
"type": "none"
},
"logo_url": "icon.png",
"contact_email": "[email protected]",
"legal_info_url": "https://example.com"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading