Skip to content

Commit 7e35d9a

Browse files
Update version to 1.0.6 and refactor
The changes include an update to the version number in both smart.py and smart_with_tools.py from 1.0.5 to 1.0.6. Additionally, the code was modified to simplify the retrieval of the last message content, improving readability by reducing redundancy in checking the content of user messages.
1 parent 82d8a70 commit 7e35d9a

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ This toolkit aims to provide developers with a versatile set of resources to bui
1212
**Install instructions:**
1313
- Simply copy the `smart.py` code into a new function in OpenWebUI.
1414
- To create a new fuction go to `Workspaces -> Functions -> New Function (+ Icon)`
15+
16+
NOTE: I would not recommend using the smart_with_tools.py code _as is_. It implements my own tools, many of which don't work without some external self-hosted APIs. However you can use it as a template to automatically implement your own tools.
1517
---
1618

1719
The SMART (Sequential Multi-Agent Reasoning Technique) system is a powerful pipeline for enhanced language model capabilities. It includes:

functions/smart.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
description: SMART is a sequential multi-agent reasoning technique.
66
required_open_webui_version: 0.3.30
77
requirements: langchain-openai==0.1.24, langgraph
8-
version: 1.0.5
8+
version: 1.0.6
99
licence: MIT
1010
"""
1111

@@ -405,31 +405,36 @@ async def pipe(
405405
content=f"{content=}",
406406
)
407407

408+
last_message_content = body["messages"][-1]["content"]
409+
410+
if isinstance(last_message_content, list):
411+
last_message_content = last_message_content[0]["text"]
412+
408413
# Try to find #!, #!!, #*yes, #*no, in the user message, let them overwrite the model choice
409414
if (
410-
"#!!!" in body["messages"][-1]["content"]
411-
or "#large" in body["messages"][-1]["content"]
415+
"#!!!" in last_message_content
416+
or "#large" in last_message_content
412417
):
413418
model_to_use_id = huge_model_id
414419
elif (
415-
"#!!" in body["messages"][-1]["content"]
416-
or "#medium" in body["messages"][-1]["content"]
420+
"#!!" in last_message_content
421+
or "#medium" in last_message_content
417422
):
418423
model_to_use_id = large_model_id
419424
elif (
420-
"#!" in body["messages"][-1]["content"]
421-
or "#small" in body["messages"][-1]["content"]
425+
"#!" in last_message_content
426+
or "#small" in last_message_content
422427
):
423428
model_to_use_id = small_model_id
424429

425430
if (
426-
"#*yes" in body["messages"][-1]["content"]
427-
or "#yes" in body["messages"][-1]["content"]
431+
"#*yes" in last_message_content
432+
or "#yes" in last_message_content
428433
):
429434
is_reasoning_needed = "YES"
430435
elif (
431-
"#*no" in body["messages"][-1]["content"]
432-
or "#no" in body["messages"][-1]["content"]
436+
"#*no" in last_message_content
437+
or "#no" in last_message_content
433438
):
434439
is_reasoning_needed = "NO"
435440

functions/smart_with_tools.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
description: SMART is a sequential multi-agent reasoning technique.
66
required_open_webui_version: 0.3.30
77
requirements: langchain-openai==0.1.24, langgraph, aiohttp
8-
version: 1.0
8+
version: 1.0.6
99
licence: MIT
1010
"""
1111

@@ -1087,36 +1087,36 @@ async def pipe(
10871087
content=f"{content=}",
10881088
)
10891089

1090+
last_message_content = body["messages"][-1]["content"]
1091+
1092+
if isinstance(last_message_content, list):
1093+
last_message_content = last_message_content[0]["text"]
1094+
10901095
# Try to find #!, #!!, #*yes, #*no, in the user message, let them overwrite the model choice
10911096
if (
1092-
"#!!!" in body["messages"][-1]["content"]
1093-
or "#large" in body["messages"][-1]["content"]
1097+
"#!!!" in last_message_content
1098+
or "#large" in last_message_content
10941099
):
10951100
model_to_use_id = huge_model_id
10961101
elif (
1097-
"#!!" in body["messages"][-1]["content"]
1098-
or "#medium" in body["messages"][-1]["content"]
1102+
"#!!" in last_message_content
1103+
or "#medium" in last_message_content
10991104
):
11001105
model_to_use_id = large_model_id
11011106
elif (
1102-
"#!" in body["messages"][-1]["content"]
1103-
or "#small" in body["messages"][-1]["content"]
1107+
"#!" in last_message_content
1108+
or "#small" in last_message_content
11041109
):
11051110
model_to_use_id = small_model_id
1106-
elif (
1107-
"#.!" in body["messages"][-1]["content"]
1108-
or "#mini" in body["messages"][-1]["content"]
1109-
):
1110-
model_to_use_id = mini_model_id
11111111

11121112
if (
1113-
"#*yes" in body["messages"][-1]["content"]
1114-
or "#yes" in body["messages"][-1]["content"]
1113+
"#*yes" in last_message_content
1114+
or "#yes" in last_message_content
11151115
):
11161116
is_reasoning_needed = "YES"
11171117
elif (
1118-
"#*no" in body["messages"][-1]["content"]
1119-
or "#no" in body["messages"][-1]["content"]
1118+
"#*no" in last_message_content
1119+
or "#no" in last_message_content
11201120
):
11211121
is_reasoning_needed = "NO"
11221122

0 commit comments

Comments
 (0)