Skip to content

Commit f093e9d

Browse files
committed
add change log
1 parent b5c40a4 commit f093e9d

27 files changed

+4359
-4116
lines changed

adalflow/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
1+
## [0.2.7] - TO Be Released
2+
### Added
3+
- `Memory` is completed with `call` and `add_dialog_turn` methods.
4+
- Integrated `LanceDB` in the `Retriever`
5+
### Improved
6+
- `BedrockAPIClient` added more details on setup, yet it is still in experimental stage.
7+
- `AzureAPIClient` added more details on setup, yet it is still in experimental stage.
28
## [0.2.6] - 2024-11-25
39
### Improved
410
- Add default `max_tokens=512` to the `AnthropicAPIClient` to avoid the error when the user does not provide the `max_tokens` in the prompt.

adalflow/adalflow/components/model_client/bedrock_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def get_first_message_content(completion: Dict) -> str:
3939
class BedrockAPIClient(ModelClient):
4040
__doc__ = r"""A component wrapper for the Bedrock API client.
4141
42+
Note:
43+
44+
This api is in experimental and is not fully tested and validated yet.
45+
4246
Support:
4347
1. AWS Titan
4448
2. Claude

notebooks/adalflow_colab_template.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
"\n",
8888
"\n",
8989
"# Set environment variables\n",
90-
"os.environ['OPENAI_API_KEY'] = openai_api_key\n",
91-
"os.environ['GROQ_API_KEY'] = groq_api_key\n",
90+
"os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n",
91+
"os.environ[\"GROQ_API_KEY\"] = groq_api_key\n",
9292
"\n",
9393
"print(\"API keys have been set.\")"
9494
]

notebooks/evaluation/adalflow_llm_eval.ipynb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"\n",
9696
"\n",
9797
"# Set environment variables\n",
98-
"os.environ['OPENAI_API_KEY'] = openai_api_key\n",
98+
"os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n",
9999
"\n",
100100
"print(\"API keys have been set.\")"
101101
]
@@ -301,11 +301,11 @@
301301
"source": [
302302
"# without questions, and with customized judgement query\n",
303303
"\n",
304+
"\n",
304305
"def compute_llm_as_judge_wo_questions():\n",
305306
" from adalflow.eval.llm_as_judge import LLMasJudge, DefaultLLMJudge\n",
306307
" from adalflow.components.model_client import OpenAIClient\n",
307308
"\n",
308-
"\n",
309309
" llm_judge = DefaultLLMJudge(\n",
310310
" model_client=OpenAIClient(),\n",
311311
" model_kwargs={\n",
@@ -413,7 +413,7 @@
413413
" eval_rslt = llm_evaluator.compute(\n",
414414
" questions=questions, gt_answers=gt_answers, pred_answers=pred_answers\n",
415415
" )\n",
416-
" print(eval_rslt)\n"
416+
" print(eval_rslt)"
417417
]
418418
},
419419
{
@@ -569,8 +569,12 @@
569569
}
570570
],
571571
"source": [
572-
"source=\"Paul Merson has restarted his row with Andros Townsend after the Tottenham midfielder was brought on with only seven minutes remaining in his team 's 0-0 draw with Burnley on Sunday . 'Just been watching the game , did you miss the coach ? # RubberDub # 7minutes , ' Merson put on Twitter . Merson initially angered Townsend for writing in his Sky Sports column that 'if Andros Townsend can get in ( the England team ) then it opens it up to anybody . ' Paul Merson had another dig at Andros Townsend after his appearance for Tottenham against Burnley Townsend was brought on in the 83rd minute for Tottenham as they drew 0-0 against Burnley Andros Townsend scores England 's equaliser in their 1-1 friendly draw with Italy in Turin on Tuesday night The former Arsenal man was proven wrong when Townsend hit a stunning equaliser for England against Italy and he duly admitted his mistake . 'It 's not as though I was watching hoping he would n't score for England , I 'm genuinely pleased for him and fair play to him \\u00e2\\u20ac\\u201c it was a great goal , ' Merson said . 'It 's just a matter of opinion , and my opinion was that he got pulled off after half an hour at Manchester United in front of Roy Hodgson , so he should n't have been in the squad . 'When I 'm wrong , I hold my hands up . I do n't have a problem with doing that - I 'll always be the first to admit when I 'm wrong . ' Townsend hit back at Merson on Twitter after scoring for England against Italy Sky Sports pundit Merson ( centre ) criticised Townsend 's call-up to the England squad last week Townsend hit back at Merson after netting for England in Turin on Wednesday , saying 'Not bad for a player that should be 'nowhere near the squad ' ay @ PaulMerse ? ' Any bad feeling between the pair seemed to have passed but Merson was unable to resist having another dig at Townsend after Tottenham drew at Turf Moor .\",\n",
573-
"summary=\"Paul merson was brought on with only seven minutes remaining in his team 's 0-0 draw with burnley . Andros townsend scored the tottenham midfielder in the 89th minute . Paul merson had another dig at andros townsend after his appearance . The midfielder had been brought on to the england squad last week . Click here for all the latest arsenal news news .\",\n",
572+
"source = (\n",
573+
" \"Paul Merson has restarted his row with Andros Townsend after the Tottenham midfielder was brought on with only seven minutes remaining in his team 's 0-0 draw with Burnley on Sunday . 'Just been watching the game , did you miss the coach ? # RubberDub # 7minutes , ' Merson put on Twitter . Merson initially angered Townsend for writing in his Sky Sports column that 'if Andros Townsend can get in ( the England team ) then it opens it up to anybody . ' Paul Merson had another dig at Andros Townsend after his appearance for Tottenham against Burnley Townsend was brought on in the 83rd minute for Tottenham as they drew 0-0 against Burnley Andros Townsend scores England 's equaliser in their 1-1 friendly draw with Italy in Turin on Tuesday night The former Arsenal man was proven wrong when Townsend hit a stunning equaliser for England against Italy and he duly admitted his mistake . 'It 's not as though I was watching hoping he would n't score for England , I 'm genuinely pleased for him and fair play to him \\u00e2\\u20ac\\u201c it was a great goal , ' Merson said . 'It 's just a matter of opinion , and my opinion was that he got pulled off after half an hour at Manchester United in front of Roy Hodgson , so he should n't have been in the squad . 'When I 'm wrong , I hold my hands up . I do n't have a problem with doing that - I 'll always be the first to admit when I 'm wrong . ' Townsend hit back at Merson on Twitter after scoring for England against Italy Sky Sports pundit Merson ( centre ) criticised Townsend 's call-up to the England squad last week Townsend hit back at Merson after netting for England in Turin on Wednesday , saying 'Not bad for a player that should be 'nowhere near the squad ' ay @ PaulMerse ? ' Any bad feeling between the pair seemed to have passed but Merson was unable to resist having another dig at Townsend after Tottenham drew at Turf Moor .\",\n",
574+
")\n",
575+
"summary = (\n",
576+
" \"Paul merson was brought on with only seven minutes remaining in his team 's 0-0 draw with burnley . Andros townsend scored the tottenham midfielder in the 89th minute . Paul merson had another dig at andros townsend after his appearance . The midfielder had been brought on to the england squad last week . Click here for all the latest arsenal news news .\",\n",
577+
")\n",
574578
"\n",
575579
"compute_g_eval_summarization(source=source, summary=summary)"
576580
]

notebooks/qas/adalflow_object_count_auto_optimization.ipynb

Lines changed: 77 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@
137137
"\n",
138138
"# Prompt user to enter their API keys securely\n",
139139
"openai_api_key = getpass(\"Please enter your OpenAI API key: \")\n",
140-
"groq_api_key = getpass(\"Please enter your GROQ API key, simplly press Enter if you don't have one: \")\n",
140+
"groq_api_key = getpass(\n",
141+
" \"Please enter your GROQ API key, simplly press Enter if you don't have one: \"\n",
142+
")\n",
141143
"\n",
142144
"\n",
143145
"# Set environment variables\n",
144-
"os.environ['OPENAI_API_KEY'] = openai_api_key\n",
145-
"os.environ['GROQ_API_KEY'] = groq_api_key\n",
146+
"os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n",
147+
"os.environ[\"GROQ_API_KEY\"] = groq_api_key\n",
146148
"\n",
147149
"print(\"API keys have been set.\")"
148150
]
@@ -209,6 +211,7 @@
209211
"<END_OF_USER>\n",
210212
"\"\"\"\n",
211213
"\n",
214+
"\n",
212215
"class ObjectCountTaskPipeline(adal.Component):\n",
213216
" def __init__(self, model_client: adal.ModelClient, model_kwargs: Dict):\n",
214217
" super().__init__()\n",
@@ -242,9 +245,7 @@
242245
" self, question: str, id: str = None\n",
243246
" ) -> Union[adal.GeneratorOutput, adal.Parameter]:\n",
244247
" output = self.llm_counter(prompt_kwargs={\"input_str\": question}, id=id)\n",
245-
" return output\n",
246-
"\n",
247-
"\n"
248+
" return output"
248249
]
249250
},
250251
{
@@ -329,44 +330,42 @@
329330
"from adalflow.components.model_client.groq_client import GroqAPIClient\n",
330331
"\n",
331332
"\n",
332-
"if len(os.environ['OPENAI_API_KEY']) > 1:\n",
333-
" gpt_3_model = {\n",
334-
" \"model_client\": OpenAIClient(),\n",
335-
" \"model_kwargs\": {\n",
336-
" \"model\": \"gpt-3.5-turbo\",\n",
337-
" \"max_tokens\": 2000,\n",
338-
" \"temperature\": 0.0,\n",
339-
" \"top_p\": 0.99,\n",
340-
" \"frequency_penalty\": 0,\n",
341-
" \"presence_penalty\": 0,\n",
342-
" \"stop\": None,\n",
343-
" },\n",
344-
" }\n",
345-
" gpt_4o_model = {\n",
346-
" \"model_client\": OpenAIClient(),\n",
347-
" \"model_kwargs\": {\n",
348-
" \"model\": \"gpt-4o\",\n",
349-
" \"max_tokens\": 4000,\n",
350-
" \"temperature\": 0.0,\n",
351-
" \"top_p\": 0.99,\n",
352-
" \"frequency_penalty\": 0,\n",
353-
" \"presence_penalty\": 0,\n",
354-
" \"stop\": None,\n",
355-
" },\n",
356-
" }\n",
333+
"if len(os.environ[\"OPENAI_API_KEY\"]) > 1:\n",
334+
" gpt_3_model = {\n",
335+
" \"model_client\": OpenAIClient(),\n",
336+
" \"model_kwargs\": {\n",
337+
" \"model\": \"gpt-3.5-turbo\",\n",
338+
" \"max_tokens\": 2000,\n",
339+
" \"temperature\": 0.0,\n",
340+
" \"top_p\": 0.99,\n",
341+
" \"frequency_penalty\": 0,\n",
342+
" \"presence_penalty\": 0,\n",
343+
" \"stop\": None,\n",
344+
" },\n",
345+
" }\n",
346+
" gpt_4o_model = {\n",
347+
" \"model_client\": OpenAIClient(),\n",
348+
" \"model_kwargs\": {\n",
349+
" \"model\": \"gpt-4o\",\n",
350+
" \"max_tokens\": 4000,\n",
351+
" \"temperature\": 0.0,\n",
352+
" \"top_p\": 0.99,\n",
353+
" \"frequency_penalty\": 0,\n",
354+
" \"presence_penalty\": 0,\n",
355+
" \"stop\": None,\n",
356+
" },\n",
357+
" }\n",
357358
"\n",
358-
"if len(os.environ['GROQ_API_KEY']) > 1:\n",
359-
" llama_3_1_model ={\n",
360-
" \"model_client\": GroqAPIClient(),\n",
361-
" \"model_kwargs\": {\n",
362-
" \"model\": \"llama-3.1-8b-instant\"\n",
363-
" }\n",
364-
" }\n",
359+
"if len(os.environ[\"GROQ_API_KEY\"]) > 1:\n",
360+
" llama_3_1_model = {\n",
361+
" \"model_client\": GroqAPIClient(),\n",
362+
" \"model_kwargs\": {\"model\": \"llama-3.1-8b-instant\"},\n",
363+
" }\n",
365364
"\n",
366365
"\n",
367366
"question = \"I have a flute, a piano, a trombone, four stoves, a violin, an accordion, a clarinet, a drum, two lamps, and a trumpet. How many musical instruments do I have?\"\n",
368367
"task_pipeline = ObjectCountTaskPipeline(**gpt_3_model)\n",
369-
"print(task_pipeline)\n"
368+
"print(task_pipeline)"
370369
]
371370
},
372371
{
@@ -467,6 +466,7 @@
467466
"from adalflow.datasets.big_bench_hard import BigBenchHard\n",
468467
"from adalflow.utils.data import subset_dataset\n",
469468
"\n",
469+
"\n",
470470
"def load_datasets(max_samples: int = None):\n",
471471
" \"\"\"Load the dataset\"\"\"\n",
472472
" train_data = BigBenchHard(split=\"train\")\n",
@@ -479,7 +479,7 @@
479479
" val_data = subset_dataset(val_data, max_samples)\n",
480480
" test_data = subset_dataset(test_data, max_samples)\n",
481481
"\n",
482-
" return train_data, val_data, test_data\n"
482+
" return train_data, val_data, test_data"
483483
]
484484
},
485485
{
@@ -583,11 +583,11 @@
583583
" def prepare_task(self, sample: Example):\n",
584584
" return self.task.call, {\"question\": sample.question, \"id\": sample.id}\n",
585585
"\n",
586-
" def prepare_eval(\n",
587-
" self, sample: Example, y_pred: adal.GeneratorOutput\n",
588-
" ) -> float:\n",
586+
" def prepare_eval(self, sample: Example, y_pred: adal.GeneratorOutput) -> float:\n",
589587
" y_label = -1\n",
590-
" if (y_pred is not None and y_pred.data is not None): # if y_pred and y_pred.data: might introduce bug when the data is 0\n",
588+
" if (\n",
589+
" y_pred is not None and y_pred.data is not None\n",
590+
" ): # if y_pred and y_pred.data: might introduce bug when the data is 0\n",
591591
" y_label = y_pred.data\n",
592592
" return self.eval_fn, {\"y\": y_label, \"y_gt\": sample.answer}"
593593
]
@@ -820,7 +820,7 @@
820820
"from adalflow.datasets.types import Example\n",
821821
"\n",
822822
"\n",
823-
"class ObjectCountAdalComponent(adal.AdalComponent):# noqa: F811\n",
823+
"class ObjectCountAdalComponent(adal.AdalComponent): # noqa: F811\n",
824824
" def __init__(\n",
825825
" self,\n",
826826
" model_client: adal.ModelClient,\n",
@@ -844,12 +844,11 @@
844844
" def prepare_task(self, sample: Example):\n",
845845
" return self.task.call, {\"question\": sample.question, \"id\": sample.id}\n",
846846
"\n",
847-
"\n",
848-
" def prepare_eval(\n",
849-
" self, sample: Example, y_pred: adal.GeneratorOutput\n",
850-
" ) -> float:\n",
847+
" def prepare_eval(self, sample: Example, y_pred: adal.GeneratorOutput) -> float:\n",
851848
" y_label = -1\n",
852-
" if (y_pred is not None and y_pred.data is not None): # if y_pred and y_pred.data: might introduce bug when the data is 0\n",
849+
" if (\n",
850+
" y_pred is not None and y_pred.data is not None\n",
851+
" ): # if y_pred and y_pred.data: might introduce bug when the data is 0\n",
853852
" y_label = y_pred.data\n",
854853
" return self.eval_fn, {\"y\": y_label, \"y_gt\": sample.answer}\n",
855854
"\n",
@@ -891,7 +890,7 @@
891890
" **gpt_3_model,\n",
892891
" teacher_model_config=gpt_4o_model,\n",
893892
" text_optimizer_model_config=gpt_4o_model,\n",
894-
" backward_engine_model_config=gpt_4o_model\n",
893+
" backward_engine_model_config=gpt_4o_model,\n",
895894
" )\n",
896895
" print(adal_component)\n",
897896
" trainer = adal.Trainer(\n",
@@ -916,7 +915,7 @@
916915
" test_dataset=test_dataset,\n",
917916
" debug=debug,\n",
918917
" resume_from_ckpt=resume_from_ckpt,\n",
919-
" )\n"
918+
" )"
920919
]
921920
},
922921
{
@@ -3255,10 +3254,14 @@
32553254
}
32563255
],
32573256
"source": [
3258-
"train(debug=False, max_steps=12, strategy=\"constrained\",\n",
3259-
" raw_shots=0, bootstrap_shots=1,\n",
3260-
" exclude_input_fields_from_bootstrap_demos=True\n",
3261-
" )"
3257+
"train(\n",
3258+
" debug=False,\n",
3259+
" max_steps=12,\n",
3260+
" strategy=\"constrained\",\n",
3261+
" raw_shots=0,\n",
3262+
" bootstrap_shots=1,\n",
3263+
" exclude_input_fields_from_bootstrap_demos=True,\n",
3264+
")"
32623265
]
32633266
},
32643267
{
@@ -6015,13 +6018,17 @@
60156018
}
60166019
],
60176020
"source": [
6018-
"\n",
60196021
"ckpt_path = \"/content/adalflow/ckpt/ObjectCountAdalComponent/constrained_max_steps_12_4e8a1_run_1.json\"\n",
60206022
"\n",
6021-
"train(debug=False, max_steps=12, strategy=\"constrained\",\n",
6022-
" raw_shots=0, bootstrap_shots=1,\n",
6023-
" resume_from_ckpt=ckpt_path,\n",
6024-
" exclude_input_fields_from_bootstrap_demos=True)"
6023+
"train(\n",
6024+
" debug=False,\n",
6025+
" max_steps=12,\n",
6026+
" strategy=\"constrained\",\n",
6027+
" raw_shots=0,\n",
6028+
" bootstrap_shots=1,\n",
6029+
" resume_from_ckpt=ckpt_path,\n",
6030+
" exclude_input_fields_from_bootstrap_demos=True,\n",
6031+
")"
60256032
]
60266033
},
60276034
{
@@ -8038,11 +8045,15 @@
80388045
}
80398046
],
80408047
"source": [
8041-
"\n",
8042-
"train(debug=False, max_steps=12, strategy=\"random\",\n",
8043-
" raw_shots=0, bootstrap_shots=1,\n",
8044-
" resume_from_ckpt=ckpt_path,\n",
8045-
" exclude_input_fields_from_bootstrap_demos=False)"
8048+
"train(\n",
8049+
" debug=False,\n",
8050+
" max_steps=12,\n",
8051+
" strategy=\"random\",\n",
8052+
" raw_shots=0,\n",
8053+
" bootstrap_shots=1,\n",
8054+
" resume_from_ckpt=ckpt_path,\n",
8055+
" exclude_input_fields_from_bootstrap_demos=False,\n",
8056+
")"
80468057
]
80478058
},
80488059
{

notebooks/tutorials/adalflow_classification_optimization.ipynb

Lines changed: 455 additions & 457 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)