mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-17 15:35:21 +02:00
完成修改
完成PR374修改
This commit is contained in:
parent
6911ca87ab
commit
c10f1306f5
3 changed files with 10 additions and 10 deletions
|
|
@ -27,10 +27,10 @@ def agent_retrive(agentmemory:AgentMemory, currtime:datetime, memory_forget:floa
|
|||
memories = sorted_memories[:n] if len(sorted_memories) >= n else sorted_memories
|
||||
|
||||
Score_list = []
|
||||
Score_list = extract_importance(memories,Score_list)
|
||||
Score_list = extract_recency(currtime,memory_forget,Score_list)
|
||||
Score_list = extract_relevance(query,Score_list)
|
||||
Score_list = normalize_Socre_floats(Score_list,0,1)
|
||||
Score_list = extract_importance(memories, Score_list)
|
||||
Score_list = extract_recency(currtime, memory_forget, Score_list)
|
||||
Score_list = extract_relevance(query, Score_list)
|
||||
Score_list = normalize_Socre_floats(Score_list, 0, 1)
|
||||
|
||||
total_dict = {}
|
||||
gw = [1,1,1] # 三个因素的权重,重要性,近因性,相关性
|
||||
|
|
@ -41,7 +41,7 @@ def agent_retrive(agentmemory:AgentMemory, currtime:datetime, memory_forget:floa
|
|||
)
|
||||
total_dict[Score_list[i]['memory']] = total_score
|
||||
|
||||
result = top_highest_x_values(total_dict,topk)
|
||||
result = top_highest_x_values(total_dict, topk)
|
||||
|
||||
return result
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ def extract_relevance(query, Score_list):
|
|||
query_embedding = embedding_tools(query)
|
||||
# 进行
|
||||
for i in range(len(Score_list)):
|
||||
result = cos_sim(Score_list[i]["memory"].embedding_key,query_embedding)
|
||||
result = cos_sim(Score_list[i]["memory"].embedding_key, query_embedding)
|
||||
Score_list[i]['relevance'] = result
|
||||
|
||||
return Score_list
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ from memory.scratch import Scratch
|
|||
from memory.associative_memory import MemoryBasic
|
||||
import json
|
||||
|
||||
def run_gpt_prompt_chat_poignancy(scratch:Scratch,content:MemoryBasic.content)->str:
|
||||
def get_poignancy_action(scratch:Scratch, content:MemoryBasic.content)->str:
|
||||
"""
|
||||
衡量事件心酸度
|
||||
"""
|
||||
def create_prompt_input(scratch,content):
|
||||
def create_prompt_input(scratch, content):
|
||||
prompt_input = [scratch.name,
|
||||
scratch.iss,
|
||||
scratch.name,
|
||||
|
|
@ -20,11 +20,11 @@ def run_gpt_prompt_chat_poignancy(scratch:Scratch,content:MemoryBasic.content)->
|
|||
|
||||
# 1. Prompt构建
|
||||
# 2. Instruction给出
|
||||
prompt_template = "prompt_templates/poignancy_chat_v1.txt" ########
|
||||
prompt_template = "poignancy_chat_v1.txt" ########
|
||||
prompt_input = create_prompt_input(scratch, content) ########
|
||||
prompt = prompt_generate(prompt_input, prompt_template)
|
||||
special_instruction = "The output should ONLY contain ONE integer value on the scale of 1 to 10."
|
||||
poignancy = special_response_generate(prompt,special_instruction)
|
||||
poignancy = special_response_generate(prompt, special_instruction)
|
||||
try:
|
||||
poi_dict = json.loads(poignancy)
|
||||
return (poi_dict['poignancy'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue