david-oplatka commited on
Commit
4c7e556
1 Parent(s): 5619f73

Add test file

Browse files
Files changed (2) hide show
  1. agent.py +1 -1
  2. test_agent.py +37 -0
agent.py CHANGED
@@ -141,7 +141,7 @@ def create_assistant_tools(cfg):
141
  [ask_hackernews]
142
  )
143
 
144
- def initialize_agent(_cfg, update_func):
145
  bot_instructions = """
146
  - You are a helpful assistant, with expertise in answering user questions based on Hacker News stories and comments.
147
  - Give slight preference to newer stories when answering questions.
 
141
  [ask_hackernews]
142
  )
143
 
144
+ def initialize_agent(_cfg, update_func = None):
145
  bot_instructions = """
146
  - You are a helpful assistant, with expertise in answering user questions based on Hacker News stories and comments.
147
  - Give slight preference to newer stories when answering questions.
test_agent.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+ import os
3
+
4
+ from omegaconf import OmegaConf
5
+ from vectara_agent.agent import Agent
6
+
7
+ from agent import initialize_agent
8
+
9
+ from dotenv import load_dotenv
10
+ load_dotenv(override=True)
11
+
12
+ class TestAgentResponses(unittest.TestCase):
13
+
14
+ def test_responses(self):
15
+
16
+ cfg = OmegaConf.create({
17
+ 'customer_id': str(os.environ['VECTARA_CUSTOMER_ID']),
18
+ 'corpus_id': str(os.environ['VECTARA_CORPUS_ID']),
19
+ 'api_key': str(os.environ['VECTARA_API_KEY']),
20
+ 'tavily_api_key': str(os.environ['TAVILY_API_KEY'])
21
+ })
22
+
23
+ agent = initialize_agent(_cfg = cfg)
24
+ self.assertIsInstance(agent, Agent)
25
+
26
+ # Questions about Posts/Stories
27
+ self.assertIn('mockingbird', agent.chat('What is the name of the LLM created by Vectara? Give the name only').lower())
28
+ self.assertIn('texas', agent.chat('Which state is Meta paying because they used facial recognition without user\'s permission? Give the state name only').lower())
29
+ self.assertIn('nextos', agent.chat('Who wrote the post The Hitchhiker\'s Guide to Logical Verification? Give the user\'s name only.').lower())
30
+
31
+ # Identifying Pages/Posts
32
+ self.assertIn('41099028', agent.chat('What is the id for the post titled Tea-tasking, a Python package for the statistical analysis of A/B tests? Just give the id, nothing else'))
33
+ self.assertIn('e10v_me', agent.chat('Who commented \'Experiments with 3 or more variants are quite rare in my practice\' on this page? Give the user name only.').lower())
34
+ self.assertIn('word slicer', agent.chat('What is the title of the post with id 41078020 Give the name only').lower())
35
+
36
+ if __name__ == "__main__":
37
+ unittest.main()