uacp


Nameuacp JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/Undertone0809/uacp
SummaryUniversal Agent Communication Protocol
upload_time2024-04-21 18:14:32
maintainerNone
docs_urlNone
authorUndertone0809
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
    UACP
</h1>
<p align="center">
  🚀 Using Universal Agent Communication Protocol to Build Your Agent 🤖
</p>

## What is UACP?

UACP is an innovative API specification designed to serve as the lingua franca for communication between diverse intelligent Agents. By providing a set of standardized interfaces, UACP enables seamless integration and efficient, flexible interaction among a variety of AI Agents. The design philosophy of UACP is centered around openness, extensibility, and interoperability, ensuring that it can adapt to the evolving technological ecosystem and support use cases ranging from simple automation tasks to complex multi-Agent systems.

## Core Concept

📋**Task Management**: At the heart of UACP is the concept of task management. A task represents a discrete unit of work assigned to an agent, which could range from simple file operations to intricate decision-making processes. UACP defines a clear structure for tasks, ensuring that agents understand what is required and can report their progress and results in a consistent manner.

🔀 **Dynamic Workflow Composition**: UACP introduces dynamic workflow composition, allowing agents to not only execute predefined sequences of actions but also to dynamically determine the next steps based on context, results, and external triggers. This adaptive approach ensures that agents can handle complex, non-linear workflows with ease.

⚡ **Real-Time Interaction**: Real-time interaction is a cornerstone of UACP. Agents can communicate in real-time, exchanging messages, status updates, and data streams. This enables synchronous operations and immediate responses, which are crucial for time-sensitive tasks and collaborative activities among multiple agents.

📈 **Scalability and Extensibility**: UACP is built with scalability in mind. It can support a growing number of agents and tasks without compromising performance. Additionally, the protocol is extensible, allowing for the introduction of new features and capabilities without disrupting existing operations.

🔗 **Interoperability**: UACP emphasizes interoperability, enabling agents built on different frameworks or languages to communicate without barriers. This is achieved through a well-defined API and a set of standard data formats that ensure compatibility across diverse systems.

## Status && Roadmap

