nonprofit-helper

Month: 2024-01

2024-01-06

paulpengtw 15:03:44
has renamed the channel from "edu-nonprofit-helper" to "nonprofit-helper"
Annie Huang 15:19:49
@annie.huang921002 has joined the channel
denkenie 15:19:56
@denkenie has joined the channel
Joannie 15:20:16
@joanie0610 has joined the channel
HACO 15:20:31
@jasonytonlinecomeands has joined the channel
宏信 Justin 15:20:36
@lancatlin has joined the channel
Stanley 15:20:41
@ccb50995 has joined the channel
Amos 15:20:47
@amosli.tw has joined the channel
lazpytb 15:20:58
@lazpytb has joined the channel
LU 15:53:53
@hypothesquerelle has joined the channel
mewho 16:21:12
@graceful.techlaw has joined the channel
yihuang.edu 16:44:51
@yihuang.edu has joined the channel
chewei 21:34:22
@chewei has joined the channel
ael 21:42:42
@aelcenganda has joined the channel

2024-01-08

Drago 11:00:12
@leechiuhui has joined the channel
Wendy Shih 15:54:20
@wendy7559886 has joined the channel

2024-01-09

paulpengtw 23:22:56

&gt; ...非商業性、完全開源的,就符合申請贊助計畫的條件,可以免費使用 Zeabur 平台提供的雲端部署服務,零成本部署 Next.js、Nuxt.js、Vite 等任何前端網站,MySQL、PostgreSQL、MongoDB、Redis 等資料庫服務,Node.js、Go、Python、Ruby on Rails、PHP 等後端服務。 有興趣的專案夥伴歡迎參考 <https://www.facebook.com/groups/1403852566495675/posts/3569562796591297/|相關資訊> 和 <https://zeabur.com/docs/zh-TW/billing/sponsor?fbclid=IwAR2VWMy_JsP9ozlki3ItN8iGqY78xZmOJW1aJh4vSMFeE4u5N3y9TkICrTo|贊助標準>

paulpengtw 23:22:56

&gt; ...非商業性、完全開源的,就符合申請贊助計畫的條件,可以免費使用 Zeabur 平台提供的雲端部署服務,零成本部署 Next.js、Nuxt.js、Vite 等任何前端網站,MySQL、PostgreSQL、MongoDB、Redis 等資料庫服務,Node.js、Go、Python、Ruby on Rails、PHP 等後端服務。 有興趣的專案夥伴歡迎參考 <https://www.facebook.com/groups/1403852566495675/posts/3569562796591297/|相關資訊> 和 <https://zeabur.com/docs/zh-TW/billing/sponsor?fbclid=IwAR2VWMy_JsP9ozlki3ItN8iGqY78xZmOJW1aJh4vSMFeE4u5N3y9TkICrTo|贊助標準>

2024-01-11

2024-01-31

paulpengtw 11:04:01
https://github.com/openai/openai-cookbook/blob/main/examples/Assistants_API_overview_python.ipynb

<https://github.com/openai/openai-cookbook/blob/main/examples/Assistants_API_overview_python.ipynb | Assistants_API_overview_python.ipynb>

``` { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Assistants API Overview (Python SDK)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The new [Assistants API](<https://platform.openai.com/docs/assistants/overview>) is a stateful evolution of our [Chat Completions API](<https://platform.openai.com/docs/guides/text-generation/chat-completions-api>) meant to simplify the creation of assistant-like experiences, and enable developer access to powerful tools like Code Interpreter and Retrieval." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Assistants API Diagram](../images/assistants_overview_diagram.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chat Completions API vs Assistants API\n", "\n", "The primitives of the **Chat Completions API** are `Messages`, on which you perform a `Completion` with a `Model` (`gpt-3.5-turbo`, `gpt-4`, etc). It is lightweight and powerful, but inherently stateless, which means you have to manage conversation state, tool definitions, retrieval documents, and code execution manually.\n", "\n", "The primitives of the **Assistants API** are\n", "\n", "- `Assistants`, which encapsulate a base model, instructions, tools, and (context) documents,\n", "- `Threads`, which represent the state of a conversation, and\n", "- `Runs`, which power the execution of an `Assistant` on a `Thread`, including textual responses and multi-step tool use.\n", "\n", "We'll take a look at how these can be used to create powerful, stateful experiences.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup\n", "\n", "### Python SDK\n", "\n", "> **Note**\n", "> We've updated our [Python SDK](<https://github.com/openai/openai-python>) to add support for the Assistants API, so you'll need to update it to the latest version (`1.2.3` at time of writing).\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "!pip install --upgrade openai" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And make sure it's up to date by running:\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Version: 1.2.3\n" ] } ], "source": [ "!pip show openai | grep Version" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Pretty Printing Helper\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import json\n", "\n", "def show_json(obj):\n", " display(json.loads(obj.model_dump_json()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Complete Example with Assistants API\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Assistants\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The easiest way to get started with the Assistants API is through the [Assistants Playground](<https://platform.openai.com/playground>).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Assistants Playground](../images/assistants_overview_assistants_playground.png)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's begin by creating an assistant! We'll create a Math Tutor just like in our [docs](<https://platform.openai.com/docs/assistants/overview>).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Creating New Assistant](../images/assistants_overview_new_assistant.png)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can view Assistants you've created in the [Assistants Dashboard](<https://platform.openai.com/assistants>).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Assistants Dashboard](../images/assistants_overview_assistants_dashboard.png)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also create Assistants directly through the Assistants API, like so:\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'asst_9HAjl9y41ufsViNcThW1EXUS',\n", " 'created_at': 1699828331,\n", " 'description': None,\n", " 'file_ids': [],\n", " 'instructions': 'You are a personal math tutor. Answer questions briefly, in a sentence or less.',\n", " 'metadata': {},\n", " 'model': 'gpt-4-1106-preview',\n", " 'name': 'Math Tutor',\n", " 'object': 'assistant',\n", " 'tools': []}" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from openai import OpenAI\n", "import os\n", "\n", "client = OpenAI(api_key=os.environ.get(\"OPENAI_API_KEY\", \"<your OpenAI API key if not set as env var>\"))\n", "\n", "\n", "assistant = client.beta.assistants.create(\n", " name=\"Math Tutor\",\n", " instructions=\"You are a personal math tutor. Answer questions briefly, in a sentence or less.\",\n", " model=\"gpt-4-1106-preview\",\n", ")\n", "show_json(assistant)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Regardless of whether you create your Assistant through the Dashboard or with the API, you'll want to keep track of the Assistant ID. This is how you'll refer to your Assistant throughout Threads and Runs.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we'll create a new Thread and add a Message to it. This will hold the state of our conversation, so we don't have re-send the entire message history each time.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Threads\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a new thread:\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'thread_bw42vPoQtYBMQE84WubNcJXG',\n", " 'created_at': 1699828331,\n", " 'metadata': {},\n", " 'object': 'thread'}" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "thread = client.beta.threads.create()\n", "show_json(thread)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then add the Message to the thread:\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'id': 'msg_IBiZDAWHhWPewxzN0EfTYNew',\n", " 'assistant_id': None,\n", " 'content': [{'text': {'annotations': [],\n", " 'value': 'I need to solve the equation `3x + 11 = 14`. Can you help me?'},\n", " 'type': 'text'}],\n", " 'created_at': 1699828332,\n", " 'file_ids': [],\n", " 'metadata': {},\n", " 'object': 'thread.message',\n", " 'role': 'user',\n", " 'run_id': None,\n", " 'thread_id': 'thread_bw42vPoQtYBMQE84WubNcJXG'}" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "message = client.beta.threads.messages.create(\n", " thread_id=thread.id,\n", " role=\"user\",\n", " content=\"I need to solve the equation `3x + 11 = 14`. Can you help me?\",\n", ")\n", "show_json(message)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "> **Not…

paulpengtw 11:04:54
https://platform.openai.com/docs/api-reference

platform.openai.com

OpenAI Platform

Explore developer resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's platform.

paulpengtw 11:05:40
https://platform.openai.com/docs/guides/text-generation

platform.openai.com

OpenAI Platform

Explore developer resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's platform.