feat: add audio transcription endpoint and MarkItDown audio provider integration

- Added new MarkItDown audio provider in g4f/Provider/audio/MarkItDown.py for handling audio transcription using markitdown external module
- Included MarkItDown provider import in g4f/Provider/audio/__init__.py
- Implemented /v1/audio/transcriptions POST API endpoint with support for file upload, model selection, provider choice, and prompt in g4f/api/__init__.py
- Added TranscriptionResponseModel Pydantic schema to g4f/api/stubs.py for transcription responses
- Fixed media tuple handling in g4f/client/__init__.py to correctly unpack and assign file/name pairs in Completions, Images, and AsyncCompletions classes
- Updated g4f/Provider/LambdaChat.py to remove redundant origin attribute and simplify URL assignment
- Added handling in AnyProvider to append provider if model is matched in provider map and provider is working (g4f/providers/any_provider.py)
- Modified backend_api.py to fix web_search logic and default filter_markdown parameter extraction from query parameters
This commit is contained in:
hlohaus
2025-04-26 02:21:30 +02:00
parent 7bcf321077
commit b15a83ae13
9 changed files with 110 additions and 18 deletions

View File

@@ -220,6 +220,8 @@ class Backend_Api(Api):
}]
web_search = request.args.get("web_search")
if web_search:
is_true_web_search = web_search.lower() in ["true", "1"]
web_search = None if is_true_web_search else web_search
tool_calls.append({
"function": {
"name": "search_tool",
@@ -227,7 +229,7 @@ class Backend_Api(Api):
},
"type": "function"
})
do_filter = request.args.get("filter_markdown")
do_filter = request.args.get("filter_markdown", request.args.get("json"))
cache_id = request.args.get('cache')
parameters = {
"model": request.args.get("model"),