From e725b926e1422520e28a7e6b440d66601d95b77c Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 31 Aug 2023 08:25:24 -0700 Subject: [PATCH] fix docs for ab_test_llms --- docs/my-website/docs/tutorials/ab_test_llms.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/docs/my-website/docs/tutorials/ab_test_llms.md b/docs/my-website/docs/tutorials/ab_test_llms.md index e425baa09..f961795ff 100644 --- a/docs/my-website/docs/tutorials/ab_test_llms.md +++ b/docs/my-website/docs/tutorials/ab_test_llms.md @@ -25,20 +25,14 @@ llm_dict = { } ``` -All models defined can be called with the same Input/Output format using litellm `completion` +### Select LLM + Make Completion call +Use weighted selection, and call the model using litellm.completion ```python from litellm import completion -# SET API KEYS in .env - https://docs.litellm.ai/docs/completion/supported -os.environ["OPENAI_API_KEY"] = "" -os.environ["TOGETHERAI_API_KEY"] = "" -os.environ["ANTHROPIC_API_KEY"] = "" +selected_llm = random.choices(list(llm_dict.keys()), weights=list(llm_dict.values()))[0] + +response = completion(model=selected_model, messages=[{ "content": "Hello, how are you?","role": "user"}]) -# openai call -response = completion(model="gpt-3.5-turbo", messages=messages) -# cohere call -response = completion(model="together_ai/togethercomputer/llama-2-70b-chat", messages=messages) -# anthropic -response = completion(model="claude-2", messages=messages) ``` ## Setup