UACP is build by [Cogit Lab](). We aim to explore all possible locations in the AGI field. Welcome your coming anytime. Related project: [Promptulate: Large language model automation and Autonomous Language Agents development framework. ](https://github.com/Undertone0809/promptulate)  

## Quick Start

```shell
pip install uacp
```

The following example show how to create a simple agent using UACP:

```python
from typing import Any
import uacp

def task_handler(task: uacp.Task) -> None:
    ...

def step_handler(step: uacp.Step) -> uacp.Step:
    ...

def result_handler(result) -> Any:
    ...

agent = uacp.Agent(task_handler, step_handler, result_handler)
response = agent.run("instruction here")
```

### Build An Agent With Plan, Execute, Reflect

> You can see more detail in `./examples/assistant-agent`

Now the following example will show how to implement a powerful agent with the capabilities to plan, execute, and reflect. This is heavily inspired by the [Plan-and-Solve](https://arxiv.org/abs/2305.04091) paper as well as the [Baby-AGI](https://github.com/yoheinakajima/babyagi) project. We call it **AssistantAgent**.

The core idea is to first come up with a multi-step plan, and then go through that plan one item at a time.
After accomplishing a particular task, you can then revisit the plan and modify as appropriate.

The general computational graph looks like the following:

![plan-and-execute diagram](./docs/images/plan-and-execute.png)

This compares to a typical [ReAct](https://arxiv.org/abs/2210.03629) style agent where you think one step at a time.
The advantages of this "plan-and-execute" style agent are:

1. Explicit long term planning (which even really strong LLMs can struggle with)
2. Ability to use smaller/weaker models for the execution step, only using larger/better models for the planning step

The following example show how to use Assistant Agent to solve a simple problem. Here we use Assistant Agent to solve a question: what is the hometown of the 2024 Australia open winner?

Firstly, we need to install necessary packages.
```bash
pip install langchain, langchain_community, promptulate
```

Now we import the necessary packages:

```python
import os
from enum import Enum
from typing import Callable, Dict, List, Optional, TypedDict

from promptulate import uacp
from promptulate.agents.base import BaseAgent
from promptulate.agents.tool_agent import ToolAgent
from promptulate.agents.tool_agent.agent import ActionResponse
from promptulate.beta.agents.assistant_agent import operations
from promptulate.beta.agents.assistant_agent.schema import Plan
from promptulate.hook import Hook, HookTable
from promptulate.llms.base import BaseLLM
from promptulate.tools.base import ToolTypes
from promptulate.tools.manager import ToolManager
from promptulate.utils.logger import logger
from typing_extensions import NotRequired
```

- Define the tools and LLMs

This example we use [Tavily](https://app.tavily.com/) as a search engine, which is a powerful search engine that can search for information from the web. To use Tavily, you need to get an API key from Tavily.```

```python
os.environ["TAVILY_API_KEY"] = "your_tavily_api_key"
os.environ["OPENAI_API_KEY"] = "your_openai_api_key"
```

Finally, we can create the Assistant Agent and run the question:

```python
class StepTypes(str, Enum):
    PLAN = "plan"
    EXECUTE = "execute"
    REVISE = "revise"


class AdditionalProperties(TypedDict):
    current_plan: dict
    past_steps: NotRequired[str]


class AssistantAgent(BaseAgent):
    """
    An agent who can plan, execute, and revise tasks.
    """

    def __init__(
        self,
        *,
        llm: BaseLLM,
        tools: Optional[List[ToolTypes]] = None,
        max_iterations: Optional[int] = 20,
        **kwargs,
    ):
        super().__init__(agent_type="Assistant Agent", **kwargs)

        self.llm = llm
        self.tool_manager = ToolManager(tools=tools if tools else [])
        self.tool_agent = ToolAgent(
            llm=llm, tool_manager=self.tool_manager, _from="agent"
        )
        self.uacp_agent = uacp.Agent(
            self.task_handler, self.step_handler, self.result_handler
        )
        self.current_task_id: Optional[str] = None
        self.max_iterations: int = max_iterations

        logger.info("Assistant Agent initialized.")

    def _run(
        self, instruction: str, additional_input: dict = None, *args, **kwargs
    ) -> str:
        additional_input = additional_input or {}

        result: str = self.uacp_agent.run(
            input=instruction, additional_input=additional_input
        )
        logger.info(f"Assistant Agent response: {result}")
        return result

    def get_llm(self) -> BaseLLM:
        return self.llm

    @property
    def current_task(self) -> Optional[uacp.Task]:
        """Get the current task, return None if no task is running."""
        if self.current_task_id is None:
            return None

        return self.uacp_agent.db.get_task(self.current_task_id)

    @property
    def current_plan(self) -> Optional[Plan]:
        """Get the current plan. Every step has a current plan stored in
        additional_properties."""
        if self.current_task is None:
            return None

        _: dict = self.current_task.steps[-1].additional_properties.get("current_plan")
        return Plan.parse_obj(_)

    @property
    def execution_steps(self) -> List[uacp.Step]:
        """Get the execution steps from the current task."""
        if self.current_task is None:
            return []

        return [s for s in self.current_task.steps if s.name == StepTypes.EXECUTE]

    def plan(self, step: uacp.Step) -> uacp.Step:
        """Plan the task and create the next step: execute.

        Args:
            step(uacp.Step): The current step.

        Returns:
            uacp.Step: The updated plan step.
        """
        logger.info("[Assistant Agent] Planning now.")

        current_plan: Plan = operations.plan(self.llm, step.input)
        Hook.call_hook(HookTable.ON_AGENT_PLAN, self, plan=current_plan.json())

        # create next step: execute
        task = self.uacp_agent.db.get_task(step.task_id)

        self.uacp_agent.db.create_step(
            task_id=task.task_id,
            name=StepTypes.EXECUTE,
            input=current_plan.tasks[0].description,
            additional_properties=AdditionalProperties(
                current_plan=current_plan.dict()
            ),
        )
        step.output = current_plan.json()

        return step

    def execute(self, step: uacp.Step) -> uacp.Step:
        """Execute the plan and create the next step: revise.

        Args:
            step(uacp.Step): The current step.

        Returns:
            uacp.Step: The updated execute step.
        """
        logger.info("[Assistant Agent] Executing step now.")

        resp: ActionResponse = operations.execute(self.tool_agent, step.input)

        if self.current_plan.get_next_task() is None:
            step.is_last = True
            step.output = resp["action_parameters"]["content"]
            return step

        # create next step: revise
        self.uacp_agent.db.create_step(
            task_id=step.task_id,
            name=StepTypes.REVISE,
            input=resp["action_parameters"]["content"],
            additional_properties=AdditionalProperties(
                current_plan=self.current_plan.dict(),
                past_steps=str(resp),
            ),
        )

        step.output = str(resp)
        return step

    def revise(self, step: uacp.Step) -> uacp.Step:
        """Review the plan and update the plan accordingly. This behavior will decide if
         the plan is complete or not, and if not, will update the plan accordingly.

        Args:
            step(uacp.Step): The current step.

        Returns:
            uacp.Step: The updated revise step.
        """
        logger.info("[Assistant Agent] Reviewing now.")

        revised_plan: Plan = operations.revise(
            llm=self.llm,
            user_target=self.current_task.input,
            original_plan=self.current_plan.json(),
            past_steps=step.additional_properties["past_steps"],
        )

        Hook.call_hook(
            HookTable.ON_AGENT_REVISE_PLAN, self, revised_plan=revised_plan.json()
        )

        if revised_plan.get_next_task() is None:
            step.is_last = True
            step.output = step.input
            return step
        else:
            # create next step: execute
            task = self.uacp_agent.db.get_task(step.task_id)
            self.uacp_agent.db.create_step(
                task_id=task.task_id,
                name=StepTypes.EXECUTE,
                input=revised_plan.get_next_task().description,
                additional_properties=AdditionalProperties(
                    current_plan=revised_plan.dict()
                ),
            )

            step.output = revised_plan.json()

        return step

    def task_handler(self, task: uacp.Task) -> None:
        """Invoke the task and start planning.

        Args:
            task: Task object
        """
        if not task.input:
            raise Exception("No task prompt")

        logger.info(
            f"[Assistant Agent] Task received. Creating Plan step, task input: {task.input}"  # noqa
        )
        self.current_task_id = task.task_id
        self.uacp_agent.db.create_step(
            task_id=task.task_id, name=StepTypes.PLAN, input=task.input
        )

    def step_handler(self, step: uacp.Step) -> uacp.Step:
        logger.info(
            f"[Assistant Agent] Step received. Executing step, step name: {step.name}"
        )
        step_map: Dict[str, Callable] = {
            StepTypes.PLAN: self.plan,
            StepTypes.EXECUTE: self.execute,
            StepTypes.REVISE: self.revise,
        }

        if len(self.current_task.steps) > self.max_iterations:
            final_output: str = self.current_task.steps[-1].output
            step.output = f"Task has too many steps. Aborting. Recently step output: {final_output}"  # noqa
            return step

        if step.name not in step_map:
            raise ValueError(f"Step name {step.name} not found in step mapping.")

        return step_map[step.name](step)

    def result_handler(self, uacp_task: uacp.Task) -> str:
        return uacp_task.steps[-1].output

```


```python
llm = ChatOpenAI(model="gpt-4-1106-preview", temperature=0.0)
agent = AssistantAgent(tools=tools, llm=llm)
agent.run("what is the hometown of the 2024 Australia open winner?")
```

```text
**Output:**

```text
[Agent] Assistant Agent start...
[User instruction] what is the hometown of the 2024 Australia open winner?
[Plan] {"goals": ["Find the hometown of the 2024 Australian Open winner"], "tasks": [{"task_id": 1, "description": "Identify the winner of the 2024 Australian Open."}, {"task_id": 2, "description": "Research the identified winner to find their place of birth or hometown."}, {"task_id": 3, "description": "Record the hometown of the 2024 Australian Open winner."}], "next_task_id": 1}
[Agent] Tool Agent start...
[User instruction] Identify the winner of the 2024 Australian Open.
[Thought] Since the current date is March 26, 2024, and the Australian Open typically takes place in January, the event has likely concluded for the year. To identify the winner, I should use the Tavily search tool to find the most recent information on the 2024 Australian Open winner.
[Action] tavily_search_results_json args: {'query': '2024 Australian Open winner'}
[Observation] [{'url': 'https://ausopen.com/articles/news/sinner-winner-italian-takes-first-major-ao-2024', 'content': 'The agile right-hander, who had claimed victory from a two-set deficit only once previously in his young career, is the second Italian man to achieve singles glory at a major, following Adriano Panatta in1976.With victories over Andrey Rublev, 10-time AO champion Novak Djokovic, and Medvedev, the Italian is the youngest player to defeat top 5 opponents in the final three matches of a major since Michael Stich did it at Wimbledon in 1991 – just weeks before Sinner was born.\n He saved the only break he faced with an ace down the tee, and helped by scoreboard pressure, broke Medvedev by slamming a huge forehand to force an error from his more experienced rival, sealing the fourth set to take the final to a decider.\n Sensing a shift in momentum as Medvedev served to close out the second at 5-3, Sinner set the RLA crowd alight with a pair of brilliant passing shots en route to creating a break point opportunity, which Medvedev snuffed out with trademark patience, drawing a forehand error from his opponent. “We are trying to get better every day, even during the tournament we try to get stronger, trying to understand every situation a little bit better, and I’m so glad to have you there supporting me, understanding me, which sometimes it’s not easy because I am a little bit young sometimes,” he said with a smile.\n Medvedev, who held to love in his first three service games of the second set, piled pressure on the Italian, forcing the right-hander to produce his best tennis to save four break points in a nearly 12-minute second game.\n'}, {'url': 'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-claims-first-grand-slam-title-in-epic-comeback-win-over-daniil-medvedev/', 'content': '"\nOur Latest Tennis Stories\nSinner makes epic comeback to win Australian Open\nSinner, Sabalenka win Australian Open singles titles\n2024 Australian Open odds, Sinner vs. Medvedev picks\nSabalenka defeats Zheng to win 2024 Australian Open\n2024 Australian Open odds, Sabalenka vs. Zheng picks\n2024 Australian Open odds, Medvedev vs. Zverev picks\nAustralian Open odds: Djokovic vs. Sinner picks, bets\nAustralian Open odds: Gauff vs. Sabalenka picks, bets\nAustralian Open odds: Zheng vs. Yastremska picks, bets\nNick Kyrgios reveals he\'s contemplating retirement\n© 2004-2024 CBS Interactive. Jannik Sinner claims first Grand Slam title in epic comeback win over Daniil Medvedev\nSinner, 22, rallied back from a two-set deficit to become the third ever Italian Grand Slam men\'s singles champion\nAfter almost four hours, Jannik Sinner climbed back from a two-set deficit to win his first ever Grand Slam title with an epic 3-6, 3-6, 6-4, 6-4, 6-3 comeback victory against Daniil Medvedev. Sinner became the first Italian man to win the Australian Open since 1976, and just the eighth man to successfully come back from two sets down in a major final.\n He did not drop a single set until his meeting with Djokovic, and that win in itself was an accomplishment as Djokovic was riding a 33-match winning streak at the Australian Open and had never lost a semifinal in Melbourne.\n @janniksin • @wwos • @espn • @eurosport • @wowowtennis pic.twitter.com/DTCIqWoUoR\n"We are trying to get better everyday, and even during the tournament, trying to get stronger and understand the situation a little bit better," Sinner said.'}, {'url': 'https://www.bbc.com/sport/tennis/68120937', 'content': 'Live scores, results and order of play\nAlerts: Get tennis news sent to your phone\nRelated Topics\nTop Stories\nFA Cup: Blackburn Rovers v Wrexham - live text commentary\nRussian skater Valieva given four-year ban for doping\nLinks to Barcelona are \'totally untrue\' - Arteta\nElsewhere on the BBC\nThe truth behind the fake grooming scandal\nFeaturing unseen police footage and interviews with the officers at the heart of the case\nDid their father and uncle kill Nazi war criminals?\n A real-life murder mystery following three brothers in their quest for the truth\nWhat was it like to travel on the fastest plane?\nTake a behind-the-scenes look at the supersonic story of the Concorde\nToxic love, ruthless ambition and shocking betrayal\nTell Me Lies follows a passionate college relationship with unimaginable consequences...\n "\nMarathon man Medvedev runs out of steam\nMedvedev is the first player to lose two Grand Slam finals after winning the opening two sets\nSo many players with the experience of a Grand Slam final have talked about how different the occasion can be, particularly if it is the first time, and potentially overwhelming.\n Jannik Sinner beats Daniil Medvedev in Melbourne final\nJannik Sinner is the youngest player to win the Australian Open men\'s title since Novak Djokovic in 2008\nJannik Sinner landed the Grand Slam title he has long promised with an extraordinary fightback to beat Daniil Medvedev in the Australian Open final.\n "\nSinner starts 2024 in inspired form\nSinner won the first Australian Open men\'s final since 2005 which did not feature Roger Federer, Rafael Nadal or Novak Djokovic\nSinner was brought to the forefront of conversation when discussing Grand Slam champions in 2024 following a stunning end to last season.\n'}]
[Execute Result] {'thought': "The search results have provided consistent information about the winner of the 2024 Australian Open. Jannik Sinner is mentioned as the winner in multiple sources, which confirms the answer to the user's question.", 'action_name': 'finish', 'action_parameters': {'content': 'Jannik Sinner won the 2024 Australian Open.'}}
[Execute] Execute End.
[Revised Plan] {"goals": ["Find the hometown of the 2024 Australian Open winner"], "tasks": [{"task_id": 2, "description": "Research Jannik Sinner to find his place of birth or hometown."}, {"task_id": 3, "description": "Record the hometown of Jannik Sinner, the 2024 Australian Open winner."}], "next_task_id": 2}
[Agent] Tool Agent start...
[User instruction] Research Jannik Sinner to find his place of birth or hometown.
[Thought] To find Jannik Sinner's place of birth or hometown, I should use the search tool to find the most recent and accurate information.
[Action] tavily_search_results_json args: {'query': 'Jannik Sinner place of birth hometown'}
[Observation] [{'url': 'https://www.sportskeeda.com/tennis/jannik-sinner-nationality', 'content': "During the semifinal of the Cup, Sinner faced Djokovic for the third time in a row and became the first player to defeat him in a singles match. Jannik Sinner Nationality\nJannik Sinner is an Italian national and was born in Innichen, a town located in the mainly German-speaking area of South Tyrol in northern Italy. A. Jannik Sinner won his maiden Masters 1000 title at the 2023 Canadian Open defeating Alex de Minaur in the straight sets of the final.\n Apart from his glorious triumph at Melbourne Park in 2024, Jannik Sinner's best Grand Slam performance came at the 2023 Wimbledon, where he reached the semifinals. In 2020, Sinner became the youngest player since Novak Djokovic in 2006 to reach the quarter-finals of the French Open."}, {'url': 'https://en.wikipedia.org/wiki/Jannik_Sinner', 'content': "At the 2023 Australian Open, Sinner lost in the 4th round to eventual runner-up Stefanos Tsitsipas in 5 sets.[87]\nSinner then won his seventh title at the Open Sud de France in Montpellier, becoming the first player to win a tour-level title in the season without having dropped a single set and the first since countryman Lorenzo Musetti won the title in Naples in October 2022.[88]\nAt the ABN AMRO Open he defeated top seed and world No. 3 Stefanos Tsitsipas taking his revenge for the Australian Open loss, for his biggest win ever.[89] At the Cincinnati Masters, he lost in the third round to Félix Auger-Aliassime after being up a set, a break, and 2 match points.[76]\nSeeded 11th at the US Open, he reached the fourth round after defeating Brandon Nakashima in four sets.[77] Next, he defeated Ilya Ivashka in a five set match lasting close to four hours to reach the quarterfinals for the first time at this Major.[78] At five hours and 26 minutes, it was the longest match of Sinner's career up until this point and the fifth-longest in the tournament history[100] as well as the second longest of the season after Andy Murray against Thanasi Kokkinakis at the Australian Open.[101]\nHe reached back to back quarterfinals in Wimbledon after defeating Juan Manuel Cerundolo, Diego Schwartzman, Quentin Halys and Daniel Elahi Galan.[102] He then reached his first Major semifinal after defeating Roman Safiullin, before losing to Novak Djokovic in straight sets.[103] In the following round in the semifinals, he lost in straight sets to career rival and top seed Carlos Alcaraz who returned to world No. 1 following the tournament.[92] In Miami, he reached the quarterfinals of this tournament for a third straight year after defeating Grigor Dimitrov and Andrey Rublev, thus returning to the top 10 in the rankings at world No. In the final, he came from a two-set deficit to beat Daniil Medvedev to become the first Italian player, male or female, to win the Australian Open singles title, and the third man to win a Major (the second of which is in the Open Era), the first in 48 years.[8][122]"}, {'url': 'https://www.thesportreview.com/biography/jannik-sinner/', 'content': '• Date of birth: 16 August 2001\n• Age: 22 years old\n• Place of birth: San Candido, Italy\n• Nationality: Italian\n• Height: 188cm / 6ft 2ins\n• Weight: 76kg / 167lbs\n• Plays: Right-handed\n• Turned Pro: 2018\n• Career Prize Money: US$ 4,896,338\n• Instagram: @janniksin\nThe impressive 22-year-old turned professional back in 2018 and soon made an impact on the tour, breaking into the top 100 in the world rankings for the first time in 2019.\n Jannik Sinner (Photo: Dubai Duty Free Tennis Championships)\nSinner ended the season as number 78 in the world, becoming the youngest player since Rafael Nadal in 2003 to end the year in the top 80.\n The Italian then ended the 2019 season in style, qualifying for the 2019 Next Gen ATP Finals and going on to win the tournament with a win over Alex de Minaur in the final.\n Sinner then reached the main draw of a grand slam for the first time at the 2019 US Open, when he came through qualifying to reach the first round, where he lost to Stan Wawrinka.\n Asked to acknowledge some of the key figures in his development, Sinner replied: “I think first of all, my family who always helped me and gave me the confidence to actually change my life when I was 13-and-a-half, 14 years old.\n'}]
[Execute Result] {'thought': 'The search results have provided two different places of birth for Jannik Sinner: Innichen and San Candido. These are actually the same place, as San Candido is the Italian name and Innichen is the German name for the town. Since the user asked for the place of birth or hometown, I can now provide this information.', 'action_name': 'finish', 'action_parameters': {'content': 'Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy.'}}
[Execute] Execute End.
[Revised Plan] {"goals": ["Find the hometown of the 2024 Australian Open winner"], "tasks": [], "next_task_id": null}
[Agent Result] Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy.
[Agent] Agent End.
```

## How it works?

You can see the detail in log information, let's explain it step by step.

> You can see more detail data in the log file, see [here](other/log_system.md) to find it.

When AssistantAgent receives the question, it first creates a plan to solve the question. The plan is a list of tasks that need to be done to solve the question. In this case, the plan result is as follows:

```json
{
  "goals": [
    "Find the hometown of the 2024 Australian Open winner"
  ],
  "tasks": [
    {
      "task_id": 1,
      "description": "Identify the winner of the 2024 Australian Open."
    },
    {
      "task_id": 2,
      "description": "Search for the biography or profile of the identified winner to find their hometown."
    },
    {
      "task_id": 3,
      "description": "Record the hometown of the 2024 Australian Open winner."
    }
  ],
  "next_task_id": 1
}
```

Firstly, agent will run the first task, which is to identify the winner of the 2024 Australian Open. The agent uses the Tavily search tool to find the most recent information on the 2024 Australian Open winner. The search result shows that Jannik Sinner is the winner of the 2024 Australian Open. The agent then revises the plan to the following:

```json
{
    "goals": [
        "Find the hometown of the 2024 Australian Open winner"
    ],
    "tasks": [
        {
            "task_id": 2,
            "description": "Research Jannik Sinner to find his place of birth or hometown."
        },
        {
            "task_id": 3,
            "description": "Record the hometown of Jannik Sinner, the 2024 Australian Open winner."
        }
    ],
    "next_task_id": 2
}
```

The agent then runs the second task, which is to research Jannik Sinner to find his place of birth or hometown. The agent uses the Tavily search tool to find the most recent and accurate information. The search result shows that Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy. The agent then records the result and finishes the task.

Finally, the agent completes the plan and provides the answer to the user: Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy.


## Development Guide

1. Clone the project to your local machine:

```bash
git clone https://github.com/Undertone0809/UACP
cd UACP
```

2. If you don't have `Poetry`. 

Conda environment is is recommended.

```bash
conda create -n uacp python==3.10
```

Please activate python of current project and install run:

```bash
conda activate uacp
pip install poetry
```


## 📖 Makefile usage

[`Makefile`](https://github.com/Undertone0809/ecjtu/blob/main/Makefile) contains a lot of functions for faster development.

<details>
<summary>Install all dependencies and pre-commit hooks</summary>
<p>

Install requirements:

```bash
make install
```

Pre-commit hooks coulb be installed after `git init` via

```bash
make pre-commit-install
```

</p>
</details>

<details>
<summary>Codestyle and type checks</summary>
<p>

Automatic format uses `ruff`.

```bash
make polish-codestyle

# or use synonym
make format
```

Codestyle checks only, without rewriting files:

```bash
make check-codestyle
```

> Note: `check-codestyle` uses `ruff` and `darglint` library

</p>
</details>

<details>
<summary>Code security</summary>
<p>

> If this command is not selected during installation, it cannnot be used.

```bash
make check-safety
```

This command launches `Poetry` integrity checks as well as identifies security issues with `Safety` and `Bandit`.

```bash
make check-safety
```

</p>
</details>

<details>
<summary>Tests with coverage badges</summary>
<p>

Run `pytest`

```bash
make test
```

</p>
</details>

<details>
<summary>All linters</summary>
<p>

Of course there is a command to run all linters in one:

```bash
make lint
```

the same as:

```bash
make check-codestyle && make test && make check-safety
```

</p>
</details>

<details>
<summary>Docker</summary>
<p>

```bash
make docker-build
```

which is equivalent to:

```bash
make docker-build VERSION=latest
```

Remove docker image with

```bash
make docker-remove
```

More information [about docker](https://github.com/Undertone0809/python-package-template/tree/main/%7B%7B%20cookiecutter.project_name%20%7D%7D/docker).

</p>
</details>

<details>
<summary>Cleanup</summary>
<p>
Delete pycache files

```bash
make pycache-remove
```

Remove package build

```bash
make build-remove
```

Delete .DS_STORE files

```bash
make dsstore-remove
```

Remove .mypycache

```bash
make mypycache-remove
```

Or to remove all above run:

```bash
make cleanup
```

</p>
</details>

## 📝 Log system

When you run UACP, all the logs are stored in a log folder. UACP divides the logs by date, which means that each day will have a separate log file.

You can find the logs in the following path:

- windows: `/Users/username/.uacp/logs`
- linux: `/home/username/.uacp/logs`

## 🛡 License

This project is licensed under the terms of the `MIT` license. See [LICENSE](https://github.com/Undertone0809/uacp/blob/master/LICENSE) for more details.

## 📃 Citation

```bibtex
@misc{uacp,
  author = {Zeelnad},
  title = {Universal Agent Communication Protocol},
  year = {2024},
  publisher = {Underonte0809},
  journal = {https://github.com/Undertone0809/UACP},
  howpublished = {\url{https://github.com/Undertone0809/uacp}}
}
```


## 💌 Contact

For more information, please contact: [zeeland4work@gmail.com](mailto:zeeland4work@gmail.com)

> This project was generated with [3PG](https://github.com/Undertone0809/3PG)

## ⭐ Contribution

We welcome contributions to UACP! Please check out the [Contribution Guide](./CONTRIBUTING.md) for guidelines on how to proceed.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Undertone0809/uacp",
    "name": "uacp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Undertone0809",
    "author_email": "zeeland4work@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/07/a5/78e2b5a7cbf76bb17360e06342916025ef3a12eb15c18755cb516885ccdb/uacp-0.1.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\n    UACP\n</h1>\n<p align=\"center\">\n  \ud83d\ude80 Using Universal Agent Communication Protocol to Build Your Agent \ud83e\udd16\n</p>\n\n## What is UACP?\n\nUACP is an innovative API specification designed to serve as the lingua franca for communication between diverse intelligent Agents. By providing a set of standardized interfaces, UACP enables seamless integration and efficient, flexible interaction among a variety of AI Agents. The design philosophy of UACP is centered around openness, extensibility, and interoperability, ensuring that it can adapt to the evolving technological ecosystem and support use cases ranging from simple automation tasks to complex multi-Agent systems.\n\n## Core Concept\n\n\ud83d\udccb**Task Management**: At the heart of UACP is the concept of task management. A task represents a discrete unit of work assigned to an agent, which could range from simple file operations to intricate decision-making processes. UACP defines a clear structure for tasks, ensuring that agents understand what is required and can report their progress and results in a consistent manner.\n\n\ud83d\udd00 **Dynamic Workflow Composition**: UACP introduces dynamic workflow composition, allowing agents to not only execute predefined sequences of actions but also to dynamically determine the next steps based on context, results, and external triggers. This adaptive approach ensures that agents can handle complex, non-linear workflows with ease.\n\n\u26a1 **Real-Time Interaction**: Real-time interaction is a cornerstone of UACP. Agents can communicate in real-time, exchanging messages, status updates, and data streams. This enables synchronous operations and immediate responses, which are crucial for time-sensitive tasks and collaborative activities among multiple agents.\n\n\ud83d\udcc8 **Scalability and Extensibility**: UACP is built with scalability in mind. It can support a growing number of agents and tasks without compromising performance. Additionally, the protocol is extensible, allowing for the introduction of new features and capabilities without disrupting existing operations.\n\n\ud83d\udd17 **Interoperability**: UACP emphasizes interoperability, enabling agents built on different frameworks or languages to communicate without barriers. This is achieved through a well-defined API and a set of standard data formats that ensure compatibility across diverse systems.\n\n## Status && Roadmap\n\nUACP is build by [Cogit Lab](). We aim to explore all possible locations in the AGI field. Welcome your coming anytime. Related project: [Promptulate: Large language model automation and Autonomous Language Agents development framework. ](https://github.com/Undertone0809/promptulate)  \n\n## Quick Start\n\n```shell\npip install uacp\n```\n\nThe following example show how to create a simple agent using UACP:\n\n```python\nfrom typing import Any\nimport uacp\n\ndef task_handler(task: uacp.Task) -> None:\n    ...\n\ndef step_handler(step: uacp.Step) -> uacp.Step:\n    ...\n\ndef result_handler(result) -> Any:\n    ...\n\nagent = uacp.Agent(task_handler, step_handler, result_handler)\nresponse = agent.run(\"instruction here\")\n```\n\n### Build An Agent With Plan, Execute, Reflect\n\n> You can see more detail in `./examples/assistant-agent`\n\nNow the following example will show how to implement a powerful agent with the capabilities to plan, execute, and reflect. This is heavily inspired by the [Plan-and-Solve](https://arxiv.org/abs/2305.04091) paper as well as the [Baby-AGI](https://github.com/yoheinakajima/babyagi) project. We call it **AssistantAgent**.\n\nThe core idea is to first come up with a multi-step plan, and then go through that plan one item at a time.\nAfter accomplishing a particular task, you can then revisit the plan and modify as appropriate.\n\nThe general computational graph looks like the following:\n\n![plan-and-execute diagram](./docs/images/plan-and-execute.png)\n\nThis compares to a typical [ReAct](https://arxiv.org/abs/2210.03629) style agent where you think one step at a time.\nThe advantages of this \"plan-and-execute\" style agent are:\n\n1. Explicit long term planning (which even really strong LLMs can struggle with)\n2. Ability to use smaller/weaker models for the execution step, only using larger/better models for the planning step\n\nThe following example show how to use Assistant Agent to solve a simple problem. Here we use Assistant Agent to solve a question: what is the hometown of the 2024 Australia open winner?\n\nFirstly, we need to install necessary packages.\n```bash\npip install langchain, langchain_community, promptulate\n```\n\nNow we import the necessary packages:\n\n```python\nimport os\nfrom enum import Enum\nfrom typing import Callable, Dict, List, Optional, TypedDict\n\nfrom promptulate import uacp\nfrom promptulate.agents.base import BaseAgent\nfrom promptulate.agents.tool_agent import ToolAgent\nfrom promptulate.agents.tool_agent.agent import ActionResponse\nfrom promptulate.beta.agents.assistant_agent import operations\nfrom promptulate.beta.agents.assistant_agent.schema import Plan\nfrom promptulate.hook import Hook, HookTable\nfrom promptulate.llms.base import BaseLLM\nfrom promptulate.tools.base import ToolTypes\nfrom promptulate.tools.manager import ToolManager\nfrom promptulate.utils.logger import logger\nfrom typing_extensions import NotRequired\n```\n\n- Define the tools and LLMs\n\nThis example we use [Tavily](https://app.tavily.com/) as a search engine, which is a powerful search engine that can search for information from the web. To use Tavily, you need to get an API key from Tavily.```\n\n```python\nos.environ[\"TAVILY_API_KEY\"] = \"your_tavily_api_key\"\nos.environ[\"OPENAI_API_KEY\"] = \"your_openai_api_key\"\n```\n\nFinally, we can create the Assistant Agent and run the question:\n\n```python\nclass StepTypes(str, Enum):\n    PLAN = \"plan\"\n    EXECUTE = \"execute\"\n    REVISE = \"revise\"\n\n\nclass AdditionalProperties(TypedDict):\n    current_plan: dict\n    past_steps: NotRequired[str]\n\n\nclass AssistantAgent(BaseAgent):\n    \"\"\"\n    An agent who can plan, execute, and revise tasks.\n    \"\"\"\n\n    def __init__(\n        self,\n        *,\n        llm: BaseLLM,\n        tools: Optional[List[ToolTypes]] = None,\n        max_iterations: Optional[int] = 20,\n        **kwargs,\n    ):\n        super().__init__(agent_type=\"Assistant Agent\", **kwargs)\n\n        self.llm = llm\n        self.tool_manager = ToolManager(tools=tools if tools else [])\n        self.tool_agent = ToolAgent(\n            llm=llm, tool_manager=self.tool_manager, _from=\"agent\"\n        )\n        self.uacp_agent = uacp.Agent(\n            self.task_handler, self.step_handler, self.result_handler\n        )\n        self.current_task_id: Optional[str] = None\n        self.max_iterations: int = max_iterations\n\n        logger.info(\"Assistant Agent initialized.\")\n\n    def _run(\n        self, instruction: str, additional_input: dict = None, *args, **kwargs\n    ) -> str:\n        additional_input = additional_input or {}\n\n        result: str = self.uacp_agent.run(\n            input=instruction, additional_input=additional_input\n        )\n        logger.info(f\"Assistant Agent response: {result}\")\n        return result\n\n    def get_llm(self) -> BaseLLM:\n        return self.llm\n\n    @property\n    def current_task(self) -> Optional[uacp.Task]:\n        \"\"\"Get the current task, return None if no task is running.\"\"\"\n        if self.current_task_id is None:\n            return None\n\n        return self.uacp_agent.db.get_task(self.current_task_id)\n\n    @property\n    def current_plan(self) -> Optional[Plan]:\n        \"\"\"Get the current plan. Every step has a current plan stored in\n        additional_properties.\"\"\"\n        if self.current_task is None:\n            return None\n\n        _: dict = self.current_task.steps[-1].additional_properties.get(\"current_plan\")\n        return Plan.parse_obj(_)\n\n    @property\n    def execution_steps(self) -> List[uacp.Step]:\n        \"\"\"Get the execution steps from the current task.\"\"\"\n        if self.current_task is None:\n            return []\n\n        return [s for s in self.current_task.steps if s.name == StepTypes.EXECUTE]\n\n    def plan(self, step: uacp.Step) -> uacp.Step:\n        \"\"\"Plan the task and create the next step: execute.\n\n        Args:\n            step(uacp.Step): The current step.\n\n        Returns:\n            uacp.Step: The updated plan step.\n        \"\"\"\n        logger.info(\"[Assistant Agent] Planning now.\")\n\n        current_plan: Plan = operations.plan(self.llm, step.input)\n        Hook.call_hook(HookTable.ON_AGENT_PLAN, self, plan=current_plan.json())\n\n        # create next step: execute\n        task = self.uacp_agent.db.get_task(step.task_id)\n\n        self.uacp_agent.db.create_step(\n            task_id=task.task_id,\n            name=StepTypes.EXECUTE,\n            input=current_plan.tasks[0].description,\n            additional_properties=AdditionalProperties(\n                current_plan=current_plan.dict()\n            ),\n        )\n        step.output = current_plan.json()\n\n        return step\n\n    def execute(self, step: uacp.Step) -> uacp.Step:\n        \"\"\"Execute the plan and create the next step: revise.\n\n        Args:\n            step(uacp.Step): The current step.\n\n        Returns:\n            uacp.Step: The updated execute step.\n        \"\"\"\n        logger.info(\"[Assistant Agent] Executing step now.\")\n\n        resp: ActionResponse = operations.execute(self.tool_agent, step.input)\n\n        if self.current_plan.get_next_task() is None:\n            step.is_last = True\n            step.output = resp[\"action_parameters\"][\"content\"]\n            return step\n\n        # create next step: revise\n        self.uacp_agent.db.create_step(\n            task_id=step.task_id,\n            name=StepTypes.REVISE,\n            input=resp[\"action_parameters\"][\"content\"],\n            additional_properties=AdditionalProperties(\n                current_plan=self.current_plan.dict(),\n                past_steps=str(resp),\n            ),\n        )\n\n        step.output = str(resp)\n        return step\n\n    def revise(self, step: uacp.Step) -> uacp.Step:\n        \"\"\"Review the plan and update the plan accordingly. This behavior will decide if\n         the plan is complete or not, and if not, will update the plan accordingly.\n\n        Args:\n            step(uacp.Step): The current step.\n\n        Returns:\n            uacp.Step: The updated revise step.\n        \"\"\"\n        logger.info(\"[Assistant Agent] Reviewing now.\")\n\n        revised_plan: Plan = operations.revise(\n            llm=self.llm,\n            user_target=self.current_task.input,\n            original_plan=self.current_plan.json(),\n            past_steps=step.additional_properties[\"past_steps\"],\n        )\n\n        Hook.call_hook(\n            HookTable.ON_AGENT_REVISE_PLAN, self, revised_plan=revised_plan.json()\n        )\n\n        if revised_plan.get_next_task() is None:\n            step.is_last = True\n            step.output = step.input\n            return step\n        else:\n            # create next step: execute\n            task = self.uacp_agent.db.get_task(step.task_id)\n            self.uacp_agent.db.create_step(\n                task_id=task.task_id,\n                name=StepTypes.EXECUTE,\n                input=revised_plan.get_next_task().description,\n                additional_properties=AdditionalProperties(\n                    current_plan=revised_plan.dict()\n                ),\n            )\n\n            step.output = revised_plan.json()\n\n        return step\n\n    def task_handler(self, task: uacp.Task) -> None:\n        \"\"\"Invoke the task and start planning.\n\n        Args:\n            task: Task object\n        \"\"\"\n        if not task.input:\n            raise Exception(\"No task prompt\")\n\n        logger.info(\n            f\"[Assistant Agent] Task received. Creating Plan step, task input: {task.input}\"  # noqa\n        )\n        self.current_task_id = task.task_id\n        self.uacp_agent.db.create_step(\n            task_id=task.task_id, name=StepTypes.PLAN, input=task.input\n        )\n\n    def step_handler(self, step: uacp.Step) -> uacp.Step:\n        logger.info(\n            f\"[Assistant Agent] Step received. Executing step, step name: {step.name}\"\n        )\n        step_map: Dict[str, Callable] = {\n            StepTypes.PLAN: self.plan,\n            StepTypes.EXECUTE: self.execute,\n            StepTypes.REVISE: self.revise,\n        }\n\n        if len(self.current_task.steps) > self.max_iterations:\n            final_output: str = self.current_task.steps[-1].output\n            step.output = f\"Task has too many steps. Aborting. Recently step output: {final_output}\"  # noqa\n            return step\n\n        if step.name not in step_map:\n            raise ValueError(f\"Step name {step.name} not found in step mapping.\")\n\n        return step_map[step.name](step)\n\n    def result_handler(self, uacp_task: uacp.Task) -> str:\n        return uacp_task.steps[-1].output\n\n```\n\n\n```python\nllm = ChatOpenAI(model=\"gpt-4-1106-preview\", temperature=0.0)\nagent = AssistantAgent(tools=tools, llm=llm)\nagent.run(\"what is the hometown of the 2024 Australia open winner?\")\n```\n\n```text\n**Output:**\n\n```text\n[Agent] Assistant Agent start...\n[User instruction] what is the hometown of the 2024 Australia open winner?\n[Plan] {\"goals\": [\"Find the hometown of the 2024 Australian Open winner\"], \"tasks\": [{\"task_id\": 1, \"description\": \"Identify the winner of the 2024 Australian Open.\"}, {\"task_id\": 2, \"description\": \"Research the identified winner to find their place of birth or hometown.\"}, {\"task_id\": 3, \"description\": \"Record the hometown of the 2024 Australian Open winner.\"}], \"next_task_id\": 1}\n[Agent] Tool Agent start...\n[User instruction] Identify the winner of the 2024 Australian Open.\n[Thought] Since the current date is March 26, 2024, and the Australian Open typically takes place in January, the event has likely concluded for the year. To identify the winner, I should use the Tavily search tool to find the most recent information on the 2024 Australian Open winner.\n[Action] tavily_search_results_json args: {'query': '2024 Australian Open winner'}\n[Observation] [{'url': 'https://ausopen.com/articles/news/sinner-winner-italian-takes-first-major-ao-2024', 'content': 'The agile right-hander, who had claimed victory from a two-set deficit only once previously in his young career, is the second Italian man to achieve singles glory at a major, following Adriano Panatta in1976.With victories over Andrey Rublev, 10-time AO champion Novak Djokovic, and Medvedev, the Italian is the youngest player to defeat top 5 opponents in the final three matches of a major since Michael Stich did it at Wimbledon in 1991 \u2013 just weeks before Sinner was born.\\n He saved the only break he faced with an ace down the tee, and helped by scoreboard pressure, broke Medvedev by slamming a huge forehand to force an error from his more experienced rival, sealing the fourth set to take the final to a decider.\\n Sensing a shift in momentum as Medvedev served to close out the second at 5-3, Sinner set the RLA crowd alight with a pair of brilliant passing shots en route to creating a break point opportunity, which Medvedev snuffed out with trademark patience, drawing a forehand error from his opponent. \u201cWe are trying to get better every day, even during the tournament we try to get stronger, trying to understand every situation a little bit better, and I\u2019m so glad to have you there supporting me, understanding me, which sometimes it\u2019s not easy because I am a little bit young sometimes,\u201d he said with a smile.\\n Medvedev, who held to love in his first three service games of the second set, piled pressure on the Italian, forcing the right-hander to produce his best tennis to save four break points in a nearly 12-minute second game.\\n'}, {'url': 'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-claims-first-grand-slam-title-in-epic-comeback-win-over-daniil-medvedev/', 'content': '\"\\nOur Latest Tennis Stories\\nSinner makes epic comeback to win Australian Open\\nSinner, Sabalenka win Australian Open singles titles\\n2024 Australian Open odds, Sinner vs. Medvedev picks\\nSabalenka defeats Zheng to win 2024 Australian Open\\n2024 Australian Open odds, Sabalenka vs. Zheng picks\\n2024 Australian Open odds, Medvedev vs. Zverev picks\\nAustralian Open odds: Djokovic vs. Sinner picks, bets\\nAustralian Open odds: Gauff vs. Sabalenka picks, bets\\nAustralian Open odds: Zheng vs. Yastremska picks, bets\\nNick Kyrgios reveals he\\'s contemplating retirement\\n\u00a9 2004-2024 CBS Interactive. Jannik Sinner claims first Grand Slam title in epic comeback win over Daniil Medvedev\\nSinner, 22, rallied back from a two-set deficit to become the third ever Italian Grand Slam men\\'s singles champion\\nAfter almost four hours, Jannik Sinner climbed back from a two-set deficit to win his first ever Grand Slam title with an epic 3-6, 3-6, 6-4, 6-4, 6-3 comeback victory against Daniil Medvedev. Sinner became the first Italian man to win the Australian Open since 1976, and just the eighth man to successfully come back from two sets down in a major final.\\n He did not drop a single set until his meeting with Djokovic, and that win in itself was an accomplishment as Djokovic was riding a 33-match winning streak at the Australian Open and had never lost a semifinal in Melbourne.\\n @janniksin \u2022 @wwos \u2022 @espn \u2022 @eurosport \u2022 @wowowtennis pic.twitter.com/DTCIqWoUoR\\n\"We are trying to get better everyday, and even during the tournament, trying to get stronger and understand the situation a little bit better,\" Sinner said.'}, {'url': 'https://www.bbc.com/sport/tennis/68120937', 'content': 'Live scores, results and order of play\\nAlerts: Get tennis news sent to your phone\\nRelated Topics\\nTop Stories\\nFA Cup: Blackburn Rovers v Wrexham - live text commentary\\nRussian skater Valieva given four-year ban for doping\\nLinks to Barcelona are \\'totally untrue\\' - Arteta\\nElsewhere on the BBC\\nThe truth behind the fake grooming scandal\\nFeaturing unseen police footage and interviews with the officers at the heart of the case\\nDid their father and uncle kill Nazi war criminals?\\n A real-life murder mystery following three brothers in their quest for the truth\\nWhat was it like to travel on the fastest plane?\\nTake a behind-the-scenes look at the supersonic story of the Concorde\\nToxic love, ruthless ambition and shocking betrayal\\nTell Me Lies follows a passionate college relationship with unimaginable consequences...\\n \"\\nMarathon man Medvedev runs out of steam\\nMedvedev is the first player to lose two Grand Slam finals after winning the opening two sets\\nSo many players with the experience of a Grand Slam final have talked about how different the occasion can be, particularly if it is the first time, and potentially overwhelming.\\n Jannik Sinner beats Daniil Medvedev in Melbourne final\\nJannik Sinner is the youngest player to win the Australian Open men\\'s title since Novak Djokovic in 2008\\nJannik Sinner landed the Grand Slam title he has long promised with an extraordinary fightback to beat Daniil Medvedev in the Australian Open final.\\n \"\\nSinner starts 2024 in inspired form\\nSinner won the first Australian Open men\\'s final since 2005 which did not feature Roger Federer, Rafael Nadal or Novak Djokovic\\nSinner was brought to the forefront of conversation when discussing Grand Slam champions in 2024 following a stunning end to last season.\\n'}]\n[Execute Result] {'thought': \"The search results have provided consistent information about the winner of the 2024 Australian Open. Jannik Sinner is mentioned as the winner in multiple sources, which confirms the answer to the user's question.\", 'action_name': 'finish', 'action_parameters': {'content': 'Jannik Sinner won the 2024 Australian Open.'}}\n[Execute] Execute End.\n[Revised Plan] {\"goals\": [\"Find the hometown of the 2024 Australian Open winner\"], \"tasks\": [{\"task_id\": 2, \"description\": \"Research Jannik Sinner to find his place of birth or hometown.\"}, {\"task_id\": 3, \"description\": \"Record the hometown of Jannik Sinner, the 2024 Australian Open winner.\"}], \"next_task_id\": 2}\n[Agent] Tool Agent start...\n[User instruction] Research Jannik Sinner to find his place of birth or hometown.\n[Thought] To find Jannik Sinner's place of birth or hometown, I should use the search tool to find the most recent and accurate information.\n[Action] tavily_search_results_json args: {'query': 'Jannik Sinner place of birth hometown'}\n[Observation] [{'url': 'https://www.sportskeeda.com/tennis/jannik-sinner-nationality', 'content': \"During the semifinal of the Cup, Sinner faced Djokovic for the third time in a row and became the first player to defeat him in a singles match. Jannik Sinner Nationality\\nJannik Sinner is an Italian national and was born in Innichen, a town located in the mainly German-speaking area of South Tyrol in northern Italy. A. Jannik Sinner won his maiden Masters 1000 title at the 2023 Canadian Open defeating Alex de Minaur in the straight sets of the final.\\n Apart from his glorious triumph at Melbourne Park in 2024, Jannik Sinner's best Grand Slam performance came at the 2023 Wimbledon, where he reached the semifinals. In 2020, Sinner became the youngest player since Novak Djokovic in 2006 to reach the quarter-finals of the French Open.\"}, {'url': 'https://en.wikipedia.org/wiki/Jannik_Sinner', 'content': \"At the 2023 Australian Open, Sinner lost in the 4th round to eventual runner-up Stefanos Tsitsipas in 5 sets.[87]\\nSinner then won his seventh title at the Open Sud de France in Montpellier, becoming the first player to win a tour-level title in the season without having dropped a single set and the first since countryman Lorenzo Musetti won the title in Naples in October 2022.[88]\\nAt the ABN AMRO Open he defeated top seed and world No. 3 Stefanos Tsitsipas taking his revenge for the Australian Open loss, for his biggest win ever.[89] At the Cincinnati Masters, he lost in the third round to F\u00e9lix Auger-Aliassime after being up a set, a break, and 2 match points.[76]\\nSeeded 11th at the US Open, he reached the fourth round after defeating Brandon Nakashima in four sets.[77] Next, he defeated Ilya Ivashka in a five set match lasting close to four hours to reach the quarterfinals for the first time at this Major.[78] At five hours and 26 minutes, it was the longest match of Sinner's career up until this point and the fifth-longest in the tournament history[100] as well as the second longest of the season after Andy Murray against Thanasi Kokkinakis at the Australian Open.[101]\\nHe reached back to back quarterfinals in Wimbledon after defeating Juan Manuel Cerundolo, Diego Schwartzman, Quentin Halys and Daniel Elahi Galan.[102] He then reached his first Major semifinal after defeating Roman Safiullin, before losing to Novak Djokovic in straight sets.[103] In the following round in the semifinals, he lost in straight sets to career rival and top seed Carlos Alcaraz who returned to world No. 1 following the tournament.[92] In Miami, he reached the quarterfinals of this tournament for a third straight year after defeating Grigor Dimitrov and Andrey Rublev, thus returning to the top 10 in the rankings at world No. In the final, he came from a two-set deficit to beat Daniil Medvedev to become the first Italian player, male or female, to win the Australian Open singles title, and the third man to win a Major (the second of which is in the Open Era), the first in 48 years.[8][122]\"}, {'url': 'https://www.thesportreview.com/biography/jannik-sinner/', 'content': '\u00e2\u20ac\u00a2 Date of birth: 16 August 2001\\n\u00e2\u20ac\u00a2 Age: 22 years old\\n\u00e2\u20ac\u00a2 Place of birth: San Candido, Italy\\n\u00e2\u20ac\u00a2 Nationality: Italian\\n\u00e2\u20ac\u00a2 Height: 188cm / 6ft 2ins\\n\u00e2\u20ac\u00a2 Weight: 76kg / 167lbs\\n\u00e2\u20ac\u00a2 Plays: Right-handed\\n\u00e2\u20ac\u00a2 Turned Pro: 2018\\n\u00e2\u20ac\u00a2 Career Prize Money: US$ 4,896,338\\n\u00e2\u20ac\u00a2 Instagram: @janniksin\\nThe impressive 22-year-old turned professional back in 2018 and soon made an impact on the tour, breaking into the top 100 in the world rankings for the first time in 2019.\\n Jannik Sinner (Photo: Dubai Duty Free Tennis Championships)\\nSinner ended the season as number 78 in the world, becoming the youngest player since Rafael Nadal in 2003 to end the year in the top 80.\\n The Italian then ended the 2019 season in style, qualifying for the 2019 Next Gen ATP Finals and going on to win the tournament with a win over Alex de Minaur in the final.\\n Sinner then reached the main draw of a grand slam for the first time at the 2019 US Open, when he came through qualifying to reach the first round, where he lost to Stan Wawrinka.\\n Asked to acknowledge some of the key figures in his development, Sinner replied: \u201cI think first of all, my family who always helped me and gave me the confidence to actually change my life when I was 13-and-a-half, 14 years old.\\n'}]\n[Execute Result] {'thought': 'The search results have provided two different places of birth for Jannik Sinner: Innichen and San Candido. These are actually the same place, as San Candido is the Italian name and Innichen is the German name for the town. Since the user asked for the place of birth or hometown, I can now provide this information.', 'action_name': 'finish', 'action_parameters': {'content': 'Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy.'}}\n[Execute] Execute End.\n[Revised Plan] {\"goals\": [\"Find the hometown of the 2024 Australian Open winner\"], \"tasks\": [], \"next_task_id\": null}\n[Agent Result] Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy.\n[Agent] Agent End.\n```\n\n## How it works?\n\nYou can see the detail in log information, let's explain it step by step.\n\n> You can see more detail data in the log file, see [here](other/log_system.md) to find it.\n\nWhen AssistantAgent receives the question, it first creates a plan to solve the question. The plan is a list of tasks that need to be done to solve the question. In this case, the plan result is as follows:\n\n```json\n{\n  \"goals\": [\n    \"Find the hometown of the 2024 Australian Open winner\"\n  ],\n  \"tasks\": [\n    {\n      \"task_id\": 1,\n      \"description\": \"Identify the winner of the 2024 Australian Open.\"\n    },\n    {\n      \"task_id\": 2,\n      \"description\": \"Search for the biography or profile of the identified winner to find their hometown.\"\n    },\n    {\n      \"task_id\": 3,\n      \"description\": \"Record the hometown of the 2024 Australian Open winner.\"\n    }\n  ],\n  \"next_task_id\": 1\n}\n```\n\nFirstly, agent will run the first task, which is to identify the winner of the 2024 Australian Open. The agent uses the Tavily search tool to find the most recent information on the 2024 Australian Open winner. The search result shows that Jannik Sinner is the winner of the 2024 Australian Open. The agent then revises the plan to the following:\n\n```json\n{\n    \"goals\": [\n        \"Find the hometown of the 2024 Australian Open winner\"\n    ],\n    \"tasks\": [\n        {\n            \"task_id\": 2,\n            \"description\": \"Research Jannik Sinner to find his place of birth or hometown.\"\n        },\n        {\n            \"task_id\": 3,\n            \"description\": \"Record the hometown of Jannik Sinner, the 2024 Australian Open winner.\"\n        }\n    ],\n    \"next_task_id\": 2\n}\n```\n\nThe agent then runs the second task, which is to research Jannik Sinner to find his place of birth or hometown. The agent uses the Tavily search tool to find the most recent and accurate information. The search result shows that Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy. The agent then records the result and finishes the task.\n\nFinally, the agent completes the plan and provides the answer to the user: Jannik Sinner was born in San Candido (Italian) / Innichen (German), Italy.\n\n\n## Development Guide\n\n1. Clone the project to your local machine:\n\n```bash\ngit clone https://github.com/Undertone0809/UACP\ncd UACP\n```\n\n2. If you don't have `Poetry`. \n\nConda environment is is recommended.\n\n```bash\nconda create -n uacp python==3.10\n```\n\nPlease activate python of current project and install run:\n\n```bash\nconda activate uacp\npip install poetry\n```\n\n\n## \ud83d\udcd6 Makefile usage\n\n[`Makefile`](https://github.com/Undertone0809/ecjtu/blob/main/Makefile) contains a lot of functions for faster development.\n\n<details>\n<summary>Install all dependencies and pre-commit hooks</summary>\n<p>\n\nInstall requirements:\n\n```bash\nmake install\n```\n\nPre-commit hooks coulb be installed after `git init` via\n\n```bash\nmake pre-commit-install\n```\n\n</p>\n</details>\n\n<details>\n<summary>Codestyle and type checks</summary>\n<p>\n\nAutomatic format uses `ruff`.\n\n```bash\nmake polish-codestyle\n\n# or use synonym\nmake format\n```\n\nCodestyle checks only, without rewriting files:\n\n```bash\nmake check-codestyle\n```\n\n> Note: `check-codestyle` uses `ruff` and `darglint` library\n\n</p>\n</details>\n\n<details>\n<summary>Code security</summary>\n<p>\n\n> If this command is not selected during installation, it cannnot be used.\n\n```bash\nmake check-safety\n```\n\nThis command launches `Poetry` integrity checks as well as identifies security issues with `Safety` and `Bandit`.\n\n```bash\nmake check-safety\n```\n\n</p>\n</details>\n\n<details>\n<summary>Tests with coverage badges</summary>\n<p>\n\nRun `pytest`\n\n```bash\nmake test\n```\n\n</p>\n</details>\n\n<details>\n<summary>All linters</summary>\n<p>\n\nOf course there is a command to run all linters in one:\n\n```bash\nmake lint\n```\n\nthe same as:\n\n```bash\nmake check-codestyle && make test && make check-safety\n```\n\n</p>\n</details>\n\n<details>\n<summary>Docker</summary>\n<p>\n\n```bash\nmake docker-build\n```\n\nwhich is equivalent to:\n\n```bash\nmake docker-build VERSION=latest\n```\n\nRemove docker image with\n\n```bash\nmake docker-remove\n```\n\nMore information [about docker](https://github.com/Undertone0809/python-package-template/tree/main/%7B%7B%20cookiecutter.project_name%20%7D%7D/docker).\n\n</p>\n</details>\n\n<details>\n<summary>Cleanup</summary>\n<p>\nDelete pycache files\n\n```bash\nmake pycache-remove\n```\n\nRemove package build\n\n```bash\nmake build-remove\n```\n\nDelete .DS_STORE files\n\n```bash\nmake dsstore-remove\n```\n\nRemove .mypycache\n\n```bash\nmake mypycache-remove\n```\n\nOr to remove all above run:\n\n```bash\nmake cleanup\n```\n\n</p>\n</details>\n\n## \ud83d\udcdd Log system\n\nWhen you run UACP, all the logs are stored in a log folder. UACP divides the logs by date, which means that each day will have a separate log file.\n\nYou can find the logs in the following path:\n\n- windows: `/Users/username/.uacp/logs`\n- linux: `/home/username/.uacp/logs`\n\n## \ud83d\udee1 License\n\nThis project is licensed under the terms of the `MIT` license. See [LICENSE](https://github.com/Undertone0809/uacp/blob/master/LICENSE) for more details.\n\n## \ud83d\udcc3 Citation\n\n```bibtex\n@misc{uacp,\n  author = {Zeelnad},\n  title = {Universal Agent Communication Protocol},\n  year = {2024},\n  publisher = {Underonte0809},\n  journal = {https://github.com/Undertone0809/UACP},\n  howpublished = {\\url{https://github.com/Undertone0809/uacp}}\n}\n```\n\n\n## \ud83d\udc8c Contact\n\nFor more information, please contact: [zeeland4work@gmail.com](mailto:zeeland4work@gmail.com)\n\n> This project was generated with [3PG](https://github.com/Undertone0809/3PG)\n\n## \u2b50 Contribution\n\nWe welcome contributions to UACP! Please check out the [Contribution Guide](./CONTRIBUTING.md) for guidelines on how to proceed.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Universal Agent Communication Protocol",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Undertone0809/uacp",
        "Repository": "https://github.com/Undertone0809/uacp"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e4f3f55266d95b5e06d8b5f38c77255c494c582266dd21aa7a1339f95ab0a03",
                "md5": "ce187c36de64fac48c38c187f198f509",
                "sha256": "6e2d2ec7c6e898f057a3601f26f0f18724f699d649e43e230ff7b8f4ed33efa4"
            },
            "downloads": -1,
            "filename": "uacp-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce187c36de64fac48c38c187f198f509",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 18578,
            "upload_time": "2024-04-21T18:14:29",
            "upload_time_iso_8601": "2024-04-21T18:14:29.913893Z",
            "url": "https://files.pythonhosted.org/packages/8e/4f/3f55266d95b5e06d8b5f38c77255c494c582266dd21aa7a1339f95ab0a03/uacp-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "07a578e2b5a7cbf76bb17360e06342916025ef3a12eb15c18755cb516885ccdb",
                "md5": "b1f3349330668c80598a9d3c1a0e8a3c",
                "sha256": "7a2c2e3284f3515bdda07a65f3660efad797c8ae8dbd3759e0ad6cf219a57415"
            },
            "downloads": -1,
            "filename": "uacp-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b1f3349330668c80598a9d3c1a0e8a3c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 28408,
            "upload_time": "2024-04-21T18:14:32",
            "upload_time_iso_8601": "2024-04-21T18:14:32.236853Z",
            "url": "https://files.pythonhosted.org/packages/07/a5/78e2b5a7cbf76bb17360e06342916025ef3a12eb15c18755cb516885ccdb/uacp-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-21 18:14:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Undertone0809",
    "github_project": "uacp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "uacp"
}
        
Elapsed time: 1.09326s