This commit is contained in:
tamiflu233
2023-12-22 15:59:09 +08:00
parent e21889ca32
commit bca83db584
3 changed files with 1025 additions and 30 deletions

View File

@@ -17,11 +17,11 @@ router = APIRouter()
bing_api = BingAPI('885e62a126554fb390af88ae31d2c8ff')
bing_api_v2 = BingAPIV2()
class QueryItem(BaseModel):
query: str
# class QueryItem(BaseModel):
# query: str
class PageItem(BaseModel):
url: str
# class PageItem(BaseModel):
# url: str
class QueryItemV2(BaseModel):
query: str
@@ -30,23 +30,23 @@ class PageItemV2(BaseModel):
url: str
query: Optional[str] = Field(None)
@router.get("/tools/bing/search")
async def bing_search(item: QueryItem):
try:
search_results = bing_api.search(item.query)
except RuntimeError as e:
raise HTTPException(status_code=500, detail=str(e))
return search_results
# @router.get("/tools/bing/search")
# async def bing_search(item: QueryItem):
# try:
# search_results = bing_api.search(item.query)
# except RuntimeError as e:
# raise HTTPException(status_code=500, detail=str(e))
# return search_results
@router.get("/tools/bing/load_page")
async def load_page(item: PageItem):
try:
page_loaded, page_detail = bing_api.load_page(item.url)
except RuntimeError as e:
raise HTTPException(status_code=500, detail=str(e))
if not page_loaded:
raise HTTPException(status_code=500, detail=page_detail)
return {"page_content": page_detail}
# @router.get("/tools/bing/load_page")
# async def load_page(item: PageItem):
# try:
# page_loaded, page_detail = bing_api.load_page(item.url)
# except RuntimeError as e:
# raise HTTPException(status_code=500, detail=str(e))
# if not page_loaded:
# raise HTTPException(status_code=500, detail=page_detail)
# return {"page_content": page_detail}
@router.get("/tools/bing/searchv2")
async def bing_search_v2(item: QueryItemV2):

View File

@@ -1,13 +1,27 @@
import requests
response = requests.get(
'http://127.0.0.1:8079/tools/bing/search',
json={'query': 'Python'}
)
print(response.json())
# response = requests.get(
# 'http://127.0.0.1:8079/tools/bing/search',
# json={'query': 'Python'}
# )
# print(response.json())
response = requests.get(
'http://127.0.0.1:8079/tools/bing/load_page',
json={'url': 'https://www.python.org/'}
)
print(response.json())
# response = requests.get(
# 'http://127.0.0.1:8079/tools/bing/load_page',
# json={'url': 'https://www.python.org/'}
# )
# print(response.json())
import requests
import json
headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML like Gecko) Chrome/52.0.2743.116 Safari/537.36'}
# url="http://101.132.188.137:8079/test?q=1"
url="http://101.132.188.137:8079/tools/bing/load_pagev2"
param = {
'url': 'https://blog.csdn.net/sjxgghg/article/details/134312033',
}
res = requests.get(url,
headers=headers,
json=param,
timeout=30)
print(res.text)

981
jarvis/core/openapi.json Normal file
View File

