agent learn with pipeline input ok

This commit is contained in:
tsukasa
2023-12-05 18:50:32 +08:00
parent 1031d527c1
commit f08d709604
28 changed files with 495 additions and 671 deletions
+47 -3
View File
@@ -1,12 +1,12 @@
instance_id = "JarvisPlus"
fullname = "JarvisPlus"
llm_model_name = "gpt-4-1106-preview"
max_token_size = 4000
#enable_kb = "true"
enable_timestamp = "true"
owner_prompt = "I am your master {name} , now is {now}"
contact_prompt = "I am your master's friend {name}"
[work.do]
owner_env = ["knowledge"]
[[work.do]]
role = "system"
content = """
My name is JarvisPlus, I am the master's super personal assistant. I think hard and try my best to complete TODOs.
@@ -58,6 +58,50 @@ The result of my planned execution must be directly parsed by `python json.loads
"""
[[learn.do]]
role = "system"
content = """
我是一名软件工程师,拥有非常优秀的资料学习能力。下面是我学习和整理资料的方法
1. 由于LLM的Token限制,我学习的可能只是资料的部分内容,此时我应能产生合适的学习中间结果,中间结果保存在metadata中。我要么产生中间结果,要么产生最终结果。
2. 当存在已知信息时,需参考已知信息的内容来思考结果。
3. 当我收到最后一部分内容时,我能结合已知的中间结果产生最终结果。
4. 现有资料库以文件系统的形式组织,我未来借助资料的摘要来浏览知识库
5. 我将学习过的资料另存在资料库的合适位置(以/开始的完整路径)。保存位置的目录深度不超过5层,文件夹名称长度不超过16个字符。
6. 总是以json格式返回思考结果,json格式如下
{
"op_list":[
{
"op":"learn",
"original_path":"$original_path",
"think":"$think_result",
"metadata":{...},
"tags":["tag1","tag2"...],
"path":["/graphic/opengl","/database/mysql"], # list of directories to save to.
"title":"$article_title",
"summary":"$summary",
"catalogs": [
{
# optional,catalogs is a tree
"title":"$catalog_name1",
"pos":"$pos:$length"
"children":[
{
"title":"$catalog_name 1.1",
"pos":"$pos:$length"
},
{
"title":"$catalog_name2",
"pos":"$pos:$length"
}
]
},
]
}
]
}
"""
[[prompt]]
role = "system"
content = """
@@ -0,0 +1,8 @@
name = "JarvisPlus"
input.module = "scan_local"
input.params.workspace = "${myai_dir}/workspace/JarvisPlus"
input.params.path = "${myai_dir}/data"
parser.module = "parse_local"
parser.params.workspace = "${myai_dir}/workspace/JarvisPlus"
parser.params.assign_to = "JarvisPlus"
+1 -2
View File
@@ -3,8 +3,7 @@ import aiofiles
import chardet
import logging
import string
from knowledge import ImageObjectBuilder, DocumentObjectBuilder, KnowledgePipelineEnvironment, KnowledgePipelineJournal
from aios_kernel.storage import AIStorage
from aios import AIStorage,ImageObjectBuilder, DocumentObjectBuilder, KnowledgePipelineEnvironment, KnowledgePipelineJournal
class KnowledgeDirSource:
def __init__(self, env: KnowledgePipelineEnvironment, config):
+1 -2
View File
@@ -1,8 +1,7 @@
# define a knowledge base class
import json
import string
from aios_kernel import ComputeKernel, AIStorage
from knowledge import *
from aios import *
class EmbeddingParser:
+6 -7
View File
@@ -1,12 +1,11 @@
import os
import logging
import json
from aios_kernel import *
from knowledge import *
from aios import *
class KnowledgeEnvironment(Environment):
def __init__(self, env_id: str) -> None:
super().__init__(env_id)
class EmbeddingEnvironment(SimpleEnvironment):
def __init__(self, workspace: str) -> None:
super().__init__(workspace)
self.path = os.path.join(AIStorage.get_instance().get_myai_dir(), "knowledge/indices/embedding")
self._default_text_model = "all-MiniLM-L6-v2"
self._default_image_model = "clip-ViT-B-32"
@@ -93,5 +92,5 @@ class KnowledgeEnvironment(Environment):
content = "*** I have provided the following known information for your reference with json format:\n"
return content + self.tokens_from_objects(object_ids[index:index+1])
def init() -> KnowledgeEnvironment:
return KnowledgeEnvironment("embedding")
def init(workspace: str) -> EmbeddingEnvironment:
return EmbeddingEnvironment(workspace)
+1 -1
View File
@@ -1,3 +1,3 @@
pipelines = [
"Mail/Sync"
"JarvisPlus"
]