This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_config.py
56 lines (45 loc) · 2.1 KB
/
example_config.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Example config for using the chat.py or rag.py scripts"""
import os
from auto_llama import ChatRoles, Config
from auto_llama.llm import LocalOpenAILLM
from auto_llama_agents import MultiSearchAgent, WikipediaSearchAgent, DuckDuckGoSearchAgent
from auto_llama_agents.selectors import SimilarityAgentSelector
from auto_llama_memory import TxtAIConversationMemory, TxtAIMemory
BASE_BATH = os.path.dirname(os.path.abspath(__file__))
# LLM -----------------------------------------------------
llm = LocalOpenAILLM(base_url="http://localhost:5000/v1")
# Memory -----------------------------------------------------
facts_memory = TxtAIMemory.from_disk(os.path.join(BASE_BATH, "data", "studies_rag_v1"))
conversation_memory = TxtAIConversationMemory.from_disk(os.path.join(BASE_BATH, "data", "conv_v1"))
# Agents -----------------------------------------------------
search_agent = MultiSearchAgent(
[
DuckDuckGoSearchAgent.with_nlp_query(facts_memory, max_results=3),
WikipediaSearchAgent.with_nlp_query(facts_memory, 2),
]
)
agents = {"search": search_agent}
# Selector -----------------------------------------------------
agent_keywords = {
"search": ["research knowledge in a encyclopedia", "search the web using a search engine"],
}
assistant_keywords = ["talk to a friend", "talk to a assistant", "answer personal questions"]
selector = SimilarityAgentSelector(agents, agent_keywords, assistant_keywords)
# System Prompt -----------------------------------------------------
roles: dict[ChatRoles, str] = {"system": "System", "assistant": "AutoLLaMa", "user": "User"}
system_prompt = """
You are {assistant} a friendly and helpfull AI Assistant. You are talking to {name}
Consider the following context when answering questions: {context}
You remember the following segments of an old conversation: {old_chat}
"""
start_message = "Hello! My name is AutoLLaMa. How can I help you?"
config = Config(
llm=llm,
agents=agents,
selector=selector,
memory=facts_memory,
conversation_memory=conversation_memory,
roles=roles,
system_prompt=system_prompt,
start_message=start_message,
)