feat: +ai-plugin

This commit is contained in:
莘权 马 2023-08-18 10:57:52 +08:00
parent 60245fbe90
commit 2513cca46b
9 changed files with 30 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View file

@ -0,0 +1,18 @@
{
"schema_version": "v1",
"name_for_model": "text processing tools",
"name_for_human": "MetaGPT Text Plugin",
"description_for_model": "Plugins for text processing, including text-to-speech, text-to-image, text-to-vector, text summarization, text-to-code, vector similarity calculation, web content crawling, and more.",
"description_for_human": "Plugins for text processing, including text-to-speech, text-to-image, text-to-vector, text summarization, text-to-code, vector similarity calculation, web content crawling, and more.",
"auth": {
"type": "none",
},
"api": {
"type": "openapi",
"url": "https://localhost:8080/.well-known/openapi.yaml",
"has_user_authentication": false
},
"logo_url": "https://localhost:8080/.well-known/MetaGPT-logo.png",
"contact_email": "hello@contact.com",
"legal_info_url": "http://localhost:8080/legal-info"
}

View file

@ -56,8 +56,9 @@ paths:
schema:
type: object
properties:
result:
wav_data:
type: string
format: base64
'400':
description: "Bad Request"
'500':
@ -96,6 +97,7 @@ paths:
properties:
image_data:
type: string
format: base64
'400':
description: "Bad Request"
'500':

View file

@ -12,7 +12,7 @@ import base64
import sys
sys.path.append(str(Path(__file__).resolve().parent.parent.parent)) # fix-bug: No module named 'metagpt'
from metagpt.utils.common import initalize_enviroment
from metagpt.utils.common import initialize_environment
from metagpt.logs import logger
from azure.cognitiveservices.speech import AudioConfig, SpeechConfig, SpeechSynthesizer

View file

@ -22,6 +22,6 @@ def post_greeting(name: str) -> str:
if __name__ == "__main__":
app = connexion.AioHttpApp(__name__, specification_dir='../../spec/')
app = connexion.AioHttpApp(__name__, specification_dir='../../.well-known/')
app.add_api("openapi.yaml", arguments={"title": "Hello World Example"})
app.run(port=8080)

View file

@ -10,11 +10,11 @@ from pathlib import Path
import sys
import connexion
sys.path.append(str(Path(__file__).resolve().parent.parent.parent)) # fix-bug: No module named 'metagpt'
from metagpt.utils.common import initalize_enviroment
from metagpt.utils.common import initialize_environment
if __name__ == "__main__":
initalize_enviroment()
initialize_environment()
app = connexion.AioHttpApp(__name__, specification_dir='../../spec/')
app = connexion.AioHttpApp(__name__, specification_dir='../../.well-known/')
app.add_api("metagpt_oas3_api.yaml")
app.run(port=8080)

View file

@ -16,7 +16,7 @@ import requests
from pydantic import BaseModel
sys.path.append(str(Path(__file__).resolve().parent.parent.parent)) # fix-bug: No module named 'metagpt'
from metagpt.utils.common import initalize_enviroment
from metagpt.utils.common import initialize_environment
from metagpt.logs import logger
@ -94,7 +94,7 @@ def oas3_openai_text_2_image(text, size_type: str = "1024x1024", openai_api_key=
if __name__ == "__main__":
initalize_enviroment()
initialize_environment()
v = oas3_openai_text_2_image("Panda emoji")
print(v)

View file

@ -260,10 +260,10 @@ def parse_recipient(text):
return recipient.group(1) if recipient else ""
def initalize_enviroment():
def initialize_environment():
"""Load `config/config.yaml` to `os.environ`"""
yaml_file_path = Path(__file__).resolve().parent.parent.parent / "config/config.yaml"
with open(str(yaml_file_path), "r") as yaml_file:
data = yaml.safe_load(yaml_file)
for k, v in data.items():
os.environ[k] = str(v)
os.environ[k] = str(v)