From 6352a70c08b4ac8847210fd89ac3546f998dab73 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 15 Aug 2023 21:23:53 -0700 Subject: [PATCH] add togetherai tutorial to docs --- .DS_Store | Bin 6148 -> 6148 bytes docs/.DS_Store | Bin 0 -> 6148 bytes .../docs/tutorials/TogetherAI_liteLLM.md | 61 ++++++++++++++++++ docs/my-website/sidebars.js | 2 +- 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 docs/.DS_Store create mode 100644 docs/my-website/docs/tutorials/TogetherAI_liteLLM.md diff --git a/.DS_Store b/.DS_Store index 2fdad250942267257ed06d411c08e15aa32447d1..4997c6790704eb3a8b46e32bd5596e5ff9ec0cfa 100644 GIT binary patch delta 63 zcmZoMXfc@JFT}>cz`)4BAi$7PoSc)CpP$3Hc_Q;FMlp~$3quM+K0`7?F+z@q=^5*0 Ic8Y0t;o!XRH$oL^rc@{N)D# D`jZS3 diff --git a/docs/.DS_Store b/docs/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2b1524840de1e8620286546458bd978bfbed4188 GIT binary patch literal 6148 zcmeHKJ5EC}5S)b+5i}`N`T{Aqffa=lZ~+uT5h*A|Kq%d-I2T7__EQi&MWP5zG%Kyg zUhmlQ6mQ=Gu;s_*0hj@p(jD>T!`OV^ePlNkF(RF3ykd<5ws`04Z|2-Pyy1uiK7aE! zhnL-Yzu$R+ObSQ=DIf);fE2ix0##b4_ZK@+2T1`ba4ib>_o2}pd*P56pAHVu0uUz* zhjAXg1hIL5*b9e5Mrf8)Vp6SI3`;uWt@3)|keGB>H6K9C%tQ3^)|36Qdk+ g;pKQ9NtxGt&i!6EBnF-FpcC~o;JV19z<(?71A(L!Z2$lO literal 0 HcmV?d00001 diff --git a/docs/my-website/docs/tutorials/TogetherAI_liteLLM.md b/docs/my-website/docs/tutorials/TogetherAI_liteLLM.md new file mode 100644 index 000000000..3b5174ece --- /dev/null +++ b/docs/my-website/docs/tutorials/TogetherAI_liteLLM.md @@ -0,0 +1,61 @@ +## liteLLM Together AI Tutorial +https://together.ai/ + + + +```python +!pip install litellm==0.1.371 +``` + + +```python +import os +from litellm import completion +os.environ["TOGETHER_AI_TOKEN"] = "" #@param +user_message = "Hello, whats the weather in San Francisco??" +messages = [{ "content": user_message,"role": "user"}] +``` + +## Calling togethercomputer/llama-2-70b-chat +https://api.together.xyz/playground/chat?model=togethercomputer%2Fllama-2-70b-chat + + +```python +model_name = "togethercomputer/llama-2-70b-chat" +response = completion(model=model_name, messages=messages, together_ai=True) +print(response) +``` + + {'choices': [{'finish_reason': 'stop', 'index': 0, 'message': {'role': 'assistant', 'content': "\n\nI'm not able to provide real-time weather information. However, I can suggest"}}], 'created': 1691629657.9288375, 'model': 'togethercomputer/llama-2-70b-chat', 'usage': {'prompt_tokens': 9, 'completion_tokens': 17, 'total_tokens': 26}} + + +## With Streaming + + +```python +response = completion(model=model_name, messages=messages, together_ai=True, stream=True) +print(response) +for chunk in response: + print(chunk['choices'][0]['delta']) # same as openai format +``` + + + {'role': 'assistant', 'content': '\\n'} + {'role': 'assistant', 'content': '\\n'} + {'role': 'assistant', 'content': 'I'} + {'role': 'assistant', 'content': 'm'} + {'role': 'assistant', 'content': ' not'} + {'role': 'assistant', 'content': ' able'} + {'role': 'assistant', 'content': ' to'} + {'role': 'assistant', 'content': ' provide'} + {'role': 'assistant', 'content': ' real'} + {'role': 'assistant', 'content': '-'} + {'role': 'assistant', 'content': 'time'} + {'role': 'assistant', 'content': ' weather'} + {'role': 'assistant', 'content': ' information'} + {'role': 'assistant', 'content': '.'} + {'role': 'assistant', 'content': ' However'} + {'role': 'assistant', 'content': ','} + {'role': 'assistant', 'content': ' I'} + {'role': 'assistant', 'content': ' can'} + diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index fd86e95a0..09978e440 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -32,7 +32,7 @@ const sidebars = { { type: 'category', label: 'Tutorials', - items: ['tutorials/huggingface_tutorial'], + items: ['tutorials/huggingface_tutorial', 'tutorials/TogetherAI_liteLLM'], }, 'token_usage', 'stream',