Skip to content

Conversation

@yanxi0830
Copy link
Collaborator

@yanxi0830 yanxi0830 commented May 16, 2025

Description

  • add Llama API as a model provider
  • add llama-api-client as dependency

Related Issues

  • updated README to include Llama API as a model provider

Type of Change

  • New feature

Testing

  • add tests
  • test with script
from strands import Agent
from strands.sdk.models import LlamaAPIModel
from strands import Agent, tool

from rich.pretty import pprint

def main():
    # Llama API
    llama_model = LlamaAPIModel(
        model_id="Llama-4-Maverick-17B-128E-Instruct-FP8",
    )
    agent = Agent(model=llama_model)
    response = agent("Tell me about Agentic AI")

    print()
    pprint(response)


def main_with_get_weather_tool():
    @tool
    def get_weather(location: str) -> str:
        """Get the weather for a location.
        
        :param location: The city, state, or country for which to fetch the temperature. 
        """
        return f"The weather in {location} is sunny."

    llama_model = LlamaAPIModel(
        model_id="Llama-4-Maverick-17B-128E-Instruct-FP8",
    )
    agent = Agent(model=llama_model, tools=[get_weather])
    response = agent("What is the weather in San Francisco?")

    print()
    pprint(response)

def main_with_word_count_tool():
    @tool
    def word_count(text: str) -> int:
        """Count the number of words in a text.
        
        :param text: The text to count the words of. 
        """
        return len(text.split())

    llama_model = LlamaAPIModel(
        model_id="Llama-4-Maverick-17B-128E-Instruct-FP8",
    )
    agent = Agent(model=llama_model, tools=[word_count])
    response = agent("How many words are in this sentence?")

    print()
    pprint(response)



if __name__ == "__main__":
    # main()
    main_with_word_count_tool()
    # main_with_get_weather_tool()
  • hatch fmt --linter
  • hatch fmt --formatter
  • hatch test --all
  • Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

Checklist

  • I have read the CONTRIBUTING document
  • I have added tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…g an SDK where autonomous intelligence can evolve.

Welcome to Strands Agents!
@yanxi0830 yanxi0830 requested a review from a team as a code owner May 16, 2025 15:20
@awsarron awsarron closed this May 16, 2025
mkmeral pushed a commit to mkmeral/sdk-python that referenced this pull request Jan 9, 2026
- Fix invoke_async to delegate to stream_async (prevents returning first incomplete event)
- Add async context manager support (__aenter__/__aexit__) and explicit aclose() method
- Improve __del__ cleanup to handle event loop edge cases
- Change logger.info to logger.debug for consistency with project standards
- Simplify factory creation with _create_default_factory() helper method
- Add comprehensive documentation to A2AStreamEvent
- Improve test fixture pattern with pytest fixture for subprocess management
- Add comprehensive e2e tests for invoke_async, stream_async, and context manager

Addresses PR strands-agents#1174 review comments:
- Comment strands-agents#2: Critical bug - invoke_async now waits for complete events
- Comment strands-agents#5: Code duplication - invoke_async delegates to stream_async
- Comment strands-agents#6: Async cleanup - proper async context manager pattern
- Comment strands-agents#3: Logging level - changed to debug
- Comment strands-agents#4: Factory simplification - extracted helper method
- Comment strands-agents#12: Documentation - documented A2AStreamEvent behavior
- Comment strands-agents#9: Test fixture - using pytest fixture pattern
- Comment strands-agents#10: Test coverage - added comprehensive e2e tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants