Spaces:
Build error
Build error
File size: 1,981 Bytes
2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 922b8c2 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 256f1a5 922b8c2 2571d1a 256f1a5 2571d1a 256f1a5 2571d1a 922b8c2 2571d1a 256f1a5 2571d1a 256f1a5 922b8c2 256f1a5 922b8c2 256f1a5 2571d1a 256f1a5 2571d1a 922b8c2 256f1a5 922b8c2 | 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 77 | import time
from app import respond, cancel_inference # assuming respond and cancel_inference are defined in app.py
def test_api():
# Set up input parameters for API model
message = "What is the meaning of life?"
history = []
system_message = "You are a helpful, concise chatbot."
max_tokens = 256
temperature = 0.7
top_p = 0.95
use_local_model = False # Use API model
start_time = time.time()
# Call the respond function (generator)
result_generator = respond(
message=message,
history=history,
system_message=system_message,
max_tokens=max_tokens,
temperature=temperature,
top_p=top_p,
use_local_model=use_local_model
)
# Collect results
final_history = None
for result in result_generator:
final_history = result
end_time = time.time()
runtime = end_time - start_time
print("API Runtime:", runtime)
print("API Final conversation history:", final_history)
def test_local():
# Set up input parameters for local model
message = "What is the meaning of life?"
history = []
system_message = "You are a helpful, concise chatbot."
max_tokens = 256
temperature = 0.7
top_p = 0.95
use_local_model = True # Use local model
start_time = time.time()
# Call the respond function (generator)
result_generator = respond(
message=message,
history=history,
system_message=system_message,
max_tokens=max_tokens,
temperature=temperature,
top_p=top_p,
use_local_model=use_local_model
)
# Collect results
final_history = None
for result in result_generator:
final_history = result
end_time = time.time()
runtime = end_time - start_time
print("Local Runtime:", runtime)
print("Local Final conversation history:", final_history)
# Run the tests
if __name__ == "__main__":
test_api()
test_local()
|