Skip to content

LIO-H-ZEN/PureAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quickstart

First install the packages:

pip install pure_agent 

setup your config.yaml

env:
  api_key: xxx
infer_params:
  model: gpt-4o-mini
  temperature: 0.8
  top_p: 0.8
  max_tokens: 512

write your first agent based on pure_agent!

from pure_agent import BaseAgent, RoleCtx, append_msg

class MyAgent(BaseAgent):
    @append_msg()
    def greeting(self, sys_name, prompt):
        with RoleCtx('system'):
            yield f"You are a helpful assistant, your name is {sys_name}."
        with RoleCtx('user'):
            yield prompt

agent = MyAgent(client_config='config.yaml')
response = agent.greeting('agent0', 'who are u?')
print(response)

use multi-thread:

from pure_agent import *

class MyAgent(BaseAgent):
    @append_msg(return_async_task=True)
    def greeting(self, sys_name, prompt):
        with RoleCtx('system'):
            yield f"You are a helpful assistant, your name is {sys_name}."
        with RoleCtx('user'):
            yield prompt

sys_names = ['pbot0', 'pbot1']
prompts = ['who are u?', 'who are u?']
with MultiThreadExecutor(10, '.cache') as pool:
    for i in range(len(sys_names)):
        agent = MyAgent(client_config='config.yaml')
        task = agent.greeting(sys_names[i], prompts[i])
        # print(pretty_print_nested(msgs))
        pool.submit(task)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages