mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-21 14:05:17 +02:00
feat: update ai-plugin.json
This commit is contained in:
parent
2513cca46b
commit
18ea97fcc6
3 changed files with 54 additions and 7 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB |
|
|
@ -2,17 +2,17 @@
|
|||
"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.",
|
||||
"description_for_model": "Plugins for text processing, including text-to-speech, text-to-image, text-to-embedding, 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-embedding, text summarization, text-to-code, vector similarity calculation, web content crawling, and more.",
|
||||
"auth": {
|
||||
"type": "none",
|
||||
"type": "none"
|
||||
},
|
||||
"api": {
|
||||
"type": "openapi",
|
||||
"url": "https://localhost:8080/.well-known/openapi.yaml",
|
||||
"url": "https://github.com/iorisa/MetaGPT/blob/feature/oas3/.well-known/metagpt_oas3_api.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"
|
||||
"logo_url": "https://github.com/iorisa/MetaGPT/blob/feature/oas3/docs/resources/MetaGPT-logo.png",
|
||||
"contact_email": "mashenquan@fuzhi.cn",
|
||||
"legal_info_url": "https://github.com/iorisa/MetaGPT/blob/feature/oas3/docs/README_CN.md"
|
||||
}
|
||||
47
metagpt/tools/openai_text_2_embedding.py
Normal file
47
metagpt/tools/openai_text_2_embedding.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/8/17
|
||||
@Author : mashenquan
|
||||
@File : openai_text_2_vector.py
|
||||
@Desc : OpenAI Text-to-Vector OAS3 api, which provides text-to-vector functionality.
|
||||
"""
|
||||
import os
|
||||
|
||||
class OpenAIText2Vector:
|
||||
def __init__(self, openai_api_key):
|
||||
"""
|
||||
:param openai_api_key: OpenAI API key, For more details, checkout: `https://platform.openai.com/account/api-keys`
|
||||
"""
|
||||
self.openai_api_key = openai_api_key if openai_api_key else os.environ.get('OPENAI_API_KEY')
|
||||
|
||||
def text_2_vector(self, text, size_type="1024x1024"):
|
||||
"""Text to image
|
||||
|
||||
:param text: The text used for image conversion.
|
||||
:param size_type: One of ['256x256', '512x512', '1024x1024']
|
||||
:return: The image data is returned in Base64 encoding.
|
||||
"""
|
||||
|
||||
class ImageUrl(BaseModel):
|
||||
url: str
|
||||
|
||||
class ImageResult(BaseModel):
|
||||
data: List[ImageUrl]
|
||||
created: int
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {self.openai_api_key}"
|
||||
}
|
||||
data = {"prompt": text, "n": 1, "size": size_type}
|
||||
try:
|
||||
response = requests.post("https://api.openai.com/v1/images/generations", headers=headers, json=data)
|
||||
response.raise_for_status() # Raise an exception for 4xx or 5xx responses
|
||||
result = ImageResult(**response.json())
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"An error occurred:{e}")
|
||||
return ""
|
||||
if len(result.data) > 0:
|
||||
return OpenAIText2Image.get_image_data(result.data[0].url)
|
||||
return ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue