Spaces:
Running
Running
Delete test_agent.py
Browse files- test_agent.py +0 -43
test_agent.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
import unittest
|
2 |
-
import os
|
3 |
-
|
4 |
-
from omegaconf import OmegaConf
|
5 |
-
from vectara_agentic.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 |
-
'examples': os.environ.get('QUERY_EXAMPLES', None)
|
21 |
-
})
|
22 |
-
|
23 |
-
agent = initialize_agent(_cfg=cfg)
|
24 |
-
self.assertIsInstance(agent, Agent)
|
25 |
-
|
26 |
-
# Test RAG tool
|
27 |
-
self.assertIn('elon musk', agent.chat('Who is the CEO of Tesla? Just give their name.').lower())
|
28 |
-
self.assertIn('david zinsner', agent.chat('Who is the CFO of Intel? Just give their name.').lower())
|
29 |
-
|
30 |
-
# Test Yahoo Finance tool
|
31 |
-
self.assertIn('274.52B', agent.chat('Was was the revenue for Apple in 2020? Just provide the number.'))
|
32 |
-
self.assertIn('amazon', agent.chat('Which company had the highest revenue in 2023? Just provide the name.').lower())
|
33 |
-
self.assertIn('amazon', agent.chat('Which company had the lowest profits in 2022?').lower())
|
34 |
-
self.assertIn('10.46B', agent.chat('What was AMD\'s gross profit in 2023?. Just provide the number.'))
|
35 |
-
|
36 |
-
# Test other custom tools
|
37 |
-
self.assertIn('2020', agent.chat('What is the earliest year you can provide information for? Just give the year.').lower())
|
38 |
-
self.assertIn('2024', agent.chat('What is the most recent year you can provide information for? Just give the year.').lower())
|
39 |
-
self.assertIn('AAPL', agent.chat('What is the stock ticker symbol for Apple? Just give the abbreiated ticker.'))
|
40 |
-
|
41 |
-
|
42 |
-
if __name__ == "__main__":
|
43 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|