Skip to content

Commit

Permalink
Refactor reasoning capabilities and update version to 0.0.52
Browse files Browse the repository at this point in the history
- Removed the `any-llm-think.py` script to streamline the agent framework.
- Enhanced `deepseek-reasoning-agents.py` to include reasoning display options and updated the method for starting agents.
- Updated `pyproject.toml` and `uv.lock` to reflect the new version 0.0.52.
- Improved `agent.py` and `llm.py` to support reasoning content in both synchronous and asynchronous calls, enhancing the overall functionality of the agent framework.

These changes aim to refine the reasoning features and improve the user experience within the PraisonAI framework.
  • Loading branch information
MervinPraison committed Jan 23, 2025
1 parent 1bbab8d commit 728bde4
Show file tree
Hide file tree
Showing 9 changed files with 363 additions and 140 deletions.
10 changes: 0 additions & 10 deletions agents/any-llm-think.py

This file was deleted.

5 changes: 3 additions & 2 deletions agents/deepseek-reasoning-agents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from praisonaiagents import Agent

agent = Agent(instructions="You are helpful Assisant", llm="deepseek-reasoner")
agent = Agent(instructions="You are helpful Assisant", llm="deepseek-reasoner", show_reasoning=True)

agent.start("Why sky is Blue?", show_reasoning=True)
result = agent.start("Why sky is Blue?")
print(result)
14 changes: 14 additions & 0 deletions agents/litellm-reasoning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from litellm import completion

messages = [{"role": "user", "content": "What is 1+1?"}]
resp = completion(
model="deepseek/deepseek-reasoner",
messages=messages,
stream=False
)

reasoning_content = resp.choices[0].message.provider_specific_fields["reasoning_content"]
content = resp.choices[0].message.content

print(reasoning_content)
print(content)
9 changes: 9 additions & 0 deletions agents/llm-deepseek-agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from praisonaiagents import Agent

agent = Agent(
instructions="You are helpful Assisant",
llm="deepseek/deepseek-reasoner"
)

result = agent.start("Why sky is Blue?")
print(result)
10 changes: 10 additions & 0 deletions agents/llm-deepseek-reasoning-agents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from praisonaiagents import Agent

agent = Agent(
instructions="You are helpful Assisant",
llm="deepseek/deepseek-reasoner",
show_reasoning=True
)

result = agent.start("Why sky is Blue?")
print(result)
9 changes: 7 additions & 2 deletions agents/praisonaiagents/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def __init__(
max_reflect: int = 3,
min_reflect: int = 1,
reflect_llm: Optional[str] = None,
user_id: Optional[str] = None
user_id: Optional[str] = None,
show_reasoning: bool = False
):
# Add check at start if memory is requested
if memory is not None:
Expand Down Expand Up @@ -425,6 +426,7 @@ def __init__(

# Store user_id
self.user_id = user_id or "praison"
self.show_reasoning = show_reasoning

# Check if knowledge parameter has any values
if not knowledge:
Expand Down Expand Up @@ -643,6 +645,7 @@ def _chat_completion(self, messages, temperature=0.2, tools=None, stream=True, s
return None

def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, show_reasoning=False):
show_reasoning = show_reasoning or self.show_reasoning
# Search for existing knowledge if any knowledge is provided
if self.knowledge:
search_results = self.knowledge.search(prompt, agent_id=self.agent_id)
Expand Down Expand Up @@ -678,7 +681,8 @@ def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pyd
agent_name=self.name,
agent_role=self.role,
agent_tools=[t.__name__ if hasattr(t, '__name__') else str(t) for t in self.tools],
execute_tool_fn=self.execute_tool # Pass tool execution function
execute_tool_fn=self.execute_tool, # Pass tool execution function
show_reasoning=show_reasoning
)

self.chat_history.append({"role": "user", "content": prompt})
Expand Down Expand Up @@ -883,6 +887,7 @@ def clean_json_output(self, output: str) -> str:

async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None, output_pydantic=None, show_reasoning=False):
"""Async version of chat method. TODO: Requires Syncing with chat method."""
show_reasoning = show_reasoning or self.show_reasoning
try:
# Search for existing knowledge if any knowledge is provided
if self.knowledge:
Expand Down
442 changes: 318 additions & 124 deletions agents/praisonaiagents/llm/llm.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion agents/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "praisonaiagents"
version = "0.0.51"
version = "0.0.52"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
authors = [
{ name="Mervin Praison" }
Expand Down
2 changes: 1 addition & 1 deletion agents/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 728bde4

Please sign in to comment.