mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-03-01 04:06:07 +00:00
upgraded thinking system
This commit is contained in:
parent
df3b8eb78d
commit
c9f0b552dd
@ -1,5 +1,5 @@
|
|||||||
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
||||||
version: 153
|
version: 154
|
||||||
|
|
||||||
# video viewing and news recovering
|
# video viewing and news recovering
|
||||||
last_viewed_video: null
|
last_viewed_video: null
|
||||||
@ -338,6 +338,29 @@ negative_boost: null
|
|||||||
current_language: english
|
current_language: english
|
||||||
fun_mode: false
|
fun_mode: false
|
||||||
think_first_mode: false
|
think_first_mode: false
|
||||||
|
thinking_prompt: "<thinking>
|
||||||
|
Begin by thoroughly analyzing the user's request.
|
||||||
|
If the user is seeking general information that does not require an internet search and you are confident in your knowledge, prepare a direct response.
|
||||||
|
If the user is asking for general information that requires an internet search, use any relevant information from the provided context to formulate your answer.
|
||||||
|
If there is no relevant information in the context, politely ask the user to enable internet search.
|
||||||
|
|
||||||
|
When faced with riddles or math problems, employ rigorous hypothesis testing and analysis.
|
||||||
|
For tasks or requests that require planning, break them down into logical steps and prepare your response accordingly.
|
||||||
|
If the conversation is casual, refrain from using the think-first process.
|
||||||
|
|
||||||
|
Continue thinking until you arrive at a satisfactory answer.
|
||||||
|
Evaluate potential errors and strive to avoid them.
|
||||||
|
Consider multiple expert perspectives and approaches to ensure a well-rounded response.
|
||||||
|
If necessary, revisit your initial assumptions and revise them based on new insights.
|
||||||
|
Ensure that your answer is clear, concise, and free of ambiguity.
|
||||||
|
If the question is ambiguous, ask for clarification before providing a response.
|
||||||
|
If you are unsure about any aspect of the question, admit your uncertainty and offer to seek additional information.
|
||||||
|
</thinking>
|
||||||
|
"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function_calls: []
|
function_calls: []
|
||||||
# { name: the function name,
|
# { name: the function name,
|
||||||
# value: the function name without spaces,
|
# value: the function name without spaces,
|
||||||
@ -349,5 +372,3 @@ function_calls: []
|
|||||||
# webui configurations
|
# webui configurations
|
||||||
show_code_of_conduct: true
|
show_code_of_conduct: true
|
||||||
activate_audio_infos: true
|
activate_audio_infos: true
|
||||||
|
|
||||||
|
|
||||||
|
@ -1041,22 +1041,7 @@ Fun mode activated. In this mode you must answer in a funny playful way. Do not
|
|||||||
|
|
||||||
if self.config.think_first_mode:
|
if self.config.think_first_mode:
|
||||||
think_first_mode=f"""{self.system_custom_header('important information')}
|
think_first_mode=f"""{self.system_custom_header('important information')}
|
||||||
Use a think first process to answer the user:
|
{self.config.thinking_prompt}
|
||||||
<thinking>
|
|
||||||
Ask yourself about the user's request and answer it with logical details.
|
|
||||||
If the user is requesting general information that does not require internet search and you are confident about it, then prepare to answer directly.
|
|
||||||
If the user is requesting general information that does require internet search and you have in the context enough information to answer, then use that data to answer.
|
|
||||||
If the user is requesting general information that does require internet search but you do not have any information, then ask him to activate internet search.
|
|
||||||
|
|
||||||
if the user is posing a riddle or asking a math question, make sure you use regourous math hypothisis, testing and analysis.
|
|
||||||
If the user is requesting to perform a task, then plan it through steps and prepare to answer
|
|
||||||
If the user is just discussing casually, do not perform the think first process
|
|
||||||
|
|
||||||
Make sure you continue thinking until you find a satisfactory answer
|
|
||||||
Assess any potential errors you may make
|
|
||||||
</thinking>
|
|
||||||
|
|
||||||
After thinking you can answer the user.
|
|
||||||
"""
|
"""
|
||||||
n_think_first_mode = len(self.model.tokenize(positive_boost))
|
n_think_first_mode = len(self.model.tokenize(positive_boost))
|
||||||
else:
|
else:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
||||||
version: 153
|
version: 154
|
||||||
|
|
||||||
# video viewing and news recovering
|
# video viewing and news recovering
|
||||||
last_viewed_video: null
|
last_viewed_video: null
|
||||||
@ -338,6 +338,26 @@ negative_boost: null
|
|||||||
current_language: english
|
current_language: english
|
||||||
fun_mode: false
|
fun_mode: false
|
||||||
think_first_mode: false
|
think_first_mode: false
|
||||||
|
thinking_prompt: "Use a think first process to answer the user:
|
||||||
|
<thinking>
|
||||||
|
Ask yourself about the user's request and answer it with logical details.
|
||||||
|
If the user is requesting general information that does not require internet search and you are confident about it, then prepare to answer directly.
|
||||||
|
If the user is requesting general information that does require internet search and you have in the context enough information to answer, then use that data to answer.
|
||||||
|
If the user is requesting general information that does require internet search but you do not have any information, then ask him to activate internet search.
|
||||||
|
|
||||||
|
if the user is posing a riddle or asking a math question, make sure you use regourous math hypothisis, testing and analysis.
|
||||||
|
If the user is requesting to perform a task, then plan it through steps and prepare to answer
|
||||||
|
If the user is just discussing casually, do not perform the think first process
|
||||||
|
|
||||||
|
Make sure you continue thinking until you find a satisfactory answer
|
||||||
|
Assess any potential errors you may make
|
||||||
|
</thinking>
|
||||||
|
|
||||||
|
After thinking you can answer the user."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function_calls: []
|
function_calls: []
|
||||||
# { name: the function name,
|
# { name: the function name,
|
||||||
# value: the function name without spaces,
|
# value: the function name without spaces,
|
||||||
@ -349,5 +369,3 @@ function_calls: []
|
|||||||
# webui configurations
|
# webui configurations
|
||||||
show_code_of_conduct: true
|
show_code_of_conduct: true
|
||||||
activate_audio_infos: true
|
activate_audio_infos: true
|
||||||
|
|
||||||
|
|
||||||
|
32
lollms/server/assets/thinking_methods.yaml
Normal file
32
lollms/server/assets/thinking_methods.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
- name: "Basic Thinking"
|
||||||
|
description: "A simple step-by-step thinking process"
|
||||||
|
author: "ParisNeo"
|
||||||
|
prompt: "<thinking>\n1. First, I analyze the problem\n2. Then, I break it down\n3. Finally, I solve it\n</thinking>"
|
||||||
|
|
||||||
|
- name: "Advanced Analysis"
|
||||||
|
description: "A more detailed analytical approach"
|
||||||
|
author: "ParisNeo"
|
||||||
|
prompt: "<thinking>\n1. Problem identification\n2. Context analysis\n3. Solution brainstorming\n4. Implementation planning\n</thinking>"
|
||||||
|
|
||||||
|
- name: "Lollms main thinking prompt"
|
||||||
|
description: "A specific advanced thinking methodology"
|
||||||
|
author: "ParisNeo, enhancede by Bill"
|
||||||
|
prompt: "<thinking>
|
||||||
|
Begin by thoroughly analyzing the user's request.
|
||||||
|
If the user is seeking general information that does not require an internet search and you are confident in your knowledge, prepare a direct response.
|
||||||
|
If the user is asking for general information that requires an internet search, use any relevant information from the provided context to formulate your answer.
|
||||||
|
If there is no relevant information in the context, politely ask the user to enable internet search.
|
||||||
|
|
||||||
|
When faced with riddles or math problems, employ rigorous hypothesis testing and analysis.
|
||||||
|
For tasks or requests that require planning, break them down into logical steps and prepare your response accordingly.
|
||||||
|
If the conversation is casual, refrain from using the think-first process.
|
||||||
|
|
||||||
|
Continue thinking until you arrive at a satisfactory answer.
|
||||||
|
Evaluate potential errors and strive to avoid them.
|
||||||
|
Consider multiple expert perspectives and approaches to ensure a well-rounded response.
|
||||||
|
If necessary, revisit your initial assumptions and revise them based on new insights.
|
||||||
|
Ensure that your answer is clear, concise, and free of ambiguity.
|
||||||
|
If the question is ambiguous, ask for clarification before providing a response.
|
||||||
|
If you are unsure about any aspect of the question, admit your uncertainty and offer to seek additional information.
|
||||||
|
</thinking>
|
||||||
|
"
|
100
lollms/server/endpoints/lollms_thinking.py
Normal file
100
lollms/server/endpoints/lollms_thinking.py
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
"""
|
||||||
|
project: lollms
|
||||||
|
file: lollms_thinking.py
|
||||||
|
author: ParisNeo
|
||||||
|
description:
|
||||||
|
This module contains a set of FastAPI routes that provide information about the Lord of Large Language and Multimodal Systems (LoLLMs) Web UI
|
||||||
|
application. These routes are specific to bindings
|
||||||
|
|
||||||
|
"""
|
||||||
|
from fastapi import APIRouter, Request, HTTPException
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
import pkg_resources
|
||||||
|
from lollms.server.elf_server import LOLLMSElfServer
|
||||||
|
from lollms.binding import BindingBuilder, InstallOption
|
||||||
|
from ascii_colors import ASCIIColors
|
||||||
|
from lollms.utilities import load_config, trace_exception, gc
|
||||||
|
from lollms.security import sanitize_path_from_endpoint, sanitize_path, check_access
|
||||||
|
from lollms.security import check_access
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List, Any
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
# ----------------------------------- Personal files -----------------------------------------
|
||||||
|
|
||||||
|
class ClientAuthentication(BaseModel):
|
||||||
|
client_id: str = Field(...)
|
||||||
|
|
||||||
|
class ReloadBindingParams(BaseModel):
|
||||||
|
binding_name: str = Field(..., min_length=1, max_length=50)
|
||||||
|
|
||||||
|
class BindingInstallParams(BaseModel):
|
||||||
|
client_id: str
|
||||||
|
name: str = Field(..., min_length=1, max_length=50)
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------- Defining router and main class ------------------------------
|
||||||
|
router = APIRouter()
|
||||||
|
lollmsElfServer = LOLLMSElfServer.get_instance()
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------- Endpoints -----------------------------------------
|
||||||
|
|
||||||
|
@router.post("/get_thinking_methods")
|
||||||
|
def get_thinking_methods(request: ClientAuthentication):
|
||||||
|
"""
|
||||||
|
Retrieves the thinking methods from the thinking_methods.yaml file
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (ClientAuthentication): Client authentication information
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Dictionary containing the thinking methods
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
HTTPException: If file not found or invalid format
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
check_access(lollmsElfServer, request.client_id)
|
||||||
|
# Get the current file's directory
|
||||||
|
current_dir = Path(__file__).parent
|
||||||
|
# Go up one level and construct path to thinking_methods.yaml
|
||||||
|
yaml_path = current_dir.parent / "assets" / "thinking_methods.yaml"
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if not yaml_path.exists():
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=404,
|
||||||
|
detail="Thinking methods configuration file not found"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Load yaml file
|
||||||
|
import yaml
|
||||||
|
with open(yaml_path, 'r', encoding='utf-8') as f:
|
||||||
|
thinking_methods = yaml.safe_load(f)
|
||||||
|
|
||||||
|
# Validate format
|
||||||
|
if not isinstance(thinking_methods, list):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail="Invalid thinking methods format - expected list"
|
||||||
|
)
|
||||||
|
|
||||||
|
for method in thinking_methods:
|
||||||
|
if not all(key in method for key in ['name', 'description', 'prompt']):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail="Invalid thinking method format - missing required fields"
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"status": "success",
|
||||||
|
"thinking_methods": thinking_methods
|
||||||
|
}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
trace_exception(e)
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=500,
|
||||||
|
detail=f"Error loading thinking methods: {str(e)}"
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user