@@ -0,0 +1,981 @@
{
"openapi": "3.1.0",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/tools/python": {
"post": {
"summary": "Execute Python",
"operationId": "execute_python_tools_python_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Item"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/calculator": {
"post": {
"summary": "Evaluate",
"operationId": "evaluate_tools_calculator_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Expression"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/arxiv": {
"get": {
"summary": "Get Arxiv Article Information",
"description": "Run Arxiv search and get the article meta information.",
"operationId": "get_arxiv_article_information_tools_arxiv_get",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ArxivQuery"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/bing/searchv2": {
"get": {
"summary": "Execute Bing Search - returns top web snippets related to the query. Avoid using complex filters like 'site:'. For detailed page content, further use the web browser tool.",
"operationId": "bing_search_v2_tools_bing_searchv2_get",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/QueryItemV2"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/bing/load_pagev2": {
"get": {
"summary": "Web browser tool for detailed content retrieval and specific information extraction from a target URL. When the task involves searching for specific details within the web page, the 'query' parameter is essential to guide the search towards the relevant information",
"operationId": "load_page_v2_tools_bing_load_pagev2_get",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PageItemV2"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/shell": {
"post": {
"summary": "Execute Shell Command",
"operationId": "execute_shell_command_tools_shell_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ShellCommandModel"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ShellCommandResultModel"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/ppt/create_file": {
"post": {
"summary": "Create File",
"operationId": "create_file_tools_ppt_create_file_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateFileModel"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/ppt/get_image": {
"post": {
"summary": "Get Image",
"operationId": "get_image_tools_ppt_get_image_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetImageModel"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/ppt/add_first_page": {
"post": {
"summary": "Add First Page",
"operationId": "add_first_page_tools_ppt_add_first_page_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AddFirstPageModel"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/ppt/add_text_page": {
"post": {
"summary": "Add Text Page",
"operationId": "add_text_page_tools_ppt_add_text_page_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AddTextPageModel"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/ppt/add_text_image_page": {
"post": {
"summary": "Add Text Image Page",
"operationId": "add_text_image_page_tools_ppt_add_text_image_page_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AddTextImagePageModel"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/ppt/submit_file": {
"get": {
"summary": "Submit File",
"operationId": "submit_file_tools_ppt_submit_file_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
}
}
}
},
"/tools/database": {
"post": {
"summary": "Execute Sqlite",
"operationId": "execute_sqlite_tools_database_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SQLRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/tools/wolframalpha": {
"post": {
"summary": "Wolframalpha Query",
"operationId": "wolframalpha_query_tools_wolframalpha_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/QueryItem"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/weather/query": {
"get": {
"summary": "Query Weather",
"operationId": "query_weather_weather_query_get",
"parameters": [
{
"name": "date",
"in": "query",
"required": true,
"schema": {
"type": "string",
"title": "Date"
}
},
{
"name": "city",
"in": "query",
"required": true,
"schema": {
"type": "string",
"title": "City"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/calendar/insert_event": {
"post": {
"summary": "Insert Event",
"operationId": "insert_event_calendar_insert_event_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CalendarEvent"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/gmail/send": {
"post": {
"summary": "Send Test Email",
"operationId": "send_test_email_gmail_send_post",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EmailSchema"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/gmail/list": {
"get": {
"summary": "List Recent Emails",
"operationId": "list_recent_emails_gmail_list_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
}
}
}
}
},
"components": {
"schemas": {
"AddFirstPageModel": {
"properties": {
"title": {
"type": "string",
"title": "Title"
},
"subtitle": {
"type": "string",
"title": "Subtitle"
}
},
"type": "object",
"required": [
"title",
"subtitle"
],
"title": "AddFirstPageModel"
},
"AddTextImagePageModel": {
"properties": {
"title": {
"type": "string",
"title": "Title"
},
"bullet_items": {
"type": "string",
"title": "Bullet Items"
},
"image": {
"type": "string",
"title": "Image"
}
},
"type": "object",
"required": [
"title",
"bullet_items",
"image"
],
"title": "AddTextImagePageModel"
},
"AddTextPageModel": {
"properties": {
"title": {
"type": "string",
"title": "Title"
},
"bullet_items": {
"type": "string",
"title": "Bullet Items"
}
},
"type": "object",
"required": [
"title",
"bullet_items"
],
"title": "AddTextPageModel"
},
"ArxivQuery": {
"properties": {
"query": {
"type": "string",
"title": "Query"
}
},
"type": "object",
"required": [
"query"
],
"title": "ArxivQuery"
},
"CalendarEvent": {
"properties": {
"summary": {
"type": "string",
"title": "Summary"
},
"location": {
"type": "string",
"title": "Location"
},
"description": {
"type": "string",
"title": "Description"
},
"start": {
"type": "object",
"title": "Start",
"example": {
"dateTime": "2023-07-31T15:00:00",
"timeZone": "Asia/Shanghai"
}
},
"end": {
"type": "object",
"title": "End",
"example": {
"dateTime": "2023-07-31T16:00:00",
"timeZone": "Asia/Shanghai"
}
}
},
"type": "object",
"required": [
"summary",
"location",
"description",
"start",
"end"
],
"title": "CalendarEvent"
},
"CreateFileModel": {
"properties": {
"theme": {
"type": "string",
"title": "Theme"
}
},
"type": "object",
"required": [
"theme"
],
"title": "CreateFileModel"
},
"EmailSchema": {
"properties": {
"from_email": {
"type": "string",
"title": "From Email"
},
"to_email": {
"type": "string",
"title": "To Email"
},
"subject": {
"type": "string",
"title": "Subject"
},
"content": {
"type": "string",
"title": "Content"
}
},
"type": "object",
"required": [
"from_email",
"to_email",
"subject",
"content"
],
"title": "EmailSchema"
},
"Expression": {
"properties": {
"expression": {
"type": "string",
"title": "Expression"
}
},
"type": "object",
"required": [
"expression"
],
"title": "Expression"
},
"GetImageModel": {
"properties": {
"keywords": {
"type": "string",
"title": "Keywords"
}
},
"type": "object",
"required": [
"keywords"
],
"title": "GetImageModel"
},
"HTTPValidationError": {
"properties": {
"detail": {
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail"
}
},
"type": "object",
"title": "HTTPValidationError"
},
"Item": {
"properties": {
"code": {
"type": "string",
"title": "Code"
}
},
"type": "object",
"required": [
"code"
],
"title": "Item"
},
"PageItemV2": {
"properties": {
"url": {
"type": "string",
"title": "Url"
},
"query": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Query"
}
},
"type": "object",
"required": [
"url"
],
"title": "PageItemV2"
},
"QueryItem": {
"properties": {
"query": {
"type": "string",
"title": "Query"
}
},
"type": "object",
"required": [
"query"
],
"title": "QueryItem"
},
"QueryItemV2": {
"properties": {
"query": {
"type": "string",
"title": "Query"
},
"top_k": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Top K"
}
},
"type": "object",
"required": [
"query"
],
"title": "QueryItemV2"
},
"SQLRequest": {
"properties": {
"queries": {
"items": {
"type": "string"
},
"type": "array",
"title": "Queries"
}
},
"type": "object",
"required": [
"queries"
],
"title": "SQLRequest"
},
"ShellCommandModel": {
"properties": {
"command": {
"type": "string",
"title": "Command"
}
},
"type": "object",
"required": [
"command"
],
"title": "ShellCommandModel"
},
"ShellCommandResultModel": {
"properties": {
"stdout": {
"type": "string",
"title": "Stdout"
},
"stderr": {
"type": "string",
"title": "Stderr"
}
},
"type": "object",
"required": [
"stdout",
"stderr"
],
"title": "ShellCommandResultModel"
},
"ValidationError": {
"properties": {
"loc": {
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"type": "array",
"title": "Location"
},
"msg": {
"type": "string",
"title": "Message"
},
"type": {
"type": "string",
"title": "Error Type"
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"title": "ValidationError"
}
}
}
}