@@ -104,52 +104,45 @@ Click [here](./examples/quickstart.ipynb) to see an extended quickstart example.
104
104
import pandas as pd
105
105
106
106
from adala.agents import Agent
107
- from adala.datasets import DataFrameDataset
108
- from adala.environments import BasicEnvironment
107
+ from adala.environments import StaticEnvironment
109
108
from adala.skills import ClassificationSkill
110
- from adala.runtimes import OpenAIRuntime
109
+ from adala.runtimes import OpenAIChatRuntime
111
110
from rich import print
112
111
113
112
# Train dataset
114
- ground_truth_df = pd.DataFrame([
113
+ train_df = pd.DataFrame([
115
114
[" It was the negative first impressions, and then it started working." , " Positive" ],
116
115
[" Not loud enough and doesn't turn on like it should." , " Negative" ],
117
116
[" I don't know what to say." , " Neutral" ],
118
117
[" Manager was rude, but the most important that mic shows very flat frequency response." , " Positive" ],
119
118
[" The phone doesn't seem to accept anything except CBR mp3s." , " Negative" ],
120
119
[" I tried it before, I bought this device for my son." , " Neutral" ],
121
- ], columns = [" text" , " ground_truth " ])
120
+ ], columns = [" text" , " sentiment " ])
122
121
123
122
# Test dataset
124
- predict_df = pd.DataFrame([
123
+ test_df = pd.DataFrame([
125
124
" All three broke within two months of use." ,
126
125
" The device worked for a long time, can't say anything bad." ,
127
126
" Just a random line of text."
128
127
], columns = [" text" ])
129
128
130
- ground_truth_dataset = DataFrameDataset(df = ground_truth_df)
131
- predict_dataset = DataFrameDataset(df = predict_df)
132
-
133
129
agent = Agent(
134
130
# connect to a dataset
135
- environment = BasicEnvironment(
136
- ground_truth_dataset = ground_truth_dataset,
137
- ground_truth_columns = {" sentiment_classification" : " ground_truth" }
138
- ),
131
+ environment = StaticEnvironment(df = train_df),
139
132
140
133
# define a skill
141
134
skills = ClassificationSkill(
142
- name = ' sentiment_classification ' ,
135
+ name = ' sentiment ' ,
143
136
instructions = " Label text as positive, negative or neutral." ,
144
- labels = [" Positive" , " Negative" , " Neutral" ],
145
- input_data_field = ' text'
137
+ labels = {' sentiment' : [" Positive" , " Negative" , " Neutral" ]},
138
+ input_template = " Text: {text} " ,
139
+ output_template = " Sentiment: {sentiment} "
146
140
),
147
141
148
142
# define all the different runtimes your skills may use
149
143
runtimes = {
150
144
# You can specify your OPENAI API KEY here via `OpenAIRuntime(..., api_key='your-api-key')`
151
- ' openai' : OpenAIRuntime(model = ' gpt-3.5-turbo-instruct' ),
152
- ' openai-gpt3' : OpenAIRuntime(model = ' gpt-3.5-turbo' )
145
+ ' openai' : OpenAIChatRuntime(model = ' gpt-3.5-turbo' ),
153
146
},
154
147
default_runtime = ' openai' ,
155
148
@@ -166,7 +159,7 @@ print(agent.skills)
166
159
agent.learn(learning_iterations = 3 , accuracy_threshold = 0.95 )
167
160
168
161
print (' \n => Run tests ...' )
169
- predictions = agent.run(predict_dataset )
162
+ predictions = agent.run(test_df )
170
163
print (' \n => Test results:' )
171
164
print (predictions)
172
165
```
0 commit comments