{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# Comparing OpenAI and open LLMs\n",
    "\n",
    "Using the [text-only content of the website of the journal AUR - Agrar- und Umweltrecht](langchain-experiments/data/input/journal-website.txt), \n",
    "we compare the performance of GPT-4, GPT-3.5-turbo and Models available on Huggingface.\n",
    "\n",
    "## Preparation\n",
    "\n",
    "Import dependencies, define shorthand functions, and prepare test data"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "396ebd275b60c720"
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [],
   "source": [
    "import io\n",
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "from langchain_openai import ChatOpenAI\n",
    "from langchain_core.output_parsers import StrOutputParser\n",
    "import pandas as pd\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "def response_to_df(response):\n",
    "    data = io.StringIO(response)\n",
    "    try:\n",
    "        return pd.read_csv(data)\n",
    "    except:\n",
    "        raise RuntimeError(f\"Error while parsing response:\\n{response}\")\n",
    "\n",
    "def use_model(model, template, **params):\n",
    "    prompt = ChatPromptTemplate.from_template(template)\n",
    "    chain = (\n",
    "            prompt\n",
    "            | model\n",
    "            | StrOutputParser()\n",
    "    )\n",
    "    return response_to_df(chain.invoke(params))\n",
    "\n",
    "with open('data/input/journal-website.txt', encoding='utf-8') as f:\n",
    "    website_text = f.read()\n",
    "journal_name = \"AUR - Agrar- und Umweltrecht\""
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-17T19:43:14.633251500Z",
     "start_time": "2024-01-17T19:43:07.158102900Z"
    }
   },
   "id": "e46d0648c1c6c96a"
  },
  {
   "cell_type": "markdown",
   "source": [
    "## Prompt\n",
    "\n",
    "OpenAI's GPT-4 works perfectly with a minimal, German-language prompt, and infers the meaning of the columns\n",
    "to returns the data we need:\n",
    "\n",
    "```\n",
    "Finde im folgenden Text die Herausgeber, Redaktion/Schriftleitung und Beirat der Zeitschrift '{journal_name}' und gebe sie im CSV-Format zurück mit den Spalten 'lastname', 'firstname', 'title', 'position', 'affiliation','role'. Die Spalte 'role' enthält entweder 'Herausgeber', 'Redaktion', 'Beirat', 'Schriftleitung' oder ist leer wenn nicht bestimmbar. Wenn keine passenden Informationen verfügbar sind, gebe nur den CSV-Header zurück. Setze alle Werte in den CSV-Spalten in Anführungszeichen.\"\n",
    "````\n",
    "\n",
    "\n",
    "In contrast, the open models performed miserably with such a prompt. We therefore use English and provide very detailed instructions.  "
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "eb805270480fbfb5"
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [],
   "source": [
    "template = \"\"\"\n",
    "In the following German text, which was scraped from a website, find the members of the editorial board or the advisory board of the journal '{journal_name}' as per the following rules:\n",
    "- In German, typical labels for these roles are \"Herausgeber\", \"Redaktion/Redakteur/Schriftleitung\" and \"Beirat\".  \n",
    "- Return the data as comma-separated values, which can be saved to a `.csv` file. Put all values in the CSV rows in quotes. \n",
    "- The CSV data must have the columns 'lastname', 'firstname', 'title', 'position', 'affiliation','role'. \n",
    "- The column 'role' must contain either 'Herausgeber', 'Redaktion', 'Beirat' or is empty. Leave the column empty if you cannot determine the role. Use 'Redaktion' for the \"Schriftleitung\" role.\n",
    "- The column 'title' should contain academic titles such as \"Dr.\" or \"Prof. Dr.\"\n",
    "- The column 'position' should contain the job title\n",
    "- The column 'affiliation' contains the institution or organization the person belongs to, or the city if one is mentioned\n",
    "- If the journal is published (\"herausgeben von\") by an association, institute or other organization, but its name in the column 'lastname'. \n",
    "- If you cannot find any information, simply return the CSV header. \n",
    "- You must not output any introduction, commentary or explanation such as 'Here is the CSV data for the members of the editorial board or the advisory board of the journal'. Only return the data.\n",
    "\n",
    "{website_text}\n",
    "\"\"\""
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-17T20:46:02.624154500Z",
     "start_time": "2024-01-17T20:46:02.598111600Z"
    }
   },
   "id": "23aef80911796078"
  },
  {
   "cell_type": "markdown",
   "source": [
    "## ChatGPT-4 \n",
    "\n",
    "GPT-4 delivers an almost perfect [result](data/output/editors-openai-gpt-4.csv). There are some problems left which could be resolved by adding some more instructions to the prompt. \n",
    "\n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "8f994c771cc9b4ef"
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "         lastname   firstname      title  \\\n0            DGAR         NaN        NaN   \n1           Busse   Christian        Dr.   \n2          Endres       Ewald  Prof. Dr.   \n3        Francois    Matthias        Dr.   \n4   von Garmissen       Bernd        Dr.   \n5            Glas        Ingo        NaN   \n6            Graß  Christiane        NaN   \n7      Haarstrich        Jens        NaN   \n8            Koch       Erich        Dr.   \n9            Köpl   Christian        Dr.   \n10       Martinez        Jose  Prof. Dr.   \n11           Nies     Volkmar        NaN   \n12       Stephany        Ralf        NaN   \n13      Wedemeyer      Harald        NaN   \n14       Martinez        José  Prof. Dr.   \n15           Nies     Volkmar        LLD   \n\n                                position  \\\n0   Deutsche Gesellschaft für Agrarrecht   \n1                     Regierungsdirektor   \n2                                    NaN   \n3                           Rechtsanwalt   \n4                           Rechtsanwalt   \n5                           Rechtsanwalt   \n6                         Rechtsanwältin   \n7                           Rechtsanwalt   \n8               Ltd. Verwaltungsdirektor   \n9                         Ministerialrat   \n10                                   NaN   \n11          Ltd. Landwirtschaftsdirektor   \n12            Rechtsanwalt/Steuerberater   \n13                          Rechtsanwalt   \n14                  Erster Schriftleiter   \n15                 Zweiter Schriftleiter   \n\n                                          affiliation         role  \n0                                                 NaN  Herausgeber  \n1   Bundesministerium für Ernährung und Landwirtsc...    Redaktion  \n2        Hochschule Weihenstephan-Triesdorf, Freising    Redaktion  \n3                                             Bitburg    Redaktion  \n4                                           Göttingen    Redaktion  \n5                                             Rostock    Redaktion  \n6                                                Bonn    Redaktion  \n7                                               Peine    Redaktion  \n8   Sozialversicherung für Landwirtschaft, Forsten...    Redaktion  \n9   Bayerisches Staatsministerium für Ernährung, L...    Redaktion  \n10  Institut für Landwirtschaftsrecht, Georg-Augus...    Redaktion  \n11                    Landwirtschaftskammer NRW, Bonn    Redaktion  \n12                                               Bonn    Redaktion  \n13                   Landvolk Niedersachsen, Hannover    Redaktion  \n14       Institut für Landwirtschaftsrecht, Göttingen    Redaktion  \n15                                       50170 Kerpen    Redaktion  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>lastname</th>\n      <th>firstname</th>\n      <th>title</th>\n      <th>position</th>\n      <th>affiliation</th>\n      <th>role</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>DGAR</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>Deutsche Gesellschaft für Agrarrecht</td>\n      <td>NaN</td>\n      <td>Herausgeber</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>Busse</td>\n      <td>Christian</td>\n      <td>Dr.</td>\n      <td>Regierungsdirektor</td>\n      <td>Bundesministerium für Ernährung und Landwirtsc...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>Endres</td>\n      <td>Ewald</td>\n      <td>Prof. Dr.</td>\n      <td>NaN</td>\n      <td>Hochschule Weihenstephan-Triesdorf, Freising</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>Francois</td>\n      <td>Matthias</td>\n      <td>Dr.</td>\n      <td>Rechtsanwalt</td>\n      <td>Bitburg</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>von Garmissen</td>\n      <td>Bernd</td>\n      <td>Dr.</td>\n      <td>Rechtsanwalt</td>\n      <td>Göttingen</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>Glas</td>\n      <td>Ingo</td>\n      <td>NaN</td>\n      <td>Rechtsanwalt</td>\n      <td>Rostock</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>Graß</td>\n      <td>Christiane</td>\n      <td>NaN</td>\n      <td>Rechtsanwältin</td>\n      <td>Bonn</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>Haarstrich</td>\n      <td>Jens</td>\n      <td>NaN</td>\n      <td>Rechtsanwalt</td>\n      <td>Peine</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>Koch</td>\n      <td>Erich</td>\n      <td>Dr.</td>\n      <td>Ltd. Verwaltungsdirektor</td>\n      <td>Sozialversicherung für Landwirtschaft, Forsten...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>Köpl</td>\n      <td>Christian</td>\n      <td>Dr.</td>\n      <td>Ministerialrat</td>\n      <td>Bayerisches Staatsministerium für Ernährung, L...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>Martinez</td>\n      <td>Jose</td>\n      <td>Prof. Dr.</td>\n      <td>NaN</td>\n      <td>Institut für Landwirtschaftsrecht, Georg-Augus...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>Nies</td>\n      <td>Volkmar</td>\n      <td>NaN</td>\n      <td>Ltd. Landwirtschaftsdirektor</td>\n      <td>Landwirtschaftskammer NRW, Bonn</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>Stephany</td>\n      <td>Ralf</td>\n      <td>NaN</td>\n      <td>Rechtsanwalt/Steuerberater</td>\n      <td>Bonn</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>Wedemeyer</td>\n      <td>Harald</td>\n      <td>NaN</td>\n      <td>Rechtsanwalt</td>\n      <td>Landvolk Niedersachsen, Hannover</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>Martinez</td>\n      <td>José</td>\n      <td>Prof. Dr.</td>\n      <td>Erster Schriftleiter</td>\n      <td>Institut für Landwirtschaftsrecht, Göttingen</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>Nies</td>\n      <td>Volkmar</td>\n      <td>LLD</td>\n      <td>Zweiter Schriftleiter</td>\n      <td>50170 Kerpen</td>\n      <td>Redaktion</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model = ChatOpenAI(model_name=\"gpt-4\")\n",
    "df = use_model(model, template, journal_name=journal_name, website_text=website_text)\n",
    "df.to_csv('data/output/editors-openai-gpt-4.csv')\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-17T19:43:51.821749100Z",
     "start_time": "2024-01-17T19:43:22.643583400Z"
    }
   },
   "id": "initial_id"
  },
  {
   "cell_type": "markdown",
   "source": [
    "## ChatGPT 3.5-turbo\n",
    "\n",
    "GPT-3.5 [performs less well](data/output/editors-openai-gpt-3.5-turbo.csv), but still ok. It gets some of the 'title' amd 'position' \n",
    "column data confused, and does not recognize the institutional publisher (Herausgeber) of the journal. \n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "9cef77bb17d57b53"
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "         lastname   firstname                         title  \\\n0           Busse   Christian                           Dr.   \n1          Endres       Ewald                     Prof. Dr.   \n2        Francois    Matthias                           Dr.   \n3   von Garmissen       Bernd                           Dr.   \n4            Glas        Ingo                           NaN   \n5            Graß  Christiane                Rechtsanwältin   \n6      Haarstrich        Jens                  Rechtsanwalt   \n7            Koch       Erich                           Dr.   \n8            Köpl   Christian                           Dr.   \n9        Martinez        Jose                     Prof. Dr.   \n10           Nies     Volkmar  Ltd. Landwirtschaftsdirektor   \n11       Stephany        Ralf    Rechtsanwalt/Steuerberater   \n12      Wedemeyer      Harald                  Rechtsanwalt   \n\n                    position  \\\n0         Regierungsdirektor   \n1                        NaN   \n2               Rechtsanwalt   \n3               Rechtsanwalt   \n4               Rechtsanwalt   \n5                        NaN   \n6                        NaN   \n7   Ltd. Verwaltungsdirektor   \n8             Ministerialrat   \n9                        NaN   \n10                       NaN   \n11                       NaN   \n12                       NaN   \n\n                                          affiliation       role  \n0   Bundesministerium für Ernährung und Landwirtsc...  Redaktion  \n1        Hochschule Weihenstephan-Triesdorf, Freising  Redaktion  \n2                                             Bitburg  Redaktion  \n3                                           Göttingen  Redaktion  \n4                                             Rostock  Redaktion  \n5                                                Bonn  Redaktion  \n6                                               Peine  Redaktion  \n7   Sozialversicherung für Landwirtschaft, Forsten...  Redaktion  \n8   Bayerisches Staatsministerium für Ernährung, L...  Redaktion  \n9   Institut für Landwirtschaftsrecht, Georg-Augus...  Redaktion  \n10                    Landwirtschaftskammer NRW, Bonn  Redaktion  \n11                                               Bonn  Redaktion  \n12                   Landvolk Niedersachsen, Hannover  Redaktion  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>lastname</th>\n      <th>firstname</th>\n      <th>title</th>\n      <th>position</th>\n      <th>affiliation</th>\n      <th>role</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>Busse</td>\n      <td>Christian</td>\n      <td>Dr.</td>\n      <td>Regierungsdirektor</td>\n      <td>Bundesministerium für Ernährung und Landwirtsc...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>Endres</td>\n      <td>Ewald</td>\n      <td>Prof. Dr.</td>\n      <td>NaN</td>\n      <td>Hochschule Weihenstephan-Triesdorf, Freising</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>Francois</td>\n      <td>Matthias</td>\n      <td>Dr.</td>\n      <td>Rechtsanwalt</td>\n      <td>Bitburg</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>von Garmissen</td>\n      <td>Bernd</td>\n      <td>Dr.</td>\n      <td>Rechtsanwalt</td>\n      <td>Göttingen</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>Glas</td>\n      <td>Ingo</td>\n      <td>NaN</td>\n      <td>Rechtsanwalt</td>\n      <td>Rostock</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>Graß</td>\n      <td>Christiane</td>\n      <td>Rechtsanwältin</td>\n      <td>NaN</td>\n      <td>Bonn</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>Haarstrich</td>\n      <td>Jens</td>\n      <td>Rechtsanwalt</td>\n      <td>NaN</td>\n      <td>Peine</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>Koch</td>\n      <td>Erich</td>\n      <td>Dr.</td>\n      <td>Ltd. Verwaltungsdirektor</td>\n      <td>Sozialversicherung für Landwirtschaft, Forsten...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>Köpl</td>\n      <td>Christian</td>\n      <td>Dr.</td>\n      <td>Ministerialrat</td>\n      <td>Bayerisches Staatsministerium für Ernährung, L...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>Martinez</td>\n      <td>Jose</td>\n      <td>Prof. Dr.</td>\n      <td>NaN</td>\n      <td>Institut für Landwirtschaftsrecht, Georg-Augus...</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>Nies</td>\n      <td>Volkmar</td>\n      <td>Ltd. Landwirtschaftsdirektor</td>\n      <td>NaN</td>\n      <td>Landwirtschaftskammer NRW, Bonn</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>Stephany</td>\n      <td>Ralf</td>\n      <td>Rechtsanwalt/Steuerberater</td>\n      <td>NaN</td>\n      <td>Bonn</td>\n      <td>Redaktion</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>Wedemeyer</td>\n      <td>Harald</td>\n      <td>Rechtsanwalt</td>\n      <td>NaN</td>\n      <td>Landvolk Niedersachsen, Hannover</td>\n      <td>Redaktion</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model = ChatOpenAI(model_name=\"gpt-3.5-turbo\")\n",
    "df = use_model(model, template, journal_name=journal_name, website_text=website_text)\n",
    "df.to_csv('data/output/editors-openai-gpt-3.5-turbo.csv')\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-17T19:46:04.139744300Z",
     "start_time": "2024-01-17T19:45:46.825487Z"
    }
   },
   "id": "e1aedc5ef3cab564"
  },
  {
   "cell_type": "markdown",
   "source": [
    "Now, let's try the open models via the Huggingface Inference Endpoint. For this to work, you need to deploy\n",
    "endpoints via https://ui.endpoints.huggingface.co/ and update the value of `enpoint_url` below."
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "31084716e138fe06"
  },
  {
   "cell_type": "markdown",
   "source": [
    "## TheBloke/Llama-2-13B-chat-GPTQ \n",
    "\n",
    "The [LLama2 13 billion parameter model](https://huggingface.co/TheBloke/Llama-2-13B-chat-GPTQ) produces [unusuable output](data/output/editors-llama-2-13b-chat-gptq.txt)."
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "90ce37abf037e19f"
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "['Martinez, Dr. Christian Busse, Bundesministerium für Ernährung und Landwirtschaft, Bonn Agrarprodukt Recht',\n 'Prof. Dr. Ewald Endres, Hochschule Weihenstephan-Triesdorf Freising Forsting Forsting, Jagd, Fischerei, Fischerei',\n 'Lawyeranwalt Ingo Glas, Bitburg Boden Recht',\n 'Christiane Grass, Bonn Agrarzivil Recht',\n 'Jens Haarstrich, Peine Redaktionär, Rostock',\n 'Prof. Dr. Bernd von Garmissen, Göttingen Erb, Redaktion, Umwelt',\n 'Ltdr. Jose Martinez, Georg-August-Universität Göttingen, Göttingen',\n '',\n '',\n \"Note: The column 'Role' contains the following values: 'Herausgeber', 'Redaktion', 'Beirat'\"]"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from lib.hf_llama2_chat_gptq import query\n",
    "llama2_template = f\"<s>[INST] <<SYS>>You are a helpful assistant. No comments or explanation, just answer the question.<</SYS>>{template}[/INST]\"\n",
    "\n",
    "endpoint_url = \"https://z8afrqamxvaaitmf.us-east-1.aws.endpoints.huggingface.cloud\"\n",
    "query(endpoint_url, template, journal_name=journal_name, website_text=website_text).split(\"\\n\")\n"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-17T19:31:23.221568600Z",
     "start_time": "2024-01-17T19:31:16.694648400Z"
    }
   },
   "id": "f05098a4cf2aa3dc"
  },
  {
   "cell_type": "markdown",
   "source": [
    "## TheBloke/Llama-2-70B-chat-GPTQ via Huggingface Inference Endpoint\n",
    "\n",
    "The 70 billion parameter variant [does a bit better](data/output/editors-llama-2-70b-chat-gptq.csv) but, among other things, doesn't the academic titles right. It also cannot be persuaded to [not comment on the CSV output].(data/output/editors-llama-2-70b-chat-gptq.txt). Given that the model costs $13/h to run, that's not really that impressive."
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "ca33fb28f6772cbc"
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "'  Here is the CSV data for the members of the editorial board or the advisory board of the journal \\'AUR - Agrar- und Umweltrecht\\':\\n\\n\"lastname\",\"firstname\",\"title\",\"affiliation\",\"role\"\\n\"Busse\",\"Christian\", \"Regierungsdirektor\", \"Bundesministerium für Ernährung und Landwirtschaft, Bonn\", \"Herausgeber\"\\n\"Endres\",\"Ewald\", \"Prof. Dr.\", \"Hochschule Weihenstephan-Triesdorf, Freising\", \"Redaktion\"\\n\"Francois\",\"Matthias\", \"Rechtsanwalt\", \"Bitburg\", \"Redaktion\"\\n\"Garmissen\",\"Bernd\", \"Rechtsanwalt\", \"Göttingen\", \"Redaktion\"\\n\"Graß\",\"Christiane\", \"Rechtsanwältin\", \"Bonn\", \"Redaktion\"\\n\"Haarstrich\",\"Jens\", \"Rechtsanwalt\", \"Peine\", \"Redaktion\"\\n\"Köpl\",\"Christian\", \"Ministerialrat\", \"Bayerisches Staatsministerium für Ernährung, Landwirtschaft und Forsten, München\", \"\"\\n\"Martinez\",\"Jose\", \"Prof. Dr.\", \"Institut für Landwirtschaftsrecht, Georg-August-Universität Göttingen, Göttingen\", \"Herausgeber\"\\n\"Nies\",\"Volkmar\", \"Ltd. Landwirtschaftsdirektor\", \"Landwirtschaftskammer NRW, Bonn\", \"Redaktion\"\\n\"Stephany\",\"Ralf\", \"Rechtsanwalt/Steuerberater\", \"Bonn\", \"Redaktion\"\\n\"Wedemeyer\",\"Harald\", \"Rechtsanwalt\", \"Landvolk Niedersachsen, Hannover\", \"Redaktion\"\\n\"Schell\",\"Irina Valeska\", \"\", \"Georg-August-Universität Göttingen, Göttingen\", \"\"\\n\\nNote: The column \\'role\\' is empty for some members, as their role could not be determined.'"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "endpoint_url = \"https://gp8iviqlqee101a0.us-east-1.aws.endpoints.huggingface.cloud\"\n",
    "query(endpoint_url, template, journal_name=journal_name, website_text=website_text).split(\"\\n\")"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-17T19:14:56.752808800Z",
     "start_time": "2024-01-17T19:13:45.800635700Z"
    }
   },
   "id": "b94cf62b996bf3a2"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}