mirror of
https://github.com/open-webui/open-webui
synced 2025-02-23 05:38:41 +00:00
refac
This commit is contained in:
parent
8d520eeecd
commit
c5a9cfacf1
@ -914,9 +914,6 @@ async def process_chat_payload(request, form_data, metadata, user, model):
|
||||
async def process_chat_response(
|
||||
request, response, form_data, user, events, metadata, tasks
|
||||
):
|
||||
|
||||
print("metadata", metadata)
|
||||
|
||||
async def background_tasks_handler():
|
||||
message_map = Chats.get_messages_by_chat_id(metadata["chat_id"])
|
||||
message = message_map.get(metadata["message_id"]) if message_map else None
|
||||
@ -1129,6 +1126,9 @@ async def process_chat_response(
|
||||
for block in content_blocks:
|
||||
if block["type"] == "text":
|
||||
content = f"{content}{block['content'].strip()}\n"
|
||||
elif block["type"] == "tool":
|
||||
pass
|
||||
|
||||
elif block["type"] == "reasoning":
|
||||
reasoning_display_content = "\n".join(
|
||||
(f"> {line}" if not line.startswith(">") else line)
|
||||
@ -1310,6 +1310,7 @@ async def process_chat_response(
|
||||
|
||||
try:
|
||||
data = json.loads(data)
|
||||
print(data)
|
||||
|
||||
if "selected_model_id" in data:
|
||||
model_id = data["selected_model_id"]
|
||||
|
@ -61,6 +61,12 @@ def get_tools(
|
||||
)
|
||||
|
||||
for spec in tools.specs:
|
||||
# TODO: Fix hack for OpenAI API
|
||||
# Some times breaks OpenAI but others don't. Leaving the comment
|
||||
for val in spec.get("parameters", {}).get("properties", {}).values():
|
||||
if val["type"] == "str":
|
||||
val["type"] = "string"
|
||||
|
||||
# Remove internal parameters
|
||||
spec["parameters"]["properties"] = {
|
||||
key: val
|
||||
|
Loading…
Reference in New Issue
Block a user