- Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathtest_cloudflare.py
42 lines (34 loc) · 997 Bytes
/
test_cloudflare.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
importos
importsys
importtraceback
fromdotenvimportload_dotenv
load_dotenv()
importio
importos
sys.path.insert(
0, os.path.abspath("../..")
) # Adds the parent directory to the system path
importjson
importpytest
importlitellm
fromlitellmimportRateLimitError, Timeout, completion, completion_cost, embedding
# Cloud flare AI test
@pytest.mark.asyncio
@pytest.mark.parametrize("stream", [True, False])
asyncdeftest_completion_cloudflare(stream):
try:
litellm.set_verbose=False
response=awaitlitellm.acompletion(
model="cloudflare/@cf/meta/llama-2-7b-chat-int8",
messages=[{"content": "what llm are you", "role": "user"}],
max_tokens=15,
stream=stream,
)
print(response)
ifstreamisTrue:
asyncforchunkinresponse:
print(chunk)
else:
print(response)
exceptExceptionase:
pytest.fail(f"Error occurred: {e}")