Merge branch 'dev' into tools-refac-1

This commit is contained in:
Michael Poluektov
2024-08-15 21:35:31 +01:00
committed by GitHub
68 changed files with 538 additions and 1320 deletions

View File

@@ -147,13 +147,17 @@ async def cleanup_response(
await session.close()
async def post_streaming_url(url: str, payload: str, stream: bool = True):
async def post_streaming_url(url: str, payload: Union[str, bytes], stream: bool = True):
r = None
try:
session = aiohttp.ClientSession(
trust_env=True, timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT)
)
r = await session.post(url, data=payload)
r = await session.post(
url,
data=payload,
headers={"Content-Type": "application/json"},
)
r.raise_for_status()
if stream:
@@ -422,6 +426,7 @@ async def copy_model(
r = requests.request(
method="POST",
url=f"{url}/api/copy",
headers={"Content-Type": "application/json"},
data=form_data.model_dump_json(exclude_none=True).encode(),
)
@@ -470,6 +475,7 @@ async def delete_model(
r = requests.request(
method="DELETE",
url=f"{url}/api/delete",
headers={"Content-Type": "application/json"},
data=form_data.model_dump_json(exclude_none=True).encode(),
)
try:
@@ -510,6 +516,7 @@ async def show_model_info(form_data: ModelNameForm, user=Depends(get_verified_us
r = requests.request(
method="POST",
url=f"{url}/api/show",
headers={"Content-Type": "application/json"},
data=form_data.model_dump_json(exclude_none=True).encode(),
)
try:
@@ -567,6 +574,7 @@ async def generate_embeddings(
r = requests.request(
method="POST",
url=f"{url}/api/embeddings",
headers={"Content-Type": "application/json"},
data=form_data.model_dump_json(exclude_none=True).encode(),
)
try:
@@ -616,6 +624,7 @@ def generate_ollama_embeddings(
r = requests.request(
method="POST",
url=f"{url}/api/embeddings",
headers={"Content-Type": "application/json"},
data=form_data.model_dump_json(exclude_none=True).encode(),
)
try:

View File

@@ -980,9 +980,9 @@ async def get_all_models():
function_module, _, _ = load_function_module_by_id(action_id)
webui_app.state.FUNCTIONS[action_id] = function_module
icon_url = None
if action.meta.manifest is not None:
icon_url = action.meta.manifest.get("icon_url", None)
__webui__ = False
if hasattr(function_module, "__webui__"):
__webui__ = function_module.__webui__
if hasattr(function_module, "actions"):
actions = function_module.actions
@@ -994,7 +994,10 @@ async def get_all_models():
"name", f"{action.name} ({_action['id']})"
),
"description": action.meta.description,
"icon_url": _action.get("icon_url", icon_url),
"icon_url": _action.get(
"icon_url", action.meta.manifest.get("icon_url", None)
),
**({"__webui__": __webui__} if __webui__ else {}),
}
for _action in actions
]
@@ -1005,7 +1008,8 @@ async def get_all_models():
"id": action_id,
"name": action.name,
"description": action.meta.description,
"icon_url": icon_url,
"icon_url": action.meta.manifest.get("icon_url", None),
**({"__webui__": __webui__} if __webui__ else {}),
}
)
@@ -2176,7 +2180,20 @@ async def get_manifest_json():
"display": "standalone",
"background_color": "#343541",
"orientation": "portrait-primary",
"icons": [{"src": "/static/logo.png", "type": "image/png", "sizes": "500x500"}],
"icons": [
{
"src": "/static/logo.png",
"type": "image/png",
"sizes": "500x500",
"purpose": "any",
},
{
"src": "/static/logo.png",
"type": "image/png",
"sizes": "500x500",
"purpose": "maskable",
},
],
}