Compare commits

...
3 Commits
Author SHA1 Message Date
Mervin Praison 117c02cf30 chore: update PraisonAI and related package versions to 2.2.46 and 0.0.119
- Updated PraisonAI version in Dockerfiles and README to 2.2.46
- Updated version in pyproject.toml and uv.lock for PraisonAI and PraisonAI agents to 0.0.119
- Adjusted deployment script to reflect the new PraisonAI version
2025-07-10 22:16:47 +01:00
Mervin Praison f44b15d73b Merge pull request #782 from MervinPraison/claude/issue-754-20250709_155935
refactor: extract streaming chunk processor to eliminate code duplication
2025-07-10 22:13:29 +01:00
claude[bot]andMervin Praison d228a742b7 refactor: extract streaming chunk processor to eliminate code duplication
- Add _process_stream_delta() helper method to consolidate duplicate logic
- Refactor 4 duplicated streaming sections (sync/async, verbose/non-verbose)
- Eliminates ~50 lines of duplicated code
- Maintains 100% backward compatibility with no API changes
- Addresses original issue #754 about streaming code duplication

Co-authored-by: Mervin Praison <[email protected]>
2025-07-09 16:03:24 +00:00
12 changed files with 65 additions and 82 deletions

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
flask \
"praisonai>=2.2.45" \
"praisonai>=2.2.46" \
"praisonai[api]" \
gunicorn \
markdown
+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.2.45" \
"praisonai>=2.2.46" \
"praisonai[chat]" \
"embedchain[github,youtube]"
+1 -1
View File
@@ -20,7 +20,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.2.45" \
"praisonai>=2.2.46" \
"praisonai[ui]" \
"praisonai[chat]" \
"praisonai[realtime]" \
+1 -1
View File
@@ -16,7 +16,7 @@ RUN mkdir -p /root/.praison
# Install Python packages (using latest versions)
RUN pip install --no-cache-dir \
praisonai_tools \
"praisonai>=2.2.45" \
"praisonai>=2.2.46" \
"praisonai[ui]" \
"praisonai[crewai]"
+2 -2
View File
@@ -121,7 +121,7 @@ healthcheck:
## 📦 Package Versions
All Docker images use consistent, up-to-date versions:
- PraisonAI: `>=2.2.45`
- PraisonAI: `>=2.2.46`
- PraisonAI Agents: `>=0.0.92`
- Python: `3.11-slim`
@@ -218,7 +218,7 @@ docker-compose up -d
### Version Pinning
To use specific versions, update the Dockerfile:
```dockerfile
RUN pip install "praisonai==2.2.45" "praisonaiagents==0.0.92"
RUN pip install "praisonai==2.2.46" "praisonaiagents==0.0.92"
```
## 🌐 Production Deployment
+45 -62
View File
@@ -229,6 +229,39 @@ class LLM:
return any(endpoint in base_url or endpoint in api_base for endpoint in ollama_endpoints)
def _process_stream_delta(self, delta, response_text: str, tool_calls: List[Dict], formatted_tools: Optional[List] = None) -> tuple:
"""
Process a streaming delta chunk to extract content and tool calls.
Args:
delta: The delta object from a streaming chunk
response_text: The accumulated response text so far
tool_calls: The accumulated tool calls list so far
formatted_tools: Optional list of formatted tools for tool call support check
Returns:
tuple: (updated_response_text, updated_tool_calls)
"""
# Process content
if delta.content:
response_text += delta.content
# Capture tool calls from streaming chunks if provider supports it
if formatted_tools and self._supports_streaming_tools() and hasattr(delta, 'tool_calls') and delta.tool_calls:
for tc in delta.tool_calls:
if tc.index >= len(tool_calls):
tool_calls.append({
"id": tc.id,
"type": "function",
"function": {"name": "", "arguments": ""}
})
if tc.function.name:
tool_calls[tc.index]["function"]["name"] = tc.function.name
if tc.function.arguments:
tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments
return response_text, tool_calls
def _parse_tool_call_arguments(self, tool_call: Dict, is_ollama: bool = False) -> tuple:
"""
Safely parse tool call arguments with proper error handling
@@ -651,23 +684,11 @@ class LLM:
):
if chunk and chunk.choices and chunk.choices[0].delta:
delta = chunk.choices[0].delta
response_text, tool_calls = self._process_stream_delta(
delta, response_text, tool_calls, formatted_tools
)
if delta.content:
response_text += delta.content
live.update(display_generating(response_text, current_time))
# Capture tool calls from streaming chunks if provider supports it
if formatted_tools and self._supports_streaming_tools() and hasattr(delta, 'tool_calls') and delta.tool_calls:
for tc in delta.tool_calls:
if tc.index >= len(tool_calls):
tool_calls.append({
"id": tc.id,
"type": "function",
"function": {"name": "", "arguments": ""}
})
if tc.function.name:
tool_calls[tc.index]["function"]["name"] = tc.function.name
if tc.function.arguments:
tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments
else:
# Non-verbose streaming
for chunk in litellm.completion(
@@ -681,22 +702,9 @@ class LLM:
):
if chunk and chunk.choices and chunk.choices[0].delta:
delta = chunk.choices[0].delta
if delta.content:
response_text += delta.content
# Capture tool calls from streaming chunks if provider supports it
if formatted_tools and self._supports_streaming_tools() and hasattr(delta, 'tool_calls') and delta.tool_calls:
for tc in delta.tool_calls:
if tc.index >= len(tool_calls):
tool_calls.append({
"id": tc.id,
"type": "function",
"function": {"name": "", "arguments": ""}
})
if tc.function.name:
tool_calls[tc.index]["function"]["name"] = tc.function.name
if tc.function.arguments:
tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments
response_text, tool_calls = self._process_stream_delta(
delta, response_text, tool_calls, formatted_tools
)
response_text = response_text.strip()
@@ -1297,24 +1305,12 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
):
if chunk and chunk.choices and chunk.choices[0].delta:
delta = chunk.choices[0].delta
response_text, tool_calls = self._process_stream_delta(
delta, response_text, tool_calls, formatted_tools
)
if delta.content:
response_text += delta.content
print("\033[K", end="\r")
print(f"Generating... {time.time() - start_time:.1f}s", end="\r")
# Capture tool calls from streaming chunks if provider supports it
if formatted_tools and self._supports_streaming_tools() and hasattr(delta, 'tool_calls') and delta.tool_calls:
for tc in delta.tool_calls:
if tc.index >= len(tool_calls):
tool_calls.append({
"id": tc.id,
"type": "function",
"function": {"name": "", "arguments": ""}
})
if tc.function.name:
tool_calls[tc.index]["function"]["name"] = tc.function.name
if tc.function.arguments:
tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments
else:
# Non-verbose streaming
async for chunk in await litellm.acompletion(
@@ -1328,22 +1324,9 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
):
if chunk and chunk.choices and chunk.choices[0].delta:
delta = chunk.choices[0].delta
if delta.content:
response_text += delta.content
# Capture tool calls from streaming chunks if provider supports it
if formatted_tools and self._supports_streaming_tools() and hasattr(delta, 'tool_calls') and delta.tool_calls:
for tc in delta.tool_calls:
if tc.index >= len(tool_calls):
tool_calls.append({
"id": tc.id,
"type": "function",
"function": {"name": "", "arguments": ""}
})
if tc.function.name:
tool_calls[tc.index]["function"]["name"] = tc.function.name
if tc.function.arguments:
tool_calls[tc.index]["function"]["arguments"] += tc.function.arguments
response_text, tool_calls = self._process_stream_delta(
delta, response_text, tool_calls, formatted_tools
)
response_text = response_text.strip()
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "praisonaiagents"
version = "0.0.118"
version = "0.0.119"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
requires-python = ">=3.10"
authors = [
+1 -1
View File
@@ -2375,7 +2375,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.118"
version = "0.0.119"
source = { editable = "." }
dependencies = [
{ name = "mcp" },
+2 -2
View File
@@ -3,8 +3,8 @@ class Praisonai < Formula
desc "AI tools for various AI applications"
homepage "https://github.com/MervinPraison/PraisonAI"
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.45.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.45.tar.gz | shasum -a 256`.split.first
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.46.tar.gz"
sha256 `curl -sL https://github.com/MervinPraison/PraisonAI/archive/refs/tags/v2.2.46.tar.gz | shasum -a 256`.split.first
license "MIT"
depends_on "[email protected]"
+1 -1
View File
@@ -57,7 +57,7 @@ class CloudDeployer:
file.write("FROM python:3.11-slim\n")
file.write("WORKDIR /app\n")
file.write("COPY . .\n")
file.write("RUN pip install flask praisonai==2.2.45 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==2.2.46 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
+4 -4
View File
@@ -1,6 +1,6 @@
[project]
name = "PraisonAI"
version = "2.2.45"
version = "2.2.46"
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
readme = "README.md"
license = ""
@@ -12,7 +12,7 @@ dependencies = [
"rich>=13.7",
"markdown>=3.5",
"pyparsing>=3.0.0",
"praisonaiagents>=0.0.118",
"praisonaiagents>=0.0.119",
"python-dotenv>=0.19.0",
"instructor>=1.3.3",
"PyYAML>=6.0",
@@ -95,7 +95,7 @@ autogen = ["pyautogen>=0.2.19", "praisonai-tools>=0.0.15", "crewai"]
[tool.poetry]
name = "PraisonAI"
version = "2.2.45"
version = "2.2.46"
description = "PraisonAI is an AI Agents Framework with Self Reflection. PraisonAI application combines PraisonAI Agents, AutoGen, and CrewAI into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customisation, and efficient human-agent collaboration."
authors = ["Mervin Praison"]
license = ""
@@ -113,7 +113,7 @@ python = ">=3.10,<3.13"
rich = ">=13.7"
markdown = ">=3.5"
pyparsing = ">=3.0.0"
praisonaiagents = ">=0.0.118"
praisonaiagents = ">=0.0.119"
python-dotenv = ">=0.19.0"
instructor = ">=1.3.3"
PyYAML = ">=6.0"
+5 -5
View File
@@ -3931,7 +3931,7 @@ wheels = [
[[package]]
name = "praisonai"
version = "2.2.45"
version = "2.2.46"
source = { editable = "." }
dependencies = [
{ name = "instructor" },
@@ -4073,7 +4073,7 @@ requires-dist = [
{ name = "plotly", marker = "extra == 'realtime'", specifier = ">=5.24.0" },
{ name = "praisonai-tools", marker = "extra == 'autogen'", specifier = ">=0.0.15" },
{ name = "praisonai-tools", marker = "extra == 'crewai'", specifier = ">=0.0.15" },
{ name = "praisonaiagents", specifier = ">=0.0.118" },
{ name = "praisonaiagents", specifier = ">=0.0.119" },
{ name = "pyautogen", marker = "extra == 'autogen'", specifier = ">=0.2.19" },
{ name = "pydantic", marker = "extra == 'chat'", specifier = "<=2.10.1" },
{ name = "pydantic", marker = "extra == 'code'", specifier = "<=2.10.1" },
@@ -4130,7 +4130,7 @@ wheels = [
[[package]]
name = "praisonaiagents"
version = "0.0.118"
version = "0.0.119"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "mcp" },
@@ -4139,9 +4139,9 @@ dependencies = [
{ name = "pydantic" },
{ name = "rich" },
]
sdist = { url = "https://files.pythonhosted.org/packages/ba/53/0363b4e986b3916a246af2798cecaba08d47d46acc5faf313789d8de07cf/praisonaiagents-0.0.118.tar.gz", hash = "sha256:0e7cb593fc1733e33c6f17d55e4670ca973cfe4233c86747c7d97be41347a3da", size = 172108 }
sdist = { url = "https://files.pythonhosted.org/packages/5f/ea/56832de856714fa3bb29da1577dcdfa7aa488b15035341329888a4e28c47/praisonaiagents-0.0.119.tar.gz", hash = "sha256:2e16aab996669ff2b0051cf9a688d6482e5560457422506d991336e7fcc357da", size = 171774 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/9a/a1/605677f442a983259be11079b492fff2a1cca78686c8a6385f8adcdea285/praisonaiagents-0.0.118-py3-none-any.whl", hash = "sha256:5e3f27ffc9af64c2db1726dc1174f348b5bb0dea07b110651fcde6f480ca36a1", size = 192626 },
{ url = "https://files.pythonhosted.org/packages/c1/bf/ea47cf5843d128ab24973a7a5260e72503be00707435d1fca79e6acc7a19/praisonaiagents-0.0.119-py3-none-any.whl", hash = "sha256:e4ddb1da0c2fdf38c25e2f918fc59f686ac5d142884c34506fd53550813edd51", size = 192290 },
]
[[package]]