Claude is a personal assistant AI which excels at personal usage through repeated interaction by gathering context about the user.
In this case, the Claude.ai interface is wrapped through an agent making it accessible but without the possibility of personalisation.
TextPrompt(
text="Compare the inflation rates of the past years in various European countries."
)TextResponse(
text="Certainly! Here's a comparison of the inflation rates in various European countries over the past few years: Inflation Rates (Annual Percentage Change): Country 2020 2021 2022 ----------------------------------------- Germany 0.4% 3.1% 7.9% France 0.5% 2.1% 5.9% Italy -0.1% 1.9% 8.0% Spain -0.3% 3.1% 8.5% United Kingdom0.9% 2.6% 9.1% Poland 3.4% 5.2% 13.9% Sweden 0.5% 2.7% 8.8% Netherlands 1.1% 2.8% 11.7% Belgium 0.4% 3.2% 9.9% Austria 1.4% 2.8% 8.6% Some key observations: - Inflation rates have generally been rising across Europe in recent years, with a significant spike in 2022. - The highest inflation rates in 2022 were seen in Poland (13.9%), the Netherlands (11.7%), and the United Kingdom (9.1%). - The lowest inflation rates in 2022 were in Germany (7.9%) and France (5.9%), though these are still relatively high historical figures. - The trend of rising inflation is widespread, with most countries seeing a substantial increase from 2020 to 2022. This data highlights the broad inflationary pressures being experienced across the European continent in the past couple of years. The specific drivers and policy responses may vary by country, but the general pattern of elevated inflation is common."
)class Location(Model):
city: str
country: str
temperature: float
StructuredOutputPrompt(
prompt="What is the temperature in Paris?",
output_schema=Location.schema(),
)StructuredOutputResponse(
output={
"city": "Paris",
"country": "France",
"temperature": 15.0,
}
)The input is comparable to other agent based LLM wrappers you see on the platform. If you provide a text as input, you'll receive a text response.
from typing import Any
from uagents import Agent, Context, Model
class TextPrompt(Model):
text: str
class TextResponse(Model):
text: str
class StructuredOutputPrompt(Model):
prompt: str
output_schema: dict[str, Any]
class StructuredOutputResponse(Model):
output: dict[str, Any]
agent = Agent()
AI_AGENT_ADDRESS = "<deployed_agent_address>"
class Location(Model):
city: str
country: str
temperature: float
prompts = [
TextPrompt(text="Compare the inflation rates of the past years in various European countries."),
StructuredOutputPrompt(
prompt="How is the weather in London today?",
output_schema=Location.schema(),
),
]
@agent.on_event("startup")
async def send_message(ctx: Context):
for prompt in prompts:
await ctx.send(AI_AGENT_ADDRESS, prompt)
ctx.logger.info(f"[Sent prompt to AI agent]: {prompt}")
@agent.on_message(TextResponse)
async def handle_response(ctx: Context, sender: str, msg: TextResponse):
ctx.logger.info(f"[Received response from ...{sender[-8:]}]:")
ctx.logger.info(msg.text)
@agent.on_message(StructuredOutputResponse)
async def handle_response(ctx: Context, sender: str, msg: StructuredOutputResponse):
ctx.logger.info(f"[Received response from ...{sender[-8:]}]:")
ctx.logger.info(msg.output)
response = Location.parse_obj(msg.output)
ctx.logger.info(response)
if __name__ == "__main__":
agent.run()-
Install the necessary packages:
pip install requests uagents
-
To interact with this agent from a local agent instead, replace
agent = Agent()in the above with:agent = Agent( name="user", endpoint="http://localhost:8000/submit", )
-
Run the agent:
python agent.py
Each agent is allowed to make up to 6 requests per hour from this agent.