Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Update Python templates for async and agent-to-agent communication#11

Merged
jhaynie merged 3 commits intomainfrom
devin/1746044341-update-python-templates-for-async
May 1, 2025
Merged

Update Python templates for async and agent-to-agent communication#11
jhaynie merged 3 commits intomainfrom
devin/1746044341-update-python-templates-for-async

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Update Python templates for async and agent-to-agent communication

This PR updates the Python templates to be consistent with the changes introduced in PR #38 of the SDK.

Changes

  • Updated all Python templates to use async clients and methods:
    • OpenAI: Changed to AsyncOpenAI and await for API calls
    • Anthropic: Changed to AsyncAnthropic and await for API calls
    • LiteLLM: Changed to acompletion and await for API calls
    • LangChain: Updated to use ainvoke for async chain execution
    • LlamaIndex: Updated to use arun for async agent execution
    • CrewAI: Updated to use akickoff for async crew execution

These changes ensure that the templates are compatible with the fully async I/O and agent-to-agent communication features introduced in the SDK.

Link to Devin run: https://app.devin.ai/sessions/799b77a3479146959b251a76791c608b
Requested by: jhaynie@agentuity.com

Co-Authored-By: jhaynie@agentuity.com <jhaynie@gmail.com>
@devin-ai-integration devin-ai-integration Bot requested a review from jhaynie April 30, 2025 20:21
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Member

@jhaynie jhaynie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure all

request.data.text

are updated to use:

await request.data.text()

Comment thread common/py/crewai/agent.py Outdated
@@ -4,5 +4,6 @@

async def run(request: AgentRequest, response: AgentResponse, context: AgentContext):
inputs = {"topic": request.data.text or "AI LLMs"}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inputs = {"topic": request.data.text or "AI LLMs"}
inputs = {"topic": await request.data.text() or "AI LLMs"}

Comment thread common/py/langchain/openai.py Outdated
output_parser = StrOutputParser()
chain = prompt | llm | output_parser
result = chain.invoke({"input": request.data.text})
result = await chain.ainvoke({"input": request.data.text or "Tell me about AI"})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = await chain.ainvoke({"input": request.data.text or "Tell me about AI"})
result = await chain.ainvoke({"input": await request.data.text() or "Tell me about AI"})

Comment thread common/py/litellm.py Outdated


async def run(request: AgentRequest, response: AgentResponse, context: AgentContext):
messages = [{"content": request.data.text or "Hello, how are you?", "role": "user"}]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
messages = [{"content": request.data.text or "Hello, how are you?", "role": "user"}]
messages = [{"content": await request.data.text() or "Hello, how are you?", "role": "user"}]

Comment thread common/py/llamaindex/openai.py Outdated

async def run(request: AgentRequest, response: AgentResponse, context: AgentContext):
result = await agent.run(request.data.text or "What is 1234 * 4567?")
result = await agent.arun(request.data.text or "What is 1234 * 4567?")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = await agent.arun(request.data.text or "What is 1234 * 4567?")
result = await agent.arun(await request.data.text() or "What is 1234 * 4567?")

Co-Authored-By: jhaynie@agentuity.com <jhaynie@gmail.com>
@jhaynie jhaynie merged commit 7e3626d into main May 1, 2025
2 checks passed
@jhaynie jhaynie deleted the devin/1746044341-update-python-templates-for-async branch May 1, 2025 03:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant