|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 6, |
| 6 | + "outputs": [], |
| 7 | + "source": [ |
| 8 | + "from langroid.agent.chat_agent import ChatAgentConfig\n", |
| 9 | + "from langroid.language_models.openai_gpt import OpenAIChatModel, OpenAIGPTConfig\n", |
| 10 | + "from examples.labeling.twitter_emotion_detection.twitter_emotion_detection import TweetEmotionDetector" |
| 11 | + ], |
| 12 | + "metadata": { |
| 13 | + "collapsed": false, |
| 14 | + "ExecuteTime": { |
| 15 | + "end_time": "2023-11-30T02:17:48.814122Z", |
| 16 | + "start_time": "2023-11-30T02:17:48.804237Z" |
| 17 | + } |
| 18 | + }, |
| 19 | + "id": "46e7f6a620fa0233" |
| 20 | + }, |
| 21 | + { |
| 22 | + "cell_type": "code", |
| 23 | + "execution_count": 7, |
| 24 | + "id": "initial_id", |
| 25 | + "metadata": { |
| 26 | + "collapsed": true, |
| 27 | + "ExecuteTime": { |
| 28 | + "end_time": "2023-11-30T02:18:29.294787Z", |
| 29 | + "start_time": "2023-11-30T02:18:29.292971Z" |
| 30 | + } |
| 31 | + }, |
| 32 | + "outputs": [], |
| 33 | + "source": [ |
| 34 | + "chat_agent_config = ChatAgentConfig(\n", |
| 35 | + " llm = OpenAIGPTConfig(\n", |
| 36 | + " chat_model = OpenAIChatModel.GPT4_TURBO,\n", |
| 37 | + " ),\n", |
| 38 | + " vecdb = None,\n", |
| 39 | + ")" |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + "cell_type": "code", |
| 44 | + "execution_count": 8, |
| 45 | + "outputs": [], |
| 46 | + "source": [ |
| 47 | + "batch_base_prompt = \"\"\"\n", |
| 48 | + "You are an expert at classifying tweets as neutral or one or more of the given emotions that best represent the mental state of the poster. Your job is to correctly label the provided input examples into one or more of the following categories: neutral, anger, anticipation, disgust, fear, joy, love, optimism, pessimism, sadness, surprise, trust.\n", |
| 49 | + "\n", |
| 50 | + "You will return the answer as a comma-separated list of labels sorted in alphabetical order for each of the input examples. For example: \n", |
| 51 | + "\n", |
| 52 | + "Sentiment[1]: label1, label2, label3\n", |
| 53 | + "Sentiment[2]: label1, label2\n", |
| 54 | + "Sentiment[3]: label1\n", |
| 55 | + "\n", |
| 56 | + "\"\"\"" |
| 57 | + ], |
| 58 | + "metadata": { |
| 59 | + "collapsed": false, |
| 60 | + "ExecuteTime": { |
| 61 | + "end_time": "2023-11-30T02:23:43.469457Z", |
| 62 | + "start_time": "2023-11-30T02:23:43.457840Z" |
| 63 | + } |
| 64 | + }, |
| 65 | + "id": "46d1016f6bd65367" |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "code", |
| 69 | + "execution_count": null, |
| 70 | + "outputs": [], |
| 71 | + "source": [ |
| 72 | + "tweet_emotion_detector = TweetEmotionDetector(\n", |
| 73 | + " chat_agent_config,\n", |
| 74 | + " \"\"\n", |
| 75 | + ")" |
| 76 | + ], |
| 77 | + "metadata": { |
| 78 | + "collapsed": false |
| 79 | + }, |
| 80 | + "id": "ad4685a8dae4eabf" |
| 81 | + } |
| 82 | + ], |
| 83 | + "metadata": { |
| 84 | + "kernelspec": { |
| 85 | + "display_name": "Python 3", |
| 86 | + "language": "python", |
| 87 | + "name": "python3" |
| 88 | + }, |
| 89 | + "language_info": { |
| 90 | + "codemirror_mode": { |
| 91 | + "name": "ipython", |
| 92 | + "version": 2 |
| 93 | + }, |
| 94 | + "file_extension": ".py", |
| 95 | + "mimetype": "text/x-python", |
| 96 | + "name": "python", |
| 97 | + "nbconvert_exporter": "python", |
| 98 | + "pygments_lexer": "ipython2", |
| 99 | + "version": "2.7.6" |
| 100 | + } |
| 101 | + }, |
| 102 | + "nbformat": 4, |
| 103 | + "nbformat_minor": 5 |
| 104 | +} |
0 commit comments