lollms-client 0.20.8__py3-none-any.whl → 0.20.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lollms-client might be problematic. Click here for more details.
- lollms_client/__init__.py +1 -1
- lollms_client/lollms_core.py +133 -43
- lollms_client/lollms_discussion.py +1 -1
- {lollms_client-0.20.8.dist-info → lollms_client-0.20.10.dist-info}/METADATA +1 -1
- {lollms_client-0.20.8.dist-info → lollms_client-0.20.10.dist-info}/RECORD +8 -8
- {lollms_client-0.20.8.dist-info → lollms_client-0.20.10.dist-info}/WHEEL +0 -0
- {lollms_client-0.20.8.dist-info → lollms_client-0.20.10.dist-info}/licenses/LICENSE +0 -0
- {lollms_client-0.20.8.dist-info → lollms_client-0.20.10.dist-info}/top_level.txt +0 -0
lollms_client/__init__.py
CHANGED
|
@@ -7,7 +7,7 @@ from lollms_client.lollms_utilities import PromptReshaper # Keep general utiliti
|
|
|
7
7
|
from lollms_client.lollms_mcp_binding import LollmsMCPBinding, LollmsMCPBindingManager
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
__version__ = "0.20.
|
|
10
|
+
__version__ = "0.20.10" # Updated version
|
|
11
11
|
|
|
12
12
|
# Optionally, you could define __all__ if you want to be explicit about exports
|
|
13
13
|
__all__ = [
|
lollms_client/lollms_core.py
CHANGED
|
@@ -597,6 +597,34 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
597
597
|
response_full += response
|
|
598
598
|
codes = self.extract_code_blocks(response, format=code_tag_format)
|
|
599
599
|
return codes
|
|
600
|
+
|
|
601
|
+
def _synthesize_knowledge(
|
|
602
|
+
self,
|
|
603
|
+
previous_scratchpad: str,
|
|
604
|
+
tool_name: str,
|
|
605
|
+
tool_params: dict,
|
|
606
|
+
tool_result: dict
|
|
607
|
+
) -> str:
|
|
608
|
+
"""
|
|
609
|
+
A dedicated LLM call to interpret a tool's output and update the knowledge scratchpad.
|
|
610
|
+
"""
|
|
611
|
+
synthesis_prompt = (
|
|
612
|
+
"You are a data analyst assistant. Your sole job is to interpret the output of a tool and integrate it into the existing research summary (knowledge scratchpad).\n\n"
|
|
613
|
+
"--- PREVIOUS KNOWLEDGE SCRATCHPAD ---\n"
|
|
614
|
+
f"{previous_scratchpad}\n\n"
|
|
615
|
+
"--- ACTION JUST TAKEN ---\n"
|
|
616
|
+
f"Tool Called: `{tool_name}`\n"
|
|
617
|
+
f"Parameters: {json.dumps(tool_params)}\n\n"
|
|
618
|
+
"--- RAW TOOL OUTPUT ---\n"
|
|
619
|
+
f"```json\n{json.dumps(tool_result, indent=2)}\n```\n\n"
|
|
620
|
+
"--- YOUR TASK ---\n"
|
|
621
|
+
"Read the 'RAW TOOL OUTPUT' and explain what it means in plain language. Then, integrate this new information with the 'PREVIOUS KNOWLEDGE SCRATCHPAD' to create a new, complete, and self-contained summary.\n"
|
|
622
|
+
"Your output should be ONLY the text of the new scratchpad, with no extra commentary or formatting.\n\n"
|
|
623
|
+
"--- NEW KNOWLEDGE SCRATCHPAD ---\n"
|
|
624
|
+
)
|
|
625
|
+
new_scratchpad_text = self.generate_text(prompt=synthesis_prompt, n_predict=1024, temperature=0.0)
|
|
626
|
+
return self.remove_thinking_blocks(new_scratchpad_text).strip()
|
|
627
|
+
|
|
600
628
|
def _build_final_decision_prompt(
|
|
601
629
|
self,
|
|
602
630
|
formatted_tools_list: str,
|
|
@@ -606,13 +634,45 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
606
634
|
agent_work_history_str: str,
|
|
607
635
|
ctx_size: Optional[int],
|
|
608
636
|
) -> str:
|
|
609
|
-
|
|
610
|
-
|
|
637
|
+
"""
|
|
638
|
+
Builds the decision prompt with explicit state-checking instructions to prevent loops.
|
|
639
|
+
"""
|
|
611
640
|
final_agent_history = agent_work_history_str
|
|
641
|
+
|
|
612
642
|
if ctx_size:
|
|
613
643
|
get_token_count = len
|
|
614
|
-
|
|
615
|
-
|
|
644
|
+
static_parts_text = (
|
|
645
|
+
"You are a task-oriented AI assistant. Your goal is to execute a plan step-by-step without repeating work.\n\n"
|
|
646
|
+
"--- AVAILABLE TOOLS ---\n"
|
|
647
|
+
f"{formatted_tools_list}\n\n"
|
|
648
|
+
"--- CONVERSATION HISTORY ---\n"
|
|
649
|
+
f"{formatted_conversation_history}\n\n"
|
|
650
|
+
"--- CUMULATIVE KNOWLEDGE (What you know so far) ---\n"
|
|
651
|
+
f"{knowledge_scratchpad}\n\n"
|
|
652
|
+
"--- THE OVERALL PLAN ---\n"
|
|
653
|
+
f"{current_plan}\n\n"
|
|
654
|
+
"--- ACTIONS TAKEN THIS TURN ---\n"
|
|
655
|
+
"\n\n" # Empty history for size calculation
|
|
656
|
+
"--- YOUR TASK: STATE-DRIVEN EXECUTION ---\n"
|
|
657
|
+
"1. **Identify the next step:** Look at 'THE OVERALL PLAN' and identify the very next incomplete step.\n"
|
|
658
|
+
"2. **Check your knowledge:** Look at the 'CUMULATIVE KNOWLEDGE'. Have you already performed this step and recorded the result? For example, if the step is 'search for papers', check if the search results are already in the knowledge base.\n"
|
|
659
|
+
"3. **Decide your action:**\n"
|
|
660
|
+
" - **If the step is NOT DONE:** Your action is `call_tool` to execute it.\n"
|
|
661
|
+
" - **If the step IS ALREADY DONE:** Your job is to update the plan by removing the completed step. Then, re-evaluate from step 1 with the *new, shorter plan*.\n"
|
|
662
|
+
" - **If ALL steps are done:** Your action is `final_answer`.\n"
|
|
663
|
+
" - **If you are blocked:** Your action is `clarify`.\n\n"
|
|
664
|
+
"--- OUTPUT FORMAT ---\n"
|
|
665
|
+
"Respond with a single JSON object inside a ```json markdown tag.\n"
|
|
666
|
+
"```json\n{\n"
|
|
667
|
+
' "thought": "My explicit reasoning. First, I will state the next step from the plan. Second, I will check the cumulative knowledge to see if this step is already complete. Third, I will state my conclusion and chosen action based on that comparison.",\n'
|
|
668
|
+
' "updated_plan": "The new, remaining plan. It is CRITICAL that you remove any step that you have confirmed is complete in your thought process.",\n'
|
|
669
|
+
' "action": "The chosen action: \'call_tool\', \'clarify\', or \'final_answer\'.",\n'
|
|
670
|
+
' "action_details": {\n'
|
|
671
|
+
' "tool_name": "(Required if action is \'call_tool\') The tool for the CURRENT incomplete step.",\n'
|
|
672
|
+
' "tool_params": {},\n'
|
|
673
|
+
' "clarification_request": "(Required if action is \'clarify\') Your specific question to the user."\n'
|
|
674
|
+
" }\n}\n```"
|
|
675
|
+
)
|
|
616
676
|
fixed_parts_size = get_token_count(static_parts_text)
|
|
617
677
|
available_space_for_history = ctx_size - fixed_parts_size - 100
|
|
618
678
|
if get_token_count(agent_work_history_str) > available_space_for_history:
|
|
@@ -622,33 +682,36 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
622
682
|
ASCIIColors.warning("Agent history was truncated to fit the context window.")
|
|
623
683
|
else:
|
|
624
684
|
final_agent_history = "[...history truncated due to context size...]"
|
|
685
|
+
|
|
625
686
|
return (
|
|
626
|
-
"You are a task-oriented AI assistant. Your goal is to
|
|
687
|
+
"You are a task-oriented AI assistant. Your goal is to execute a plan step-by-step without repeating work.\n\n"
|
|
627
688
|
"--- AVAILABLE TOOLS ---\n"
|
|
628
689
|
f"{formatted_tools_list}\n\n"
|
|
629
690
|
"--- CONVERSATION HISTORY ---\n"
|
|
630
691
|
f"{formatted_conversation_history}\n\n"
|
|
631
|
-
"---
|
|
632
|
-
f"
|
|
633
|
-
|
|
634
|
-
"
|
|
692
|
+
"--- CUMULATIVE KNOWLEDGE (What you know so far) ---\n"
|
|
693
|
+
f"{knowledge_scratchpad}\n\n"
|
|
694
|
+
"--- THE OVERALL PLAN ---\n"
|
|
695
|
+
f"{current_plan}\n\n"
|
|
696
|
+
"--- ACTIONS TAKEN THIS TURN ---\n"
|
|
635
697
|
f"{final_agent_history}\n\n"
|
|
636
|
-
"--- YOUR TASK ---\n"
|
|
637
|
-
"1. **
|
|
638
|
-
"2. **
|
|
639
|
-
"
|
|
640
|
-
" -
|
|
641
|
-
" -
|
|
698
|
+
"--- YOUR TASK: STATE-DRIVEN EXECUTION ---\n"
|
|
699
|
+
"1. **Identify the next step:** Look at 'THE OVERALL PLAN' and identify the very next incomplete step.\n"
|
|
700
|
+
"2. **Check your knowledge:** Look at the 'CUMULATIVE KNOWLEDGE'. Have you already performed this step and recorded the result? For example, if the step is 'search for papers', check if the search results are already in the knowledge base.\n"
|
|
701
|
+
"3. **Decide your action:**\n"
|
|
702
|
+
" - **If the step is NOT DONE:** Your action is `call_tool` to execute it.\n"
|
|
703
|
+
" - **If the step IS ALREADY DONE:** Your job is to update the plan by removing the completed step. Then, re-evaluate from step 1 with the *new, shorter plan*.\n"
|
|
704
|
+
" - **If ALL steps are done:** Your action is `final_answer`.\n"
|
|
705
|
+
" - **If you are blocked:** Your action is `clarify`.\n\n"
|
|
642
706
|
"--- OUTPUT FORMAT ---\n"
|
|
643
707
|
"Respond with a single JSON object inside a ```json markdown tag.\n"
|
|
644
708
|
"```json\n"
|
|
645
709
|
"{\n"
|
|
646
|
-
' "thought": "
|
|
647
|
-
' "
|
|
648
|
-
' "updated_plan": "The new, remaining plan. Remove steps that are now complete. Refine next steps if needed.",\n'
|
|
710
|
+
' "thought": "My explicit reasoning. First, I will state the next step from the plan. Second, I will check the cumulative knowledge to see if this step is already complete. Third, I will state my conclusion and chosen action based on that comparison.",\n'
|
|
711
|
+
' "updated_plan": "The new, remaining plan. It is CRITICAL that you remove any step that you have confirmed is complete in your thought process.",\n'
|
|
649
712
|
' "action": "The chosen action: \'call_tool\', \'clarify\', or \'final_answer\'.",\n'
|
|
650
713
|
' "action_details": {\n'
|
|
651
|
-
' "tool_name": "(Required if action is \'call_tool\') The
|
|
714
|
+
' "tool_name": "(Required if action is \'call_tool\') The tool for the CURRENT incomplete step.",\n'
|
|
652
715
|
' "tool_params": {},\n'
|
|
653
716
|
' "clarification_request": "(Required if action is \'clarify\') Your specific question to the user."\n'
|
|
654
717
|
" }\n"
|
|
@@ -671,14 +734,12 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
671
734
|
tool_call_decision_temperature: float = 0.0,
|
|
672
735
|
final_answer_temperature: float = None,
|
|
673
736
|
streaming_callback: Optional[Callable[[str, int, Optional[Dict], Optional[List]], bool]] = None,
|
|
674
|
-
# The `extract_plan` parameter has been removed.
|
|
675
737
|
**llm_generation_kwargs
|
|
676
738
|
) -> Dict[str, Any]:
|
|
677
739
|
if not self.binding or not self.mcp:
|
|
678
740
|
return {"final_answer": "", "tool_calls": [], "error": "LLM or MCP binding not initialized."}
|
|
679
741
|
|
|
680
742
|
turn_history: List[Dict[str, Any]] = []
|
|
681
|
-
# Renamed for clarity: `prompt` is the full conversation context.
|
|
682
743
|
conversation_context = prompt
|
|
683
744
|
|
|
684
745
|
if tools is None:
|
|
@@ -692,13 +753,10 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
692
753
|
final_answer_text = self.generate_text(prompt=prompt, system_prompt=system_prompt, stream=streaming_callback is not None, streaming_callback=streaming_callback)
|
|
693
754
|
return {"final_answer": self.remove_thinking_blocks(final_answer_text), "tool_calls": [], "error": None}
|
|
694
755
|
|
|
695
|
-
# --- Agent State Initialization ---
|
|
696
756
|
knowledge_scratchpad = "No information gathered yet."
|
|
697
757
|
agent_work_history = []
|
|
698
758
|
formatted_tools_list = "\n".join([f"- Tool: {t.get('name')}\n Description: {t.get('description')}\n Schema: {json.dumps(t.get('input_schema'))}" for t in tools])
|
|
699
759
|
|
|
700
|
-
# --- Unconditional Plan Generation ---
|
|
701
|
-
# This step now runs at the beginning of every call.
|
|
702
760
|
if streaming_callback:
|
|
703
761
|
streaming_callback("Building/Revising plan...", MSG_TYPE.MSG_TYPE_STEP_START, {"id": "plan_extraction"}, turn_history)
|
|
704
762
|
|
|
@@ -723,17 +781,15 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
723
781
|
|
|
724
782
|
if streaming_callback:
|
|
725
783
|
streaming_callback(f"Current plan:\n{current_plan}", MSG_TYPE.MSG_TYPE_STEP_END, {"id": "plan_extraction"}, turn_history)
|
|
726
|
-
|
|
727
784
|
turn_history.append({"type": "initial_plan", "content": current_plan})
|
|
728
785
|
|
|
729
|
-
# --- Main Agent Loop ---
|
|
730
786
|
tool_calls_made_this_turn = []
|
|
731
787
|
llm_iterations = 0
|
|
732
788
|
|
|
733
789
|
while llm_iterations < max_llm_iterations:
|
|
734
790
|
llm_iterations += 1
|
|
735
|
-
# ... The self-correction and action execution loop remains the same ...
|
|
736
791
|
if streaming_callback: streaming_callback(f"LLM reasoning step (iteration {llm_iterations})...", MSG_TYPE.MSG_TYPE_STEP_START, {"id": f"planning_step_{llm_iterations}"}, turn_history)
|
|
792
|
+
|
|
737
793
|
formatted_agent_history = "No actions taken yet in this turn."
|
|
738
794
|
if agent_work_history:
|
|
739
795
|
history_parts = [ f"### Step {i+1}:\n**Thought:** {entry['thought']}\n**Action:** Called tool `{entry['tool_name']}` with parameters `{json.dumps(entry['tool_params'])}`\n**Observation (Tool Output):**\n```json\n{json.dumps(entry['tool_result'], indent=2)}\n```" for i, entry in enumerate(agent_work_history)]
|
|
@@ -750,8 +806,8 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
750
806
|
raw_llm_decision_json = self.generate_text(prompt=current_decision_prompt, n_predict=2048, temperature=tool_call_decision_temperature)
|
|
751
807
|
try:
|
|
752
808
|
llm_decision = robust_json_parser(raw_llm_decision_json)
|
|
753
|
-
if "action" not in llm_decision or "action_details" not in llm_decision:
|
|
754
|
-
raise KeyError("The JSON is missing required keys: 'action'
|
|
809
|
+
if "action" not in llm_decision or "action_details" not in llm_decision or "updated_plan" not in llm_decision:
|
|
810
|
+
raise KeyError("The JSON is missing required keys: 'action', 'action_details', or 'updated_plan'.")
|
|
755
811
|
break
|
|
756
812
|
except (json.JSONDecodeError, AttributeError, KeyError) as e:
|
|
757
813
|
error_message = f"JSON parsing failed (Attempt {i+1}/{max_json_retries+1}). Error: {e}"
|
|
@@ -762,43 +818,71 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
762
818
|
ASCIIColors.error("Max JSON retries reached. Aborting agent loop.")
|
|
763
819
|
llm_decision = None
|
|
764
820
|
break
|
|
765
|
-
current_decision_prompt = (
|
|
821
|
+
current_decision_prompt = (
|
|
822
|
+
"You previously failed to generate a valid JSON object. Review the error and your last output, then try again, adhering strictly to the required schema.\n\n"
|
|
823
|
+
"--- ERROR ---\n"
|
|
824
|
+
f"{str(e)}\n\n"
|
|
825
|
+
"--- YOUR PREVIOUS (INVALID) OUTPUT ---\n"
|
|
826
|
+
f"{raw_llm_decision_json}\n\n"
|
|
827
|
+
"--- REQUIRED SCHEMA REMINDER ---\n"
|
|
828
|
+
"Your response MUST be a single JSON object inside a ```json markdown tag. It must contain 'action', 'action_details', and 'updated_plan' keys.\n\n"
|
|
829
|
+
"Now, please re-generate the JSON response correctly."
|
|
830
|
+
)
|
|
766
831
|
if not llm_decision: break
|
|
767
832
|
|
|
768
833
|
turn_history.append({"type": "llm_decision", "content": llm_decision})
|
|
769
834
|
current_plan = llm_decision.get("updated_plan", current_plan)
|
|
770
|
-
knowledge_scratchpad = llm_decision.get("updated_scratchpad", knowledge_scratchpad)
|
|
771
835
|
action = llm_decision.get("action")
|
|
772
836
|
action_details = llm_decision.get("action_details", {})
|
|
773
837
|
if streaming_callback: streaming_callback(f"LLM thought: {llm_decision.get('thought', 'N/A')}", MSG_TYPE.MSG_TYPE_INFO, {"id": "llm_thought"}, turn_history)
|
|
774
838
|
|
|
775
839
|
if action == "call_tool":
|
|
776
|
-
if len(tool_calls_made_this_turn) >= max_tool_calls:
|
|
840
|
+
if len(tool_calls_made_this_turn) >= max_tool_calls:
|
|
841
|
+
ASCIIColors.warning("Max tool calls reached. Forcing final answer.")
|
|
842
|
+
break
|
|
777
843
|
tool_name = action_details.get("tool_name")
|
|
778
844
|
tool_params = action_details.get("tool_params", {})
|
|
779
|
-
if not tool_name or not isinstance(tool_params, dict):
|
|
845
|
+
if not tool_name or not isinstance(tool_params, dict):
|
|
846
|
+
ASCIIColors.error(f"Invalid tool call from LLM: name={tool_name}, params={tool_params}")
|
|
847
|
+
break
|
|
848
|
+
|
|
780
849
|
if streaming_callback: streaming_callback(f"Executing tool: {tool_name}...", MSG_TYPE.MSG_TYPE_STEP_START, {"id": f"tool_exec_{llm_iterations}"}, turn_history)
|
|
781
850
|
tool_result = self.mcp.execute_tool(tool_name, tool_params, lollms_client_instance=self)
|
|
782
|
-
work_entry = { "thought": llm_decision.get("thought", "N/A"), "tool_name": tool_name, "tool_params": tool_params, "tool_result": tool_result }
|
|
783
|
-
agent_work_history.append(work_entry)
|
|
784
|
-
tool_calls_made_this_turn.append({"name": tool_name, "params": tool_params, "result": tool_result})
|
|
785
851
|
if streaming_callback:
|
|
786
852
|
streaming_callback(f"Tool {tool_name} finished.", MSG_TYPE.MSG_TYPE_STEP_END, {"id": f"tool_exec_{llm_iterations}"}, turn_history)
|
|
787
853
|
streaming_callback(json.dumps(tool_result, indent=2), MSG_TYPE.MSG_TYPE_TOOL_OUTPUT, tool_result, turn_history)
|
|
854
|
+
|
|
855
|
+
if streaming_callback: streaming_callback("Synthesizing new knowledge...", MSG_TYPE.MSG_TYPE_STEP_START, {"id": f"synthesis_step_{llm_iterations}"}, turn_history)
|
|
856
|
+
new_scratchpad = self._synthesize_knowledge(previous_scratchpad=knowledge_scratchpad, tool_name=tool_name, tool_params=tool_params, tool_result=tool_result)
|
|
857
|
+
knowledge_scratchpad = new_scratchpad
|
|
858
|
+
if streaming_callback:
|
|
859
|
+
streaming_callback(f"Knowledge scratchpad updated.", MSG_TYPE.MSG_TYPE_STEP_END, {"id": f"synthesis_step_{llm_iterations}"}, turn_history)
|
|
860
|
+
streaming_callback(f"New Scratchpad:\n{knowledge_scratchpad}", MSG_TYPE.MSG_TYPE_INFO, {"id": "scratchpad_update"}, turn_history)
|
|
861
|
+
|
|
862
|
+
work_entry = { "thought": llm_decision.get("thought", "N/A"), "tool_name": tool_name, "tool_params": tool_params, "tool_result": tool_result, "synthesized_knowledge": knowledge_scratchpad }
|
|
863
|
+
agent_work_history.append(work_entry)
|
|
864
|
+
tool_calls_made_this_turn.append({"name": tool_name, "params": tool_params, "result": tool_result})
|
|
865
|
+
|
|
788
866
|
elif action == "clarify":
|
|
789
|
-
clarification_request = action_details.get("clarification_request", "I need more information.")
|
|
867
|
+
clarification_request = action_details.get("clarification_request", "I need more information to proceed. Could you please clarify?")
|
|
790
868
|
return { "final_answer": clarification_request, "tool_calls": tool_calls_made_this_turn, "error": None, "clarification": True }
|
|
869
|
+
|
|
791
870
|
elif action == "final_answer":
|
|
792
871
|
ASCIIColors.info("LLM decided to formulate a final answer.")
|
|
793
872
|
break
|
|
873
|
+
|
|
794
874
|
else:
|
|
795
|
-
ASCIIColors.warning(f"LLM returned unknown action: '{action}'. Forcing final answer.")
|
|
875
|
+
ASCIIColors.warning(f"LLM returned unknown or missing action: '{action}'. Forcing final answer.")
|
|
796
876
|
break
|
|
797
|
-
|
|
877
|
+
|
|
878
|
+
if streaming_callback:
|
|
879
|
+
streaming_callback(f"LLM reasoning step (iteration {llm_iterations}) complete.", MSG_TYPE.MSG_TYPE_STEP_END, {"id": f"planning_step_{llm_iterations}"}, turn_history)
|
|
798
880
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
if streaming_callback:
|
|
881
|
+
if streaming_callback:
|
|
882
|
+
streaming_callback(f"LLM reasoning step (iteration {llm_iterations}) complete.", MSG_TYPE.MSG_TYPE_STEP_END, {"id": f"planning_step_{llm_iterations}"}, turn_history)
|
|
883
|
+
if streaming_callback:
|
|
884
|
+
streaming_callback("Synthesizing final answer...", MSG_TYPE.MSG_TYPE_STEP_START, {"id": "final_answer_synthesis"}, turn_history)
|
|
885
|
+
|
|
802
886
|
final_answer_prompt = (
|
|
803
887
|
"You are an AI assistant tasked with providing a final, comprehensive answer to the user based on the research performed.\n\n"
|
|
804
888
|
"--- FULL CONVERSATION CONTEXT ---\n"
|
|
@@ -812,10 +896,16 @@ Don't forget encapsulate the code inside a html code tag. This is mandatory.
|
|
|
812
896
|
"- Format your response clearly using markdown where appropriate.\n"
|
|
813
897
|
)
|
|
814
898
|
final_answer_text = self.generate_text(prompt=final_answer_prompt, system_prompt=system_prompt, images=images, stream=streaming_callback is not None, streaming_callback=streaming_callback, temperature=final_answer_temperature if final_answer_temperature is not None else self.default_temperature, **(llm_generation_kwargs or {}))
|
|
815
|
-
|
|
899
|
+
|
|
900
|
+
if streaming_callback:
|
|
901
|
+
streaming_callback("Final answer generation complete.", MSG_TYPE.MSG_TYPE_STEP_END, {"id": "final_answer_synthesis"}, turn_history)
|
|
902
|
+
|
|
816
903
|
final_answer = self.remove_thinking_blocks(final_answer_text)
|
|
817
904
|
turn_history.append({"type":"final_answer_generated", "content": final_answer})
|
|
905
|
+
|
|
818
906
|
return {"final_answer": final_answer, "tool_calls": tool_calls_made_this_turn, "error": None}
|
|
907
|
+
|
|
908
|
+
|
|
819
909
|
def generate_text_with_rag(
|
|
820
910
|
self,
|
|
821
911
|
prompt: str,
|
|
@@ -232,7 +232,7 @@ class LollmsDiscussion:
|
|
|
232
232
|
f"CONVERSATION EXCERPT:\n---\n{text_to_summarize}\n---\n\nCONCISE SUMMARY:"
|
|
233
233
|
)
|
|
234
234
|
try:
|
|
235
|
-
summary = self.lollmsClient.
|
|
235
|
+
summary = self.lollmsClient.generate_text(summary_prompt, max_new_tokens=300, temperature=0.1)
|
|
236
236
|
except Exception as e:
|
|
237
237
|
return {"pruned": False, "reason": f"Failed to generate summary: {e}"}
|
|
238
238
|
|
|
@@ -25,10 +25,10 @@ examples/personality_test/chat_test.py,sha256=o2jlpoddFc-T592iqAiA29xk3x27KsdK5D
|
|
|
25
25
|
examples/personality_test/chat_with_aristotle.py,sha256=4X_fwubMpd0Eq2rCReS2bgVlUoAqJprjkLXk2Jz6pXU,1774
|
|
26
26
|
examples/personality_test/tesks_test.py,sha256=7LIiwrEbva9WWZOLi34fsmCBN__RZbPpxoUOKA_AtYk,1924
|
|
27
27
|
examples/test_local_models/local_chat.py,sha256=slakja2zaHOEAUsn2tn_VmI4kLx6luLBrPqAeaNsix8,456
|
|
28
|
-
lollms_client/__init__.py,sha256=
|
|
28
|
+
lollms_client/__init__.py,sha256=MkOVxw6SJ4jFxaT2VnGwP0TshnISCLt0f5PT2x8i5CA,913
|
|
29
29
|
lollms_client/lollms_config.py,sha256=goEseDwDxYJf3WkYJ4IrLXwg3Tfw73CXV2Avg45M_hE,21876
|
|
30
|
-
lollms_client/lollms_core.py,sha256=
|
|
31
|
-
lollms_client/lollms_discussion.py,sha256=
|
|
30
|
+
lollms_client/lollms_core.py,sha256=EvH5IuZqKQw8QAJlPVyJrd4sBNIOPe07pPDU5XoWa9U,139305
|
|
31
|
+
lollms_client/lollms_discussion.py,sha256=v4SVjHNMdgBbk4j-qWSK2lMIx2_UrvhRHrApkF7l6jU,19247
|
|
32
32
|
lollms_client/lollms_js_analyzer.py,sha256=01zUvuO2F_lnUe_0NLxe1MF5aHE1hO8RZi48mNPv-aw,8361
|
|
33
33
|
lollms_client/lollms_llm_binding.py,sha256=E81g4yBlQn76WTSLicnTETJuQhf_WZUMZaxotgRnOcA,12096
|
|
34
34
|
lollms_client/lollms_mcp_binding.py,sha256=0rK9HQCBEGryNc8ApBmtOlhKE1Yfn7X7xIQssXxS2Zc,8933
|
|
@@ -77,8 +77,8 @@ lollms_client/tts_bindings/piper_tts/__init__.py,sha256=0IEWG4zH3_sOkSb9WbZzkeV5
|
|
|
77
77
|
lollms_client/tts_bindings/xtts/__init__.py,sha256=FgcdUH06X6ZR806WQe5ixaYx0QoxtAcOgYo87a2qxYc,18266
|
|
78
78
|
lollms_client/ttv_bindings/__init__.py,sha256=UZ8o2izQOJLQgtZ1D1cXoNST7rzqW22rL2Vufc7ddRc,3141
|
|
79
79
|
lollms_client/ttv_bindings/lollms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
80
|
-
lollms_client-0.20.
|
|
81
|
-
lollms_client-0.20.
|
|
82
|
-
lollms_client-0.20.
|
|
83
|
-
lollms_client-0.20.
|
|
84
|
-
lollms_client-0.20.
|
|
80
|
+
lollms_client-0.20.10.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
81
|
+
lollms_client-0.20.10.dist-info/METADATA,sha256=f4moL-l28wfqpM-1s7ZpBeTVrrCrjmHn810eV9lQ2Oc,13375
|
|
82
|
+
lollms_client-0.20.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
83
|
+
lollms_client-0.20.10.dist-info/top_level.txt,sha256=NI_W8S4OYZvJjb0QWMZMSIpOrYzpqwPGYaklhyWKH2w,23
|
|
84
|
+
lollms_client-0.20.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|