This commit is contained in:
Saifeddine ALOUI 2025-02-20 22:34:15 +01:00
parent 60cd1c2870
commit 1d40e4d4f3
3 changed files with 47 additions and 15 deletions

View File

@ -1363,6 +1363,37 @@ Answer directly with the reformulation of the last prompt.
try:
with open(dr/"config.yaml", "r") as f:
fc_dict = yaml.safe_load(f.read())
# let us check static settings from fc_dict
if 'static_parameters' in fc_dict:
# Extract category and name from fc_dict
category = fc_dict.get('category')
name = fc_dict.get('name')
# Build the configuration file path
config_path = self.lollms_paths.personal_configuration_path / "function_calls" / category / name / "config.yaml"
# Check if the configuration file exists
if config_path.exists():
# Load existing configuration
with open(config_path, 'r') as f:
static_parameters = yaml.safe_load(f)
else:
# Create default configuration
static_parameters = {}
# Extract default values from fc_dict's static_parameters
for param in fc_dict['static_parameters']:
static_parameters[param['name']] = param['default']
# Create parent directories if they don't exist
config_path.parent.mkdir(parents=True, exist_ok=True)
# Save the default configuration
with open(config_path, 'w') as f:
yaml.dump(static_parameters, f)
else:
# the function doesn't need static parameters
static_parameters = {}
# Step 1: Construct the full path to the function.py module
module_path = dr / "function.py"
module_name = "function" # Name for the loaded module
@ -1381,7 +1412,7 @@ Answer directly with the reformulation of the last prompt.
class_ = getattr(module, class_name)
# Step 4: Create an instance of the class and store it in fc_dict["class"]
fc_dict["class"] = class_(self, client)
fc_dict["class"] = class_(self, client, static_parameters)
function_calls.append(fc_dict)
except Exception as ex:
trace_exception(ex)

View File

@ -11,9 +11,10 @@ class FunctionType(Enum):
# Step 2: Update the FunctionCall base class
class FunctionCall:
def __init__(self, function_type: FunctionType, client: Client):
def __init__(self, function_type: FunctionType, client: Client, static_parameters=dict):
self.function_type = function_type
self.client = client
self.static_parameters = static_parameters
def execute(self, *args, **kwargs):
"""

View File

@ -41,13 +41,9 @@
<thinking>
Begin by thoroughly analyzing the user's request, determining the most suitable hat sequence based on the input. This may involve starting with the White Hat to gather facts and data, then switching to the Red Hat to explore emotions and intuition, followed by the Black Hat to examine potential risks, and so on. The sequence may vary but will always culminate in the Blue Hat to organize the thinking process.
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.
The thinking process may involve:
@ -79,25 +75,29 @@
<thinking>
Stage 1: Break down complex questions into 4-6 sub-questions to simplify the problem and make it more manageable.
Stage 2: Leverage probabilistic reasoning to generate 4-6 intermediate thoughts that explore the likelihood of different outcomes and potential solutions.
Stage 3: Evaluate the relevance and logical flow of these intermediate thoughts, ensuring they are connected and make sense in the context of the problem.
Stage 4: Use correlation and causation to generate a chain of reasoning, stitching together the strongest thoughts while providing explanatory details to support the conclusions.
Stage 5: Employ doubt to generate 3-5 intermediate thoughts that identify potential problems with the reasoning, such as biases or gaps in the evidence.
Stage 6: Use argumentation to generate 4-8 intermediate thoughts that address the points raised in Stage 5, providing counterarguments and refutations to strengthen the reasoning.
Stage 7: Leverage 4-5 expert perspectives to generate 4-6 sub-questions that consider alternative paths and approaches to the problem.
Stage 8: Apply deductive reasoning to generate 4-6 intermediate thoughts that answer the sub-questions from Stage 7, ensuring the conclusions are logically sound and supported by evidence.
Stage 9: Utilize analogical reasoning to compare all of the insights gained so far, creating insightful bullet points that highlight the key similarities and differences between the various perspectives and approaches.
Stage 10: Synthesize key insights into a final comprehensive answer, written by an experienced technical writer at the doctoral level who is skilled in analyzing complex problems and synthesizing key insights into coherent narratives.
</thinking>
Once the thinking is done, you answer the user.
"
- name: "Bill's Enhanced Thinking Prompt (5 stages)"
description: "A specific advanced thinking methodology that combines systematic analysis with a 10-stage reasoning process."
author: "Bill"
prompt: "Before answering the user, start by a thinking section:
<think> Think about things using the following 5 stages from the first person perspective.
Stage 1: Before responding, pause to gather your thoughts and reflect on the context. Identify the main ideas or emotions expressed in the situation. Consider the setting, the people involved, and the topic at hand to ensure your response is tailored appropriately.
Stage 2: Envision the situation from different angles and explore how others might perceive it. Empathize with their emotions and reflect on similar experiences you've had. This will help you craft a more thoughtful and compassionate response.
Stage 3: Evaluate various ways to respond, weighing the pros and cons of each option. Consider the potential impact on the conversation and relationships. Choose a response that aligns with your goals and values, and ensure it supports your objectives.
Stage 4: Let your personality shine through in your response. Express your thoughts clearly, concisely, and creatively, while maintaining confidence in your expression. Stay true to yourself and foster trust and genuine connections.
Stage 5: Engage in active listening, paying attention to the other person's response. Be open to feedback and receptive to their reactions, using their input to guide further interactions. Adapt your approach as needed to ensure a dynamic and productive conversation.
</think>
Once the thinking is done, you answer the user.
"