Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Bool1020 committed Feb 24, 2024
1 parent 8584d9a commit 707121d
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
from apps.handle.chat.api_rpc import chat
from apps.handle.chat.api_rpc import chat, model_message
from apps.handle.knowledge.knowledge_utils import load_knowledge
from apps.handle.retrieval.retrieval_utils import Search
from apps.handle.mylang.chain_utils import llm
from langchain.tools.retriever import create_retriever_tool
from langchain.tools.render import format_tool_to_openai_function
from langgraph.prebuilt import ToolExecutor
from langchain.chat_models import ChatBaichuan
from apps.handle.mylang.chain_utils import CustomChat
import os
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
BaseMessage,
BaseMessageChunk,
ChatMessage,
ChatMessageChunk,
HumanMessage,
HumanMessageChunk,
)


if __name__ == '__main__':
for i, _ in chat('达美康的国内适应症是什么?缓释制剂初始剂量是多少?', is_stream=True):
print(i)
db = load_knowledge('test')
search = Search(db)

from apps.handle.mylang.agent_utils import AgenticRAG

rag = AgenticRAG(search)

inputs = {
"messages": [
HumanMessage(
content="What does Lilian Weng say about the types of agent memory?"
)
]
}
for output in rag(inputs):
for key, value in output.items():
print(f"Output from node '{key}':")
print("---")
print(value)
print("\n---\n")

0 comments on commit 707121d

Please sign in to comment.