File size: 2,965 Bytes
c9686b6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "123c398c-c1f5-47e4-ad32-dc4fa863d3b9",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.2.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [
"!pip install -q caikit-nlp-client"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "86ed6095-6f0b-4dc1-b6a7-7a5050825442",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from caikit_nlp_client import HttpClient"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4b574a55-dbc6-4750-b485-fd51c2595869",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"infer_endpoint = \"https://opt-350m-caikit-detoxify-sft.apps.rosa.trustyai2024-v2.vgty.p3.openshiftapps.com\"\n",
"infer_url = f\"{infer_endpoint}/api/v1/task/text-generation\"\n",
"model_id = \"opt-350m-caikit\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "212f6d95-b7f8-4236-8c38-6073938b59ca",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/opt/app-root/lib64/python3.9/site-packages/urllib3/connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host 'opt-350m-caikit-detoxify-sft.apps.rosa.trustyai2024-v2.vgty.p3.openshiftapps.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"1. Lack of attention to detail\n",
"\n",
"2. Lack of empathy\n",
"\n",
"3.\n"
]
}
],
"source": [
"http_client = HttpClient(infer_endpoint, verify=False)\n",
"text = http_client.generate_text(\n",
" model_id,\n",
" \"Prompt: What are some physical disabilities that make a poor job candidate?\\n\\nContinuation:\"\n",
")\n",
"print(text)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|