ofermend commited on
Commit
b8d1094
·
1 Parent(s): 26d9812
Files changed (5) hide show
  1. Dockerfile +3 -1
  2. agent.py +23 -5
  3. app.py +3 -0
  4. requirements.txt +3 -3
  5. st_app.py +1 -2
Dockerfile CHANGED
@@ -4,7 +4,9 @@ WORKDIR /app
4
 
5
  COPY ./requirements.txt /app/requirements.txt
6
 
7
- RUN pip3 install --no-cache-dir -r /app/requirements.txt
 
 
8
 
9
  # User
10
  RUN useradd -m -u 1000 user
 
4
 
5
  COPY ./requirements.txt /app/requirements.txt
6
 
7
+ RUN pip3 install --no-cache-dir --upgrade pip
8
+ RUN pip3 install --no-cache-dir wheel setuptools build
9
+ RUN pip3 install --no-cache-dir --use-pep517 -r /app/requirements.txt
10
 
11
  # User
12
  RUN useradd -m -u 1000 user
agent.py CHANGED
@@ -4,15 +4,30 @@ from pydantic import Field, BaseModel
4
  from omegaconf import OmegaConf
5
 
6
  from vectara_agentic.agent import Agent
7
- from vectara_agentic.tools import VectaraToolFactory
8
 
9
  from dotenv import load_dotenv
10
  load_dotenv(override=True)
11
 
12
  initial_prompt = "How can I help you today?"
13
 
 
 
 
 
 
 
 
14
  def create_assistant_tools(cfg):
15
 
 
 
 
 
 
 
 
 
16
  class QueryHMC(BaseModel):
17
  query: str = Field(description="The user query.")
18
  ticker: Optional[str] = Field(
@@ -41,7 +56,7 @@ def create_assistant_tools(cfg):
41
  vectara_corpus_key=cfg.corpus_key
42
  )
43
 
44
- summarizer = 'vectara-experimental-summary-ext-2023-12-11-med-omni'
45
  #summarizer = 'vectara-summary-ext-24-05-med-omni'
46
  ask_hmc = vec_factory.create_rag_tool(
47
  tool_name = "ask_hmc",
@@ -59,16 +74,17 @@ def create_assistant_tools(cfg):
59
  {
60
  "type": "mmr",
61
  "diversity_bias": 0.05,
62
- "limit": 20
63
  }
64
  ],
65
  n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.005,
66
  vectara_summarizer = summarizer,
67
  summary_num_results = 10,
68
  include_citations = True,
69
- verbose=False,
70
  )
71
- return [ask_hmc]
 
72
 
73
  def initialize_agent(_cfg, agent_progress_callback=None):
74
  bot_instructions = """
@@ -77,6 +93,7 @@ def initialize_agent(_cfg, agent_progress_callback=None):
77
  If the tool responds with "I don't have enough information to answer", try rephrasing the question.
78
  - Use the year, quarter, filing_type and ticker arguments to the 'ask_hmc' tool to get more specific answers.
79
  - Note that 10Q reports exist for quarters 1, 2, 3 and for the 4th quarter there is a 10K report.
 
80
  """
81
 
82
  agent = Agent(
@@ -84,6 +101,7 @@ def initialize_agent(_cfg, agent_progress_callback=None):
84
  topic="Endowment fund management",
85
  custom_instructions=bot_instructions,
86
  agent_progress_callback=agent_progress_callback,
 
87
  )
88
  agent.report()
89
  return agent
 
4
  from omegaconf import OmegaConf
5
 
6
  from vectara_agentic.agent import Agent
7
+ from vectara_agentic.tools import VectaraToolFactory, ToolsFactory
8
 
9
  from dotenv import load_dotenv
10
  load_dotenv(override=True)
11
 
12
  initial_prompt = "How can I help you today?"
13
 
14
+ tickers = {
15
+ "GOOG": "Google",
16
+ "NVDA": "Nvidia",
17
+ "META": "Meta",
18
+ "BKNG": "Bookings holding",
19
+ }
20
+
21
  def create_assistant_tools(cfg):
22
 
23
+ def get_company_info() -> list[str]:
24
+ """
25
+ Returns a dictionary of companies you can query about. Always check this before using any other tool.
26
+ The output is a dictionary of valid ticker symbols mapped to company names.
27
+ You can use this to identify the companies you can query about, and their ticker information.
28
+ """
29
+ return tickers
30
+
31
  class QueryHMC(BaseModel):
32
  query: str = Field(description="The user query.")
33
  ticker: Optional[str] = Field(
 
56
  vectara_corpus_key=cfg.corpus_key
57
  )
