This is my custom aioaiagent client
Project description
DM-aioaiagent
Urls
* Package contains both asynchronous
and synchronous
clients
Usage
Analogue to DMAioAIAgent
is the synchronous client DMAIAgent
.
import asyncio
from dm_aioaiagent import DMAioAIAgent
async def main():
# define a system message
system_message = "Your custom system message with role, backstory and goal"
# define a list of tools, if you want to use them
tools = [...]
# define a openai model, default is "gpt-4o-mini"
model_name = "gpt-4o"
# create an agent
ai_agent = DMAioAIAgent(system_message, tools, model=model_name)
# you can set input_output_logging=False, if you don't want to see the input and output messages from agent
# define the conversation messages
messages = [
{"role": "user", "content": "Hello!"},
{"role": "ai", "content": "How can I help you?"},
{"role": "user", "content": "I want to know the weather in Kyiv"},
]
# start the agent
state = await ai_agent.run(messages)
# if you define tools, you can see the context of the tools
answer = state["answer"]
print(state["context"])
if __name__ == "__main__":
asyncio.run(main())
Set custom logger
If you want set up custom logger
from dm_aioaiagent import DMAioAIAgent
# create custom logger
class MyLogger:
def debug(self, message):
pass
def info(self, message):
pass
def warning(self, message):
print(message)
def error(self, message):
print(message)
# create agent
ai_agent = DMAioAIAgent()
# set up custom logger for this agent
ai_agent.set_logger(MyLogger())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dm_aioaiagent-0.1.3.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for dm_aioaiagent-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70be62a32f0179c745208c56375c4a0f72398b7a73c96c7e4ac4941bf83fe95b |
|
MD5 | 3086e7183a08d42adb4e56981113e319 |
|
BLAKE2b-256 | 31e5836927e034b85be0d53ae145b89a6a333b832b4f29e20e9596db9d735e80 |