Skip to content

Commit afa4df5

Browse files
committed
feat: add async run support and example scripts for multi-turn conversations
1 parent 993ae07 commit afa4df5

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from praisonaiagents import Agent
2+
3+
agent = Agent(
4+
instructions="You are a helpful assistant",
5+
llm="gpt-5-nano"
6+
)
7+
agent.start("Why sky is Blue?")
8+
agent.start("What was my previous question?")

src/praisonai-agents/openai-run.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from praisonaiagents import Agent
2+
import asyncio
3+
4+
agent = Agent(
5+
instructions="You are a helpful assistant",
6+
llm="gpt-5-nano"
7+
)
8+
agent.run("Why sea is Blue?")
9+
10+
async def main():
11+
await agent.arun("Why sky is Blue?")
12+
await agent.arun("What was my previous question?")
13+
14+
asyncio.run(main())

src/praisonai-agents/praisonaiagents/agent/agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,13 +2082,17 @@ async def _achat_completion(self, response, tools, reasoning_steps=False):
20822082
display_error(f"Error in _achat_completion: {e}")
20832083
return None
20842084

2085+
async def arun(self, prompt: str, **kwargs):
2086+
"""Async alias for astart() method"""
2087+
return await self.astart(prompt, **kwargs)
2088+
20852089
async def astart(self, prompt: str, **kwargs):
20862090
"""Async version of start method"""
20872091
return await self.achat(prompt, **kwargs)
20882092

2089-
def run(self):
2093+
def run(self, prompt: str, **kwargs):
20902094
"""Alias for start() method"""
2091-
return self.start()
2095+
return self.start(prompt, **kwargs)
20922096

20932097
def start(self, prompt: str, **kwargs):
20942098
"""Start the agent with a prompt. This is a convenience method that wraps chat()."""

src/praisonai-agents/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "praisonaiagents"
7-
version = "0.0.161"
7+
version = "0.0.162"
88
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
99
requires-python = ">=3.10"
1010
authors = [

src/praisonai-agents/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)