|
| 1 | +""" Basic connectivity tests to cloud API providers. """ |
| 2 | + |
1 | 3 | import os |
2 | 4 | from llmware.prompts import Prompt |
3 | 5 |
|
|
7 | 9 | google_api_key = os.environ.get("GOOGLE_API_KEY","") |
8 | 10 | cohere_api_key = os.environ.get("COHERE_API_KEY", "") |
9 | 11 |
|
| 12 | + |
10 | 13 | # Simple test to make sure we are reaching OpenAI |
11 | 14 | def test_openai(): |
12 | 15 | prompter = Prompt(llm_name="gpt-4", llm_api_key=openai_api_key) |
13 | 16 | response = prompter.completion("what is artificial intelligence?") |
14 | 17 | llm_response = response["llm_response"] |
15 | 18 | assert 'artificial' in llm_response.lower() |
16 | 19 |
|
| 20 | + |
17 | 21 | # Simple test to make sure we are reaching Google |
18 | 22 | def test_google(): |
19 | 23 | prompter = Prompt(llm_name="text-bison@001", llm_api_key=google_api_key) |
20 | 24 | response = prompter.completion("what is artificial intelligence?") |
21 | 25 | llm_response = response["llm_response"] |
22 | 26 | assert 'artificial' in llm_response.lower() |
23 | 27 |
|
| 28 | + |
24 | 29 | # Simple test to make sure we are reaching Anthropic |
25 | 30 | def test_anthropic(): |
26 | 31 | prompter = Prompt(llm_name="claude-instant-v1", llm_api_key=anthropic_api_key) |
27 | 32 | response = prompter.completion("what is artificial intelligence?") |
28 | 33 | llm_response = response["llm_response"] |
29 | 34 | assert 'artificial' in llm_response.lower() |
30 | 35 |
|
| 36 | + |
31 | 37 | # Simple test to make sure we are reaching AI21 |
32 | 38 | def test_ai21(): |
33 | 39 | prompter = Prompt(llm_name="j2-grande-instruct", llm_api_key=ai21_api_key) |
34 | 40 | response = prompter.completion("what is artificial intelligence?") |
35 | 41 | llm_response = response["llm_response"] |
36 | 42 | assert 'artificial' in llm_response.lower() |
37 | | - |
38 | | -# Simple test to make sure we are reaching Cohere. Disabling due to Cohere temporarily rate-limiting summarization for Trial accounts |
39 | | -# def test_cohere(): |
40 | | -# user_managed_secrets_setup() |
41 | | -# prompter = Prompt(llm_name="summarize-medium", llm_api_key=os.environ["USER_MANAGED_COHERE_API_KEY"]) |
42 | | -# response = prompter.completion("what is artificial intelligence?") |
43 | | -# llm_response = response["llm_response"] |
44 | | -# print(llm_response) |
45 | | -# assert 'artificial' in llm_response.lower() |
0 commit comments