-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathagent.py
40 lines (27 loc) · 1.21 KB
/
agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Full end2end question/answer app
# Experimenation
from lib import *
from langgraph.prebuilt import create_react_agent
from langgraph.checkpoint.memory import MemorySaver
def main():
tool = create_faiss_retriever_tool('all-MiniLM-L6-v2',
'faiss/programs_index',
'programs_info')
tools = [tool]
llm = load_llama('llama3.2', nthreads=4)
memory = MemorySaver()
system_prompt = '''You are an advisor...'''
agent_executor = create_react_agent(llm, tools, checkpointer=memory, state_modifier=system_prompt)
config = {"configurable": {"thread_id": "thread-1"}}
while 1:
print('\n==== Say something')
query = input()
print("\nProcessing query:", query)
vector_store = FAISS.load_local("faiss/programs_index",
HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2"),
allow_dangerous_deserialization=True)
docs = vector_store.similarity_search(query)
r = get_ai_response(agent_executor, query, config)
print(r.pretty_repr())
if __name__ == "__main__":
main()