|
7 | 7 | "source": [ |
8 | 8 | "# Together AI\n", |
9 | 9 | "\n", |
10 | | - "> The Together API makes it easy to fine-tune or run leading open-source models with a couple lines of code. We have integrated the world’s leading open-source models, including Llama-2, RedPajama, Falcon, Alpaca, Stable Diffusion XL, and more. Read more: https://together.ai\n", |
| 10 | + "> The Together API makes it easy to query and fine-tune leading open-source models with a couple lines of code. We have integrated the world’s leading open-source models, including Llama-3, Mixtral, DBRX, Stable Diffusion XL, and more. Read more: https://together.ai\n", |
11 | 11 | "\n", |
12 | 12 | "To use, you'll need an API key which you can find here:\n", |
13 | | - "https://api.together.xyz/settings/api-keys. This can be passed in as init param\n", |
| 13 | + "https://api.together.ai/settings/api-keys. This can be passed in as init param\n", |
14 | 14 | "``together_api_key`` or set as environment variable ``TOGETHER_API_KEY``.\n", |
15 | 15 | "\n", |
16 | | - "Together API reference: https://docs.together.ai/reference" |
| 16 | + "Together API reference: https://docs.together.ai" |
17 | 17 | ] |
18 | 18 | }, |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "id": "1c47fc36", |
| 22 | + "metadata": {}, |
| 23 | + "source": [] |
| 24 | + }, |
19 | 25 | { |
20 | 26 | "cell_type": "code", |
21 | 27 | "execution_count": null, |
|
28 | 34 | }, |
29 | 35 | { |
30 | 36 | "cell_type": "code", |
31 | | - "execution_count": 3, |
| 37 | + "execution_count": null, |
| 38 | + "id": "637bb53f", |
| 39 | + "metadata": {}, |
| 40 | + "outputs": [], |
| 41 | + "source": [ |
| 42 | + "# Running chat completions with Together AI\n", |
| 43 | + "\n", |
| 44 | + "from langchain_core.prompts import ChatPromptTemplate\n", |
| 45 | + "from langchain_together import ChatTogether\n", |
| 46 | + "\n", |
| 47 | + "chat = ChatTogether()\n", |
| 48 | + "\n", |
| 49 | + "# using chat invoke\n", |
| 50 | + "chat.invoke(\"Tell me fun things to do in NYC\")\n", |
| 51 | + "\n", |
| 52 | + "# using chat stream\n", |
| 53 | + "for m in chat.stream(\"Tell me fun things to do in NYC\"):\n", |
| 54 | + " print(m)" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "code", |
| 59 | + "execution_count": null, |
32 | 60 | "id": "e7b7170d-d7c5-4890-9714-a37238343805", |
33 | 61 | "metadata": {}, |
34 | | - "outputs": [ |
35 | | - { |
36 | | - "name": "stdout", |
37 | | - "output_type": "stream", |
38 | | - "text": [ |
39 | | - "\n", |
40 | | - "\n", |
41 | | - "A: A large language model is a neural network that is trained on a large amount of text data. It is able to generate text that is similar to the training data, and can be used for tasks such as language translation, question answering, and text summarization.\n", |
42 | | - "\n", |
43 | | - "A: A large language model is a neural network that is trained on a large amount of text data. It is able to generate text that is similar to the training data, and can be used for tasks such as language translation, question answering, and text summarization.\n", |
44 | | - "\n", |
45 | | - "A: A large language model is a neural network that is trained on\n" |
46 | | - ] |
47 | | - } |
48 | | - ], |
| 62 | + "outputs": [], |
49 | 63 | "source": [ |
| 64 | + "# Running completions with Together AI\n", |
| 65 | + "\n", |
50 | 66 | "from langchain_together import Together\n", |
51 | 67 | "\n", |
52 | 68 | "llm = Together(\n", |
53 | | - " model=\"togethercomputer/RedPajama-INCITE-7B-Base\",\n", |
54 | | - " temperature=0.7,\n", |
55 | | - " max_tokens=128,\n", |
56 | | - " top_k=1,\n", |
| 69 | + " model=\"codellama/CodeLlama-70b-Python-hf\",\n", |
57 | 70 | " # together_api_key=\"...\"\n", |
58 | 71 | ")\n", |
59 | 72 | "\n", |
60 | | - "input_ = \"\"\"You are a teacher with a deep knowledge of machine learning and AI. \\\n", |
61 | | - "You provide succinct and accurate answers. Answer the following question: \n", |
62 | | - "\n", |
63 | | - "What is a large language model?\"\"\"\n", |
64 | | - "print(llm.invoke(input_))" |
| 73 | + "print(llm.invoke(\"def bubble_sort(): \"))" |
65 | 74 | ] |
66 | 75 | } |
67 | 76 | ], |
|
0 commit comments