File size: 3,012 Bytes
a76d7fc
 
 
 
d21188b
a76d7fc
 
 
75bf125
 
 
 
 
 
 
d21188b
 
 
 
 
 
 
 
b82fac7
75bf125
 
 
 
 
 
 
 
 
d21188b
75bf125
 
 
 
 
 
d21188b
75bf125
 
 
 
 
 
d21188b
 
 
 
75bf125
 
 
 
 
d21188b
75bf125
 
 
 
 
 
 
d21188b
 
75bf125
 
 
d21188b
75bf125
 
 
 
 
d21188b
75bf125
 
 
 
 
 
 
 
a76d7fc
 
 
 
75bf125
 
 
 
 
a76d7fc
75bf125
 
 
 
 
 
 
 
 
 
a76d7fc
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fc00c2fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "import dspy\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a1670ba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null
   "id": "194bf39b",
   "metadata": {},
   "outputs": [],
   "source": [
    "gpt_5_mini = dspy.LM(\n",
    "    model=\"openai/gpt-5-mini\",\n",
    "    api_key=os.getenv(\"OPENAI_API_KEY\"),\n",
    "    temperature=float(os.getenv(\"TEMPERATURE\", 1.0)),\n",
    "    max_tokens= None,\n",
    "    # max_completion_tokens=3000,\n",
    "    cache=False\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "011b0ca4",
   "metadata": {},
   "outputs": [],
   "source": [
    "dspy.configure(lm= gpt_5_mini)\n",
    "\n",
    "allocator = dspy.Predict(\"goal,planner_desc,dataset->exact_word_complexity:Literal['unrelated','basic', 'intermediate', 'advanced'],reasoning\")\n",
    "\n",
    "\n",
    "session = allocator(goal=\"build me a regression model and then visualize the residuals\", planner_desc='{data_viz_agent:\"I love visualizaing\"}', dataset='housing dataset, can only answer housing')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0217d501",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Prediction(\n",
       "    exact_word_complexity='intermediate',\n",
       "    reasoning='Building a regression model and visualizing residuals requires moderate statistical and coding knowledge: selecting and preprocessing features from the housing dataset, splitting data, fitting a model (e.g., linear or regularized regression), computing evaluation metrics (MSE, R²), and creating diagnostic plots (residuals vs. fitted, histogram or KDE of residuals, Q–Q plot, and scale-location). It’s more than a basic copy-paste task because it involves assumption checks and exploratory/feature work, but it doesn’t require the advanced theory or highly specialized modeling techniques that would push it into “advanced.” The work is therefore best categorized as intermediate.'\n",
       ")"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "session"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2bf84f7e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "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.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}