修改1.1

This commit is contained in:
ziming 2023-09-26 09:37:49 +08:00
parent c18f384356
commit 5fbe015c56
4 changed files with 37 additions and 17 deletions

View file

@ -7,7 +7,6 @@
from run_gpt import run_gpt_prompt_chat_poignancy,run_gpt_random_concept
from gpt_structure import embedding
from retrive import agent_retrive
from reflect import *
import time
import json
@ -67,14 +66,14 @@ if __name__ == "__main__":
John_iss = "John Lin is a pharmacy shopkeeper at the Willow Market and Pharmacy who loves to help people. He is always looking for ways to make the process of getting medication easier for his customers; John Lin is living with his wife, Mei Lin, who is a college professor, and son, Eddy Lin, who is a student studying music theory; John Lin loves his family very much; John Lin has known the old couple next-door, Sam Moore and Jennifer Moore, for a few years; John Lin thinks Sam Moore is a kind and nice man; John Lin knows his neighbor, Yuriko Yamamoto, well; John Lin knows of his neighbors, Tamara Taylor and Carmen Ortiz, but has not met them before; John Lin and Tom Moreno are colleagues at The Willows Market and Pharmacy; John Lin and Tom Moreno are friends and like to discuss local politics together; John Lin knows the Moreno family somewhat well — the husband Tom Moreno and the wife Jane Moreno."
John = Agent_memeory("John",John_iss,memory_path="agent_memories/John_memory.json")
# for i in range(3):
# memory = run_gpt_random_concept()
# curr_time = time.time()
# poignancy = run_gpt_prompt_chat_poignancy(John,memory)
# M = Meomry_basic(curr_time,curr_time,memory,poignancy)
# John.memories_list.append(M)
for i in range(3):
memory = run_gpt_random_concept()
curr_time = time.time()
poignancy = run_gpt_prompt_chat_poignancy(John,memory)
M = Meomry_basic(curr_time,curr_time,memory,poignancy)
John.memories_list.append(M)
# John.memory_save(John.memory_path)
John.memory_save(John.memory_path)
for i in range(len(John.memories_list)):
print(f"John记忆为:{John.memories_list[i].description}")
@ -85,7 +84,5 @@ if __name__ == "__main__":
print(f"John的相关信息{Top_v}")
# John的相关信息{'Had a friendly chat with Yuriko about her garden.': 2.4992317730827667, 'Helped Mrs. Moore carry groceries into her house.': 1.957656720441911, 'Discussed local politics with Tom Moreno.': 1.9458268038234035}
A=generate_focus_point(John.memories_list)
B=generate_insights_and_evidence(John,John.memories_list,question=A[0])

File diff suppressed because one or more lines are too long

View file

@ -5,14 +5,15 @@
# Date:9.25
import openai
openai.api_key = "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"
openai.api_key = "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"
openai.proxy='http://127.0.0.1:7000'
# 直接调用Prompt生成
def response_generate(prompt):
completion = openai.Completion.create(
model="gpt-3.5-turbo-instruct",
prompt= prompt,
temperature=0,
max_tokens = 20,
max_tokens = 500,
top_p = 1,
stream = False,
frequency_penalty = 0,

View file

@ -1,6 +1,8 @@
import json
from gpt_structure import final_response
import run_gpt
from GA_memory_storage import Agent_memeory
from retrive import agent_retrive
'''
首先
@ -39,8 +41,28 @@ def generate_insights_and_evidence(agent,memories_list,question, n=5):
Input:
{statements}
What {n} high-level insights can you infer from the above statements? (example format: insight (because of 1, 5, 3))
1.'''
What {n} high-level insights can you infer from the above statements?
You should return a list of list[str,list] . The first element is the insight you have found.The second element is the
'''
ret = final_response(prompt.format(question=question,statements=statements,n=n), "['insightA',(1,2,3)]")
print(ret)
ret = final_response(prompt.format(question=question,statements=statements,n=n), "['insightA',[1,2,3]]")
try:
insight_list = json.loads(ret)
return (insight_list)
except:
return ret
if __name__ == "__main__":
# 例子构建John Agent实现retrive
John_iss = "John Lin is a pharmacy shopkeeper at the Willow Market and Pharmacy who loves to help people. He is always looking for ways to make the process of getting medication easier for his customers; John Lin is living with his wife, Mei Lin, who is a college professor, and son, Eddy Lin, who is a student studying music theory; John Lin loves his family very much; John Lin has known the old couple next-door, Sam Moore and Jennifer Moore, for a few years; John Lin thinks Sam Moore is a kind and nice man; John Lin knows his neighbor, Yuriko Yamamoto, well; John Lin knows of his neighbors, Tamara Taylor and Carmen Ortiz, but has not met them before; John Lin and Tom Moreno are colleagues at The Willows Market and Pharmacy; John Lin and Tom Moreno are friends and like to discuss local politics together; John Lin knows the Moreno family somewhat well — the husband Tom Moreno and the wife Jane Moreno."
John = Agent_memeory("John",John_iss,memory_path="agent_memories/John_memory.json")
# John的相关信息{'Had a friendly chat with Yuriko about her garden.': 2.4992317730827667, 'Helped Mrs. Moore carry groceries into her house.': 1.957656720441911, 'Discussed local politics with Tom Moreno.': 1.9458268038234035}
A=generate_focus_point(John.memories_list)
B=generate_insights_and_evidence(John,John.memories_list,question=A[0])
print(type(B))
print(B)
'''
这里是输出,list形式返回给记忆
[['The pharmacy is a friendly and helpful community.', [0, 2, 9, 12]], ['The pharmacy is a place where people come for more than just medication.', [3, 5, 13, 14]], ['The pharmacy is a place where people come for advice and conversation.', [0, 2, 6, 9, 12]], ['The pharmacy is a place where people come for assistance with daily tasks.', [3, 5, 13, 14]], ['The pharmacy is a place where people come for political discussions.', [1]]]
'''