Skip to content

Commit dfcbfa0

Browse files
Update version and add new models
The changes in smart.py include an update to the version number from 0.8 to 1.0.1. New model fields for online and mini reasoning have been added, along with a flag for using the Groq planning model. The logic for selecting models based on hashtags has been expanded to include an online model option.
1 parent bbd4052 commit dfcbfa0

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

pipes/smart.py

Lines changed: 38 additions & 2 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: 0.8
8+
version: 1.0.1
99
licence: MIT
1010
"""
1111

@@ -52,6 +52,7 @@
5252
- Use #small for the simple queries or queries that mostly involve summarization or simple "mindless" work. This also invloves very simple tool use, like converting a file, etc.
5353
- Use #medium for task that requiere some creativity, writing of code, or complex tool-use.
5454
- Use #large for tasks that are mostly creative or involve the writing of complex code, math, etc.
55+
- Use #online for tasks that mostly requiere the use of the internet. Such as news or queries that will benifit greatly from up-to-date information. However, this model can not use tools and does not have vision.
5556
2. Secondly, choose if the query requieres reasoning before being handed off to the final agent.
5657
- Queries that requeire reasoning are especially queries where llm are bad at. Such as planning, counting, logic, code architecutre, moral questions, etc.
5758
- Queries that don't requeire reasoning are queries that are easy for llms. Such as "knowledge" questions, summarization, writing notes, simple tool use, etc.
@@ -197,6 +198,21 @@ class Valves(BaseModel):
197198
REASONING_MODEL: str = Field(
198199
default="anthropic/claude-3.5-sonnet",
199200
description="Model for reasoning tasks",
201+
),
202+
ONLINE_MODEL: str = Field(
203+
default="perplexity/llama-3.1-sonar-large-128k-online", description="Online Model"
204+
),
205+
MINI_REASONING_MODEL: str = Field(
206+
default="openai/gpt-4o-2024-08-06", description="Reasoning for the -mini Model"
207+
)
208+
USE_GROQ_PLANNING_MODEL: str = Field(
209+
default="False", description="Use Groq planning model, input model ID if you want to use it."
210+
)
211+
GROQ_API_KEY: str = Field(
212+
default="", description="Groq API key"
213+
)
214+
ONLY_USE_GROQ_FOR_MINI: bool = Field(
215+
default=True, description="Only use Groq planning model for mini tasks"
200216
)
201217
AGENT_NAME: str = Field(default="Smart/Core", description="Name of the agent")
202218
AGENT_ID: str = Field(default="smart-core", description="ID of the agent")
@@ -214,7 +230,7 @@ def pipes(self) -> list[dict[str, str]]:
214230
except Exception as e:
215231
return [{"id": "error", "name": f"Error: {e}"}]
216232

217-
return [{"id": self.valves.AGENT_ID, "name": self.valves.AGENT_NAME}]
233+
return [{"id": self.valves.AGENT_ID, "name": self.valves.AGENT_NAME}, {"id": self.valves.AGENT_ID + "-mini", "name": self.valves.AGENT_NAME + "-mini"}]
218234

219235
def setup(self):
220236
v = self.valves
@@ -244,11 +260,29 @@ async def pipe(
244260

245261
start_time = time.time()
246262

263+
called_model_id = body["model"]
264+
mini_mode = False
265+
if called_model_id.endswith("-mini"):
266+
mini_mode = True
267+
247268
# print(f"{body=}")
248269

249270
small_model_id = self.valves.SMALL_MODEL
250271
large_model_id = self.valves.LARGE_MODEL
251272
huge_model_id = self.valves.HUGE_MODEL
273+
online_model_id = self.valves.ONLINE_MODEL
274+
275+
if self.valves.USE_GROQ_PLANNING_MODEL != "False":
276+
if self.valves.ONLY_USE_GROQ_FOR_MINI == True and mini_mode == True:
277+
planning_model_id = self.valves.USE_GROQ_PLANNING_MODEL
278+
planning_model = ChatOpenAI(model=planning_model_id, **self.groq_kwargs) # type: ignore
279+
elif self.valves.ONLY_USE_GROQ_FOR_MINI == False:
280+
planning_model_id = self.valves.USE_GROQ_PLANNING_MODEL
281+
planning_model = ChatOpenAI(model=planning_model_id, **self.groq_kwargs) # type: ignore
282+
else:
283+
planning_model = ChatOpenAI(model=planning_model_id, **self.openai_kwargs) # type: ignore
284+
else:
285+
planning_model = ChatOpenAI(model=planning_model_id, **self.openai_kwargs) # type: ignore
252286

253287
planning_model = ChatOpenAI(model=small_model_id, **self.openai_kwargs) # type: ignore
254288

@@ -351,6 +385,8 @@ async def pipe(
351385
model_to_use_id = large_model_id
352386
elif "#large" in csv_hastag_list:
353387
model_to_use_id = huge_model_id
388+
elif "#online" in csv_hastag_list:
389+
model_to_use_id = online_model_id
354390
else:
355391
model_to_use_id = small_model_id
356392

0 commit comments

Comments
 (0)