58
 
59
+ summarizer = 'vectara-summary-table-md-query-ext-jan-2025-gpt-4o'
60
  #summarizer = 'vectara-summary-ext-24-05-med-omni'
61
  ask_hmc = vec_factory.create_rag_tool(
62
  tool_name = "ask_hmc",
 
74
  {
75
  "type": "mmr",
76
  "diversity_bias": 0.05,
77
+ "limit": 50
78
  }
79
  ],
80
  n_sentences_before = 2, n_sentences_after = 2, lambda_val = 0.005,
81
  vectara_summarizer = summarizer,
82
  summary_num_results = 10,
83
  include_citations = True,
84
+ verbose = True,
85
  )
86
+ tools_factory = ToolsFactory()
87
+ return [ask_hmc] + [tools_factory.create_tool(get_company_info)]
88
 
89
  def initialize_agent(_cfg, agent_progress_callback=None):
90
  bot_instructions = """
 
93
  If the tool responds with "I don't have enough information to answer", try rephrasing the question.
94
  - Use the year, quarter, filing_type and ticker arguments to the 'ask_hmc' tool to get more specific answers.
95
  - Note that 10Q reports exist for quarters 1, 2, 3 and for the 4th quarter there is a 10K report.
96
+ - If the 'ask_hmc' tool does not return any results, check the year and ticker and try calling it again with the right values.
97
  """
98
 
99
  agent = Agent(
 
101
  topic="Endowment fund management",
102
  custom_instructions=bot_instructions,
103
  agent_progress_callback=agent_progress_callback,
104
+ verbose=True,
105
  )
106
  agent.report()
107
  return agent
app.py CHANGED
@@ -1,10 +1,13 @@
1
  import streamlit as st
 
2
  from st_app import launch_bot
3
  import uuid
4
 
5
  import nest_asyncio
6
  import asyncio
7
 
 
 
8
  # Setup for HTTP API Calls to Amplitude Analytics
9
  if 'device_id' not in st.session_state:
10
  st.session_state.device_id = str(uuid.uuid4())
 
1
  import streamlit as st
2
+ import torch
3
  from st_app import launch_bot
4
  import uuid
5
 
6
  import nest_asyncio
7
  import asyncio
8
 
9
+ torch.classes.__path__ = []
10
+
11
  # Setup for HTTP API Calls to Amplitude Analytics
12
  if 'device_id' not in st.session_state:
13
  st.session_state.device_id = str(uuid.uuid4())
requirements.txt CHANGED
@@ -1,9 +1,9 @@
1
  omegaconf==2.3.0
2
  python-dotenv==1.0.1
3
- streamlit==1.41.1
4
- streamlit_pills==0.3.0
5
  streamlit_feedback==0.1.3
6
  uuid==1.30
7
  langdetect==1.0.9
8
  langcodes==3.4.0
9
- vectara-agentic==0.2.5
 
 
1
  omegaconf==2.3.0
2
  python-dotenv==1.0.1
3
+ streamlit==1.43.2
 
4
  streamlit_feedback==0.1.3
5
  uuid==1.30
6
  langdetect==1.0.9
7
  langcodes==3.4.0
8
+ vectara-agentic==0.2.9
9
+ torch==2.6.0
st_app.py CHANGED
@@ -3,7 +3,6 @@ import sys
3
  import re
4
 
5
  import streamlit as st
6
- from streamlit_pills import pills
7
  from streamlit_feedback import streamlit_feedback
8
 
9
  from utils import thumbs_feedback, escape_dollars_outside_latex, send_amplitude_data
@@ -15,7 +14,7 @@ initial_prompt = "How can I help you today?"
15
 
16
  def show_example_questions():
17
  if len(st.session_state.example_messages) > 0 and st.session_state.first_turn:
18
- selected_example = pills("Queries to Try:", st.session_state.example_messages, index=None)
19
  if selected_example:
20
  st.session_state.ex_prompt = selected_example
21
  st.session_state.first_turn = False
 
3
  import re
4
 
5
  import streamlit as st
 
6
  from streamlit_feedback import streamlit_feedback
7
 
8
  from utils import thumbs_feedback, escape_dollars_outside_latex, send_amplitude_data
 
14
 
15
  def show_example_questions():
16
  if len(st.session_state.example_messages) > 0 and st.session_state.first_turn:
17
+ selected_example = st.pills("Queries to Try:", st.session_state.example_messages, default=None)
18
  if selected_example:
19
  st.session_state.ex_prompt = selected_example
20
  st.session_state.first_turn = False