ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
from aworld.replay_buffer.query_filter import QueryBuilder
|
||||
from aworld.logs.util import logger
|
||||
|
||||
|
||||
def example():
|
||||
'''
|
||||
expression: task_id = "123"
|
||||
return :
|
||||
{
|
||||
'field': 'task_id',
|
||||
'value': '123',
|
||||
'op': 'eq'
|
||||
}
|
||||
'''
|
||||
qb = QueryBuilder()
|
||||
query = qb.eq("task_id", "123").build()
|
||||
logger.info(query)
|
||||
|
||||
|
||||
def example1():
|
||||
'''
|
||||
expression: (task_id = "123" and agent_id = "111") or (task_id = "456" and agent_id = "222")
|
||||
return :
|
||||
{
|
||||
'or_': [{
|
||||
'and_': [{
|
||||
'field': 'task_id',
|
||||
'value': '123',
|
||||
'op': 'eq'
|
||||
}, {
|
||||
'field': 'agent_id',
|
||||
'value': '111',
|
||||
'op': 'eq'
|
||||
}]
|
||||
}, {
|
||||
'and_': [{
|
||||
'field': 'task_id',
|
||||
'value': '456',
|
||||
'op': 'eq'
|
||||
}, {
|
||||
'field': 'agent_id',
|
||||
'value': '222',
|
||||
'op': 'eq'
|
||||
}]
|
||||
}]
|
||||
}
|
||||
'''
|
||||
qb = QueryBuilder()
|
||||
query = (qb.eq("task_id", "123")
|
||||
.and_()
|
||||
.eq("agent_id", "111")
|
||||
.or_()
|
||||
.nested(QueryBuilder()
|
||||
.eq("task_id", "456")
|
||||
.and_()
|
||||
.eq("agent_id", "222"))
|
||||
.build())
|
||||
logger.info(query)
|
||||
|
||||
|
||||
def example2():
|
||||
'''
|
||||
expression: task_id = "123" and (agent_id = "111" or agent_id = "222")
|
||||
return :
|
||||
{
|
||||
'and_': [{
|
||||
'field': 'task_id',
|
||||
'value': '123',
|
||||
'op': 'eq'
|
||||
}, {
|
||||
'or_': [{
|
||||
'field': 'agent_id',
|
||||
'value': '111',
|
||||
'op': 'eq'
|
||||
}, {
|
||||
'field': 'agent_id',
|
||||
'value': '222',
|
||||
'op': 'eq'
|
||||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
qb = QueryBuilder()
|
||||
query = (qb.eq("task_id", "123")
|
||||
.and_()
|
||||
.nested(QueryBuilder()
|
||||
.eq("agent_id", "111")
|
||||
.or_()
|
||||
.eq("agent_id", "222"))
|
||||
.build())
|
||||
logger.info(query)
|
||||
|
||||
if __name__ == "__main__":
|
||||
example()
|
||||
example1()
|
||||
example2()
|
||||
Reference in New Issue
Block a user