- Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathtest_snowflake.py
76 lines (68 loc) · 2.3 KB
/
test_snowflake.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
importos
importsys
importtraceback
fromdotenvimportload_dotenv
load_dotenv()
importpytest
fromlitellmimportcompletion, acompletion
@pytest.mark.parametrize("sync_mode", [True, False])
@pytest.mark.asyncio
asyncdeftest_chat_completion_snowflake(sync_mode):
try:
messages= [
{
"role": "user",
"content": "Write me a poem about the blue sky",
},
]
ifsync_mode:
response=completion(
model="snowflake/mistral-7b",
messages=messages,
api_base="https://exampleopenaiendpoint-production.up.railway.app/v1/chat/completions"
)
print(response)
assertresponseisnotNone
else:
response=awaitacompletion(
model="snowflake/mistral-7b",
messages=messages,
api_base="https://exampleopenaiendpoint-production.up.railway.app/v1/chat/completions"
)
print(response)
assertresponseisnotNone
exceptExceptionase:
pytest.fail(f"Error occurred: {e}")
@pytest.mark.asyncio
@pytest.mark.parametrize("sync_mode", [True, False])
asyncdeftest_chat_completion_snowflake_stream(sync_mode):
try:
set_verbose=True
messages= [
{
"role": "user",
"content": "Write me a poem about the blue sky",
},
]
ifsync_modeisFalse:
response=awaitacompletion(
model="snowflake/mistral-7b",
messages=messages,
max_tokens=100,
stream=True,
api_base="https://exampleopenaiendpoint-production.up.railway.app/v1/chat/completions"
)
asyncforchunkinresponse:
print(chunk)
else:
response=completion(
model="snowflake/mistral-7b",
messages=messages,
max_tokens=100,
stream=True,
api_base="https://exampleopenaiendpoint-production.up.railway.app/v1/chat/completions"
)
forchunkinresponse:
print(chunk)
exceptExceptionase:
pytest.fail(f"Error occurred: {e}")