Spaces:
Running
Running
update
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ import datetime
|
|
9 |
from dotenv import load_dotenv
|
10 |
|
11 |
from pydantic import Field, BaseModel
|
12 |
-
from vectara_agent.agent import Agent,
|
13 |
from vectara_agent.tools import ToolsFactory
|
14 |
from vectara_agent.tools_catalog import rephrase_text
|
15 |
|
@@ -19,7 +19,7 @@ languages = {'English': 'en', 'Spanish': 'es', 'French': 'fr', 'German': 'de', '
|
|
19 |
'Hebrew': 'he', 'Hindi': 'hi', 'Italian': 'it', 'Japanese': 'ja', 'Korean': 'ko', 'Portuguese': 'pt'}
|
20 |
initial_prompt = "How can I help you today?"
|
21 |
|
22 |
-
load_dotenv()
|
23 |
|
24 |
def create_tools(cfg):
|
25 |
|
@@ -78,7 +78,7 @@ def create_tools(cfg):
|
|
78 |
[query_tool]
|
79 |
)
|
80 |
|
81 |
-
def initialize_agent(
|
82 |
date = datetime.datetime.now().strftime("%Y-%m-%d")
|
83 |
bot_instructions = f"""
|
84 |
- You are a helpful teacher assistant, with expertise in education in various teaching styles.
|
@@ -95,7 +95,6 @@ def initialize_agent(agent_type: AgentType, _cfg):
|
|
95 |
st.session_state.log_messages.append(output)
|
96 |
|
97 |
agent = Agent(
|
98 |
-
agent_type=agent_type,
|
99 |
tools=create_tools(_cfg),
|
100 |
topic="An educator with expertise in philosophy",
|
101 |
custom_instructions=bot_instructions,
|
@@ -103,12 +102,12 @@ def initialize_agent(agent_type: AgentType, _cfg):
|
|
103 |
)
|
104 |
return agent
|
105 |
|
106 |
-
def launch_bot(
|
107 |
def reset():
|
108 |
cfg = st.session_state.cfg
|
109 |
st.session_state.messages = [{"role": "assistant", "content": initial_prompt, "avatar": "🦖"}]
|
110 |
st.session_state.thinking_message = "Agent at work..."
|
111 |
-
st.session_state.agent = initialize_agent(
|
112 |
st.session_state.log_messages = []
|
113 |
st.session_state.show_logs = False
|
114 |
|
@@ -213,5 +212,5 @@ def launch_bot(agent_type: AgentType):
|
|
213 |
|
214 |
|
215 |
if __name__ == "__main__":
|
216 |
-
launch_bot(
|
217 |
|
|
|
9 |
from dotenv import load_dotenv
|
10 |
|
11 |
from pydantic import Field, BaseModel
|
12 |
+
from vectara_agent.agent import Agent, AgentStatusType
|
13 |
from vectara_agent.tools import ToolsFactory
|
14 |
from vectara_agent.tools_catalog import rephrase_text
|
15 |
|
|
|
19 |
'Hebrew': 'he', 'Hindi': 'hi', 'Italian': 'it', 'Japanese': 'ja', 'Korean': 'ko', 'Portuguese': 'pt'}
|
20 |
initial_prompt = "How can I help you today?"
|
21 |
|
22 |
+
load_dotenv(override=True)
|
23 |
|
24 |
def create_tools(cfg):
|
25 |
|
|
|
78 |
[query_tool]
|
79 |
)
|
80 |
|
81 |
+
def initialize_agent(_cfg):
|
82 |
date = datetime.datetime.now().strftime("%Y-%m-%d")
|
83 |
bot_instructions = f"""
|
84 |
- You are a helpful teacher assistant, with expertise in education in various teaching styles.
|
|
|
95 |
st.session_state.log_messages.append(output)
|
96 |
|
97 |
agent = Agent(
|
|
|
98 |
tools=create_tools(_cfg),
|
99 |
topic="An educator with expertise in philosophy",
|
100 |
custom_instructions=bot_instructions,
|
|
|
102 |
)
|
103 |
return agent
|
104 |
|
105 |
+
def launch_bot():
|
106 |
def reset():
|
107 |
cfg = st.session_state.cfg
|
108 |
st.session_state.messages = [{"role": "assistant", "content": initial_prompt, "avatar": "🦖"}]
|
109 |
st.session_state.thinking_message = "Agent at work..."
|
110 |
+
st.session_state.agent = initialize_agent(cfg)
|
111 |
st.session_state.log_messages = []
|
112 |
st.session_state.show_logs = False
|
113 |
|
|
|
212 |
|
213 |
|
214 |
if __name__ == "__main__":
|
215 |
+
launch_bot()
|
216 |
|