openai-sdk-helpers 0.4.3__py3-none-any.whl → 0.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. openai_sdk_helpers/__init__.py +41 -7
  2. openai_sdk_helpers/agent/__init__.py +1 -2
  3. openai_sdk_helpers/agent/base.py +169 -190
  4. openai_sdk_helpers/agent/configuration.py +12 -20
  5. openai_sdk_helpers/agent/coordinator.py +14 -17
  6. openai_sdk_helpers/agent/runner.py +3 -45
  7. openai_sdk_helpers/agent/search/base.py +49 -71
  8. openai_sdk_helpers/agent/search/vector.py +82 -110
  9. openai_sdk_helpers/agent/search/web.py +103 -81
  10. openai_sdk_helpers/agent/summarizer.py +20 -28
  11. openai_sdk_helpers/agent/translator.py +17 -23
  12. openai_sdk_helpers/agent/validator.py +17 -23
  13. openai_sdk_helpers/errors.py +9 -0
  14. openai_sdk_helpers/extract/__init__.py +23 -0
  15. openai_sdk_helpers/extract/extractor.py +157 -0
  16. openai_sdk_helpers/extract/generator.py +476 -0
  17. openai_sdk_helpers/files_api.py +1 -0
  18. openai_sdk_helpers/logging.py +12 -1
  19. openai_sdk_helpers/prompt/extractor_config_agent_instructions.jinja +6 -0
  20. openai_sdk_helpers/prompt/extractor_config_generator.jinja +37 -0
  21. openai_sdk_helpers/prompt/extractor_config_generator_instructions.jinja +9 -0
  22. openai_sdk_helpers/prompt/extractor_prompt_optimizer_agent_instructions.jinja +4 -0
  23. openai_sdk_helpers/prompt/extractor_prompt_optimizer_request.jinja +11 -0
  24. openai_sdk_helpers/response/__init__.py +2 -6
  25. openai_sdk_helpers/response/base.py +233 -164
  26. openai_sdk_helpers/response/configuration.py +39 -14
  27. openai_sdk_helpers/response/files.py +41 -2
  28. openai_sdk_helpers/response/runner.py +1 -48
  29. openai_sdk_helpers/response/tool_call.py +0 -141
  30. openai_sdk_helpers/response/vector_store.py +8 -5
  31. openai_sdk_helpers/streamlit_app/app.py +1 -9
  32. openai_sdk_helpers/structure/__init__.py +16 -0
  33. openai_sdk_helpers/structure/base.py +239 -278
  34. openai_sdk_helpers/structure/extraction.py +1228 -0
  35. openai_sdk_helpers/structure/plan/plan.py +0 -20
  36. openai_sdk_helpers/structure/plan/task.py +0 -33
  37. openai_sdk_helpers/structure/prompt.py +16 -0
  38. openai_sdk_helpers/structure/responses.py +2 -2
  39. openai_sdk_helpers/structure/web_search.py +0 -10
  40. openai_sdk_helpers/tools.py +346 -99
  41. openai_sdk_helpers/utils/__init__.py +7 -0
  42. openai_sdk_helpers/utils/json/base_model.py +315 -32
  43. openai_sdk_helpers/utils/langextract.py +194 -0
  44. openai_sdk_helpers/vector_storage/cleanup.py +7 -2
  45. openai_sdk_helpers/vector_storage/storage.py +37 -7
  46. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/METADATA +21 -6
  47. openai_sdk_helpers-0.5.1.dist-info/RECORD +95 -0
  48. openai_sdk_helpers/streamlit_app/streamlit_web_search.py +0 -75
  49. openai_sdk_helpers-0.4.3.dist-info/RECORD +0 -86
  50. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/WHEEL +0 -0
  51. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/entry_points.txt +0 -0
  52. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/licenses/LICENSE +0 -0
@@ -208,7 +208,11 @@ class VectorStorage:
208
208
  self._existing_files[file_name] = f.id
209
209
 
210
210
  except Exception as exc:
211
- log(f"Failed to load existing files: {exc}", level=logging.ERROR)
211
+ log(
212
+ f"Failed to load existing files: {exc}",
213
+ level=logging.ERROR,
214
+ exc=exc,
215
+ )
212
216
  self._existing_files = {}
213
217
  return self._existing_files
214
218
 
@@ -231,7 +235,11 @@ class VectorStorage:
231
235
  result[file_name] = f.id
232
236
  return result
233
237
  except Exception as exc:
234
- log(f"Failed to load existing files: {exc}", level=logging.ERROR)
238
+ log(
239
+ f"Failed to load existing files: {exc}",
240
+ level=logging.ERROR,
241
+ exc=exc,
242
+ )
235
243
  return {}
236
244
 
237
245
  def upload_file(
@@ -328,7 +336,11 @@ class VectorStorage:
328
336
 
329
337
  return VectorStorageFileInfo(name=file_name, id=file.id, status="success")
330
338
  except Exception as exc:
331
- log(f"Error uploading {file_name}: {str(exc)}", level=logging.ERROR)
339
+ log(
340
+ f"Error uploading {file_name}: {str(exc)}",
341
+ level=logging.ERROR,
342
+ exc=exc,
343
+ )
332
344
  return VectorStorageFileInfo(
333
345
  name=file_name, id="", status="error", error=str(exc)
334
346
  )
@@ -447,6 +459,7 @@ class VectorStorage:
447
459
  log(
448
460
  f"Warning: Could not delete file {file_id} from Files API: {file_delete_exc}",
449
461
  level=logging.WARNING,
462
+ exc=file_delete_exc,
450
463
  )
451
464
 
452
465
  to_remove = [k for k, v in self.existing_files.items() if v == file_id]
@@ -457,7 +470,11 @@ class VectorStorage:
457
470
  name=to_remove[0] if to_remove else "", id=file_id, status="success"
458
471
  )
459
472
  except Exception as exc:
460
- log(f"Error deleting file {file_id}: {str(exc)}", level=logging.ERROR)
473
+ log(
474
+ f"Error deleting file {file_id}: {str(exc)}",
475
+ level=logging.ERROR,
476
+ exc=exc,
477
+ )
461
478
  return VectorStorageFileInfo(
462
479
  name="", id=file_id, status="failed", error=str(exc)
463
480
  )
@@ -524,6 +541,7 @@ class VectorStorage:
524
541
  log(
525
542
  f"Error deleting vector store '{self._vector_storage.name}': {str(exc)}",
526
543
  level=logging.ERROR,
544
+ exc=exc,
527
545
  )
528
546
 
529
547
  def download_files(self, output_dir: str) -> VectorStorageFileStats:
@@ -551,7 +569,11 @@ class VectorStorage:
551
569
  )
552
570
  store_files = list(getattr(files, "data", files))
553
571
  except Exception as exc:
554
- log(f"Failed to list files for download: {exc}", level=logging.ERROR)
572
+ log(
573
+ f"Failed to list files for download: {exc}",
574
+ level=logging.ERROR,
575
+ exc=exc,
576
+ )
555
577
  return VectorStorageFileStats(
556
578
  total=0,
557
579
  fail=1,
@@ -582,7 +604,11 @@ class VectorStorage:
582
604
  handle.write(data)
583
605
  stats.success += 1
584
606
  except Exception as exc:
585
- log(f"Failed to download {file_id}: {exc}", level=logging.ERROR)
607
+ log(
608
+ f"Failed to download {file_id}: {exc}",
609
+ level=logging.ERROR,
610
+ exc=exc,
611
+ )
586
612
  stats.fail += 1
587
613
  stats.errors.append(
588
614
  VectorStorageFileInfo(
@@ -621,7 +647,11 @@ class VectorStorage:
621
647
  )
622
648
  return response
623
649
  except Exception as exc:
624
- log(f"Error searching vector store: {str(exc)}", level=logging.ERROR)
650
+ log(
651
+ f"Error searching vector store: {str(exc)}",
652
+ level=logging.ERROR,
653
+ exc=exc,
654
+ )
625
655
  return None
626
656
 
627
657
  def summarize(self, query: str, *, top_k: int = 15) -> str | None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openai-sdk-helpers
3
- Version: 0.4.3
3
+ Version: 0.5.1
4
4
  Summary: Composable helpers for OpenAI SDK agents, prompts, and storage
5
5
  Author: openai-sdk-helpers maintainers
6
6
  License: MIT
@@ -17,6 +17,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
17
  Classifier: Typing :: Typed
18
18
  Requires-Python: >=3.10
19
19
  Requires-Dist: jinja2
20
+ Requires-Dist: langextract
20
21
  Requires-Dist: openai-agents<1.0.0,>=0.6.4
21
22
  Requires-Dist: openai<3.0.0,>=2.14.0
22
23
  Requires-Dist: pydantic<3,>=2.7
@@ -31,6 +32,8 @@ Requires-Dist: pyright; extra == 'dev'
31
32
  Requires-Dist: pytest; extra == 'dev'
32
33
  Requires-Dist: pytest-asyncio; extra == 'dev'
33
34
  Requires-Dist: pytest-cov; extra == 'dev'
35
+ Provides-Extra: extract
36
+ Requires-Dist: langextract; extra == 'extract'
34
37
  Description-Content-Type: text/markdown
35
38
 
36
39
  <div align="center">
@@ -78,7 +81,7 @@ structures, configuration helpers, and orchestration utilities—while leaving
78
81
  application-specific prompts and tools to the consuming project.
79
82
 
80
83
  **Important**: This library integrates with **two distinct OpenAI SDKs**:
81
- - **`openai-agents`** - Used by the `agent` module for high-level agent workflows with automatic tool handling and streaming
84
+ - **`openai-agents`** - Used by the `agent` module for high-level agent workflows with automatic tool handling
82
85
  - **`openai`** - Used by the `response` module for direct API interactions with fine-grained control over responses
83
86
 
84
87
  The `agent` module provides a higher-level abstraction for building agents, while the `response` module offers lower-level control for custom response handling workflows.
@@ -302,7 +305,7 @@ response.close()
302
305
  ```
303
306
 
304
307
  **Key Differences:**
305
- - **Agent Module**: Higher-level abstraction with built-in streaming, automatic tool handling, and agent-specific workflows
308
+ - **Agent Module**: Higher-level abstraction with automatic tool handling and agent-specific workflows
306
309
  - **Response Module**: Lower-level control with manual message management, custom tool handlers, and direct API access
307
310
 
308
311
  ## Advanced Usage
@@ -327,7 +330,7 @@ with ResponseBase(
327
330
  ) as response:
328
331
  # Automatic type detection - single files parameter
329
332
  # Images are sent as base64-encoded images
330
- # Documents are sent as base64-encoded file data
333
+ # PDF documents are sent as base64-encoded file data
331
334
  result = response.run_sync(
332
335
  "Analyze these files",
333
336
  files=["photo.jpg", "document.pdf"]
@@ -353,7 +356,8 @@ with ResponseBase(
353
356
  **How It Works:**
354
357
 
355
358
  - **Images** (jpg, png, gif, etc.) are automatically sent as base64-encoded images
356
- - **Documents** (pdf, txt, xlsx, etc.) are sent as base64-encoded file data by default
359
+ - **Documents** are sent as base64-encoded file data by default for PDFs only
360
+ - **Non-PDF documents** should use `use_vector_store=True` (or be converted to PDF)
357
361
  - **Vector Stores** can optionally be used for documents when `use_vector_store=True`
358
362
  - **Batch Processing** is automatically used for multiple files (>3) for efficient encoding
359
363
 
@@ -523,7 +527,7 @@ The package is organized around cohesive, reusable building blocks:
523
527
 
524
528
  ### Agent Modules (Built on `openai-agents` SDK)
525
529
 
526
- These modules use the `openai-agents` SDK for high-level agent workflows with automatic streaming, tool handling, and conversation management.
530
+ These modules use the `openai-agents` SDK for high-level agent workflows with automatic tool handling and conversation management.
527
531
 
528
532
  - **`openai_sdk_helpers.agent.base.AgentBase`**
529
533
  Base class for all agents with synchronous and asynchronous execution support.
@@ -585,6 +589,17 @@ These modules use the standard `openai` SDK for direct API interactions with fin
585
589
  - **`openai_sdk_helpers.utils`**
586
590
  JSON serialization helpers, logging utilities, and common validation functions.
587
591
 
592
+ - **`openai_sdk_helpers.utils.langextract`**
593
+ Adapter helpers for running LangExtract-style extractors and validating the
594
+ results into Pydantic models.
595
+
596
+ ## Related Projects
597
+
598
+ - **[LangExtract](https://github.com/google/langextract)**
599
+ Google-maintained toolkit for extracting structured data from language model
600
+ outputs, which can complement the validation and response utilities in
601
+ `openai-sdk-helpers`.
602
+
588
603
  ## Contributing
589
604
 
590
605
  Contributions are welcome! We appreciate functional changes accompanied by
@@ -0,0 +1,95 @@
1
+ openai_sdk_helpers/__init__.py,sha256=8I469KuzrbAjhNX2A5UnYt_kSmjXqQbfHectTeUx7TI,5163
2
+ openai_sdk_helpers/cli.py,sha256=BDc08NqWVfL4GBekxMfN5IPPB4pmN1Od9sVpKtIJRZk,8025
3
+ openai_sdk_helpers/environment.py,sha256=mNoswzIdv37tTRhFwA2B6_Onxsm7vhfjPArfwhYuL7g,1825
4
+ openai_sdk_helpers/errors.py,sha256=ZclLp94o08fSsFNjFn_yrX9yTjw1RE0v7A5T1hBChUc,2925
5
+ openai_sdk_helpers/files_api.py,sha256=Sg-k4YDsrzggvICYA7h4Ua6_vGhMpZmAeS5JtQVE2hU,12598
6
+ openai_sdk_helpers/logging.py,sha256=djtMo_R_88JjxJeUGU_hSlYCTRv3ffoSu1ocOKrUBIw,1153
7
+ openai_sdk_helpers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ openai_sdk_helpers/settings.py,sha256=xK_u0YNKgtPrLrZrVr4F4k0CvSuYbsmkqqw9mCMdyF8,10932
9
+ openai_sdk_helpers/tools.py,sha256=8hhcytpmDfoXV16UQbDmDVV0rhLOn8c_VjXO8XaTFLQ,19000
10
+ openai_sdk_helpers/types.py,sha256=ejCG0rYqJhjOQvKLoNnzq-TzcKCFt69GVfi7y805NkU,1451
11
+ openai_sdk_helpers/agent/__init__.py,sha256=SRz8WupyS89c7sYML2hkwZLkIu6zczyI9MVyDWAHK1w,1040
12
+ openai_sdk_helpers/agent/base.py,sha256=8LIwi7zuYcOsXBjpsNdFTdpY8Ih-iAYXkqzLn4wkd1w,26144
13
+ openai_sdk_helpers/agent/configuration.py,sha256=FU3xnb8-8qoezLW47WwxZg7z2AxNXRW1Svl0FMsk8kc,14244
14
+ openai_sdk_helpers/agent/coordinator.py,sha256=lVjA0yI-GhGKlqbNR_k9GOCrUjFoZ0QoqRaafHckyME,18052
15
+ openai_sdk_helpers/agent/runner.py,sha256=l2NPS9VA9d4RISuBfanFfKxXNYSHQ7MTjRsuzx4APls,3473
16
+ openai_sdk_helpers/agent/summarizer.py,sha256=-yVm-KdTvGRXGj1MlEikTAFYVlPoovLNIL3Tc_WYIzs,3653
17
+ openai_sdk_helpers/agent/translator.py,sha256=6Gj1cqT-W5j32F14sY9kOCFQenq_odceu2fi8hud_Z0,5970
18
+ openai_sdk_helpers/agent/utils.py,sha256=DTD5foCqGYfXf13F2bZMYIQROl7SbDSy5GDPGi0Zl-0,1089
19
+ openai_sdk_helpers/agent/validator.py,sha256=krktzjaHhEprn76F7hD4cH6H2CwucmFN1KWJ_vjl01g,4774
20
+ openai_sdk_helpers/agent/search/__init__.py,sha256=LXXzEcX2MU7_htHRdRCGPw0hsr9CrZn0ESii7GZJMBw,806
21
+ openai_sdk_helpers/agent/search/base.py,sha256=BonbNL7yAQyImhPTrsxZs5axLmaTbwjVGdADNYQaEvY,9764
22
+ openai_sdk_helpers/agent/search/vector.py,sha256=7GoDwvarwyIJIYlP-JpMyH1XokInNalRUJT0HNdQMBk,14130
23
+ openai_sdk_helpers/agent/search/web.py,sha256=vwBKmLNhE6PGswQPjr-sTOPfPURLlwlX7Wm1ysY6w7U,11502
24
+ openai_sdk_helpers/enums/__init__.py,sha256=aFf79C4JBeLC3kMlJfSpehyjx5uNCtW6eK5rD6ZFfhM,322
25
+ openai_sdk_helpers/enums/base.py,sha256=cNllDtzcgI0_eZYXxFko14yhxwicX6xbeDfz9gFE3qo,2753
26
+ openai_sdk_helpers/extract/__init__.py,sha256=T8xtBEm_Mlu5SeXVn4Qv87uGDXed9L0JQaY_gryR1CQ,734
27
+ openai_sdk_helpers/extract/extractor.py,sha256=vmRJyhKDEYAVfRk0KMgLH5hTqUfDAUyWBug5gR3yzcc,5313
28
+ openai_sdk_helpers/extract/generator.py,sha256=K9Euq0IaWs82oe5aRm73_18DelLKYyuH8VhfZ1_ZCEU,14695
29
+ openai_sdk_helpers/prompt/__init__.py,sha256=MOqgKwG9KLqKudoKRlUfLxiSmdOi2aD6hNrWDFqLHkk,418
30
+ openai_sdk_helpers/prompt/base.py,sha256=6X0zeopEvO0ba8207O8Nnj1QvFZEZier7kNNh4qkcmE,7782
31
+ openai_sdk_helpers/prompt/extractor_config_agent_instructions.jinja,sha256=vCrsoUnsgHWSr7OS_ojMUjmPtHfbyv9bzKfaMaCJ99E,329
32
+ openai_sdk_helpers/prompt/extractor_config_generator.jinja,sha256=9rZ1PZdoQtnxDxFUlKRb0SooIEfNw4_Em99n9xvFyyU,960
33
+ openai_sdk_helpers/prompt/extractor_config_generator_instructions.jinja,sha256=GqV3DrGObyER_Fa-GMGGqhWBrQIH9FFlyKdgTjidyzg,534
34
+ openai_sdk_helpers/prompt/extractor_prompt_optimizer_agent_instructions.jinja,sha256=vDCXs1segU-9w9f5Fjp2PfWoXUeOeYw8SBLkAKS8plo,129
35
+ openai_sdk_helpers/prompt/extractor_prompt_optimizer_request.jinja,sha256=YC5uY18CeEXwlnWXOD-vke0npd7Mk-BHRBLjvQzq5lk,280
36
+ openai_sdk_helpers/prompt/summarizer.jinja,sha256=jliSetWDISbql1EkWi1RB8-L_BXUg8JMkRRsPRHuzbY,309
37
+ openai_sdk_helpers/prompt/translator.jinja,sha256=SZhW8ipEzM-9IA4wyS_r2wIMTAclWrilmk1s46njoL0,291
38
+ openai_sdk_helpers/prompt/validator.jinja,sha256=6t8q_IdxFd3mVBGX6SFKNOert1Wo3YpTOji2SNEbbtE,547
39
+ openai_sdk_helpers/prompt/vector_planner.jinja,sha256=szzuJu6ZawYWuARgQn4DykBLigHfCd0lKYM-GRgoR30,282
40
+ openai_sdk_helpers/prompt/vector_search.jinja,sha256=KPEYQDRKsUesadSyQcBBiqYQEDL1NLN6BQsqw-GcKMA,249
41
+ openai_sdk_helpers/prompt/vector_writer.jinja,sha256=q5osfexGvt1xn8ZPtBWUP36n_1HK_Ziu8dkmCZDVamc,342
42
+ openai_sdk_helpers/response/__init__.py,sha256=YFrGpnMIfatnLWXAZgZDMvDx7Yjsqjat8W9INxKuPxY,1728
43
+ openai_sdk_helpers/response/base.py,sha256=pz4JT_7K8_pwjoogag1znvO-_NC0HV5xAgkHkWqX_8k,37559
44
+ openai_sdk_helpers/response/configuration.py,sha256=jxneKd7oj08D40ceOWETB3TeUHd7Cnz-ooQp0akI9fA,10465
45
+ openai_sdk_helpers/response/files.py,sha256=O--boEPdFGsf9pHXPuNtG0aVJG2ZzwR4L1CZDW0hBP4,14450
46
+ openai_sdk_helpers/response/messages.py,sha256=qX3sW79rLuJEys28zyv5MovZikwGOaLevzdVN0VYMRE,10104
47
+ openai_sdk_helpers/response/planner.py,sha256=AuNMZkd4TGnvybSJaf2iMbvfPINbusrWucWBk2uQN_g,340
48
+ openai_sdk_helpers/response/prompter.py,sha256=TLRLmNwPcxaaB_X76BbvwXlphducPKYVbn-afTqN2Rk,344
49
+ openai_sdk_helpers/response/runner.py,sha256=3VmWY5du5iBwjVU9D0n2hexu61f561m2iTvhkmq30rc,2932
50
+ openai_sdk_helpers/response/tool_call.py,sha256=Y0ub14WJyuVyj9gRdnHFH2e-ezkfhJ9nnMlkubMKdug,2938
51
+ openai_sdk_helpers/response/vector_store.py,sha256=HClp6O_g20uklQTY7trC4age3rtDmrt3tuvrl93xIf4,3222
52
+ openai_sdk_helpers/streamlit_app/__init__.py,sha256=3yAkl6qV71cqtT5YFZuC9Bkqit0NtffDV6jmMWpT1k4,812
53
+ openai_sdk_helpers/streamlit_app/app.py,sha256=kkjtdCKVwrJ9nZWuBArm3dhvcjMESX0TMqAiF61_JLM,17402
54
+ openai_sdk_helpers/streamlit_app/configuration.py,sha256=0KeJ4HqCNFthBHsedV6ptqHluAcTPBb5_TujFOGkIUU,16685
55
+ openai_sdk_helpers/structure/__init__.py,sha256=JRdhEFPLDwty8tuAzCmep59RSknorZ4Dd7cyqonOi4Q,3891
56
+ openai_sdk_helpers/structure/agent_blueprint.py,sha256=VyJWkgPNzAYKRDMeR1M4kE6qqQURnwqtrrEn0TRJf0g,9698
57
+ openai_sdk_helpers/structure/base.py,sha256=nYViUME9pvzMRFIvNORTgwNFcjJdCjd4R1mLMo0nMSM,24822
58
+ openai_sdk_helpers/structure/extraction.py,sha256=wODP0iLAhhsdQkMWRYPYTiLUMU8bFMKiBjPl3PKUleg,37335
59
+ openai_sdk_helpers/structure/prompt.py,sha256=ZfsaHdA0hj5zmZDrOdpXjCsC8U-jjzwFG4JBsWYiaH4,1535
60
+ openai_sdk_helpers/structure/responses.py,sha256=WUwh0DhXj24pkvgqH1FMkdx5V2ArdvdtrDN_fuMBtDU,4882
61
+ openai_sdk_helpers/structure/summary.py,sha256=iP1uffqve18B9HXceP4rV0Ho5AaDZXMmC66tRKDNx3c,3143
62
+ openai_sdk_helpers/structure/translation.py,sha256=rBSzGBX6hGaETD43340z9MbKGsxWekjRD4xEZz67SnI,712
63
+ openai_sdk_helpers/structure/validation.py,sha256=D03rlyBDn22qNjTGaGsjhsk3g50oPmzYMFqycYF2_CU,2409
64
+ openai_sdk_helpers/structure/vector_search.py,sha256=XNQsG6_-c7X6TpXjqWOdKCmqXatX1gwd0zq-hII3cz4,5782
65
+ openai_sdk_helpers/structure/web_search.py,sha256=cPqjwip0xS3OHf7yQ3B_t4VJSlviqgqzPpOkT8_qLvY,4330
66
+ openai_sdk_helpers/structure/plan/__init__.py,sha256=IGr0Tk4inN_8o7fT2N02_FTi6U6l2T9_npcQHAlBwKA,1076
67
+ openai_sdk_helpers/structure/plan/enum.py,sha256=seESSwH-IeeW-9BqIMUQyk3qjtchfU3TDhF9HPDB1OM,3079
68
+ openai_sdk_helpers/structure/plan/helpers.py,sha256=Vc6dBTMFrNWlsaCTpEImEIKjfFq4BSSxNjB4K8dywOQ,5139
69
+ openai_sdk_helpers/structure/plan/plan.py,sha256=yRBx0Z7tog4sGyq7s1kJHvqQOzLpKT8JJ9Ur5j-lhtk,9130
70
+ openai_sdk_helpers/structure/plan/task.py,sha256=DAfgJIa3Yq2AMEzaX20o8SdOs2AlM28pPE9GfbmXk3o,3547
71
+ openai_sdk_helpers/structure/plan/types.py,sha256=7y9QEVdZreQUXV7n-R4RoNZzw5HeOVbJGWx9QkSfuNY,418
72
+ openai_sdk_helpers/utils/__init__.py,sha256=TO8VoKlxCNnrdsLT9iMA5hFwF2mT5SEoTsJzYnLdDKs,3669
73
+ openai_sdk_helpers/utils/async_utils.py,sha256=9KbPEVfi6IXdbwkTUE0h5DleK8TI7I6P_VPL8UgUv98,3689
74
+ openai_sdk_helpers/utils/coercion.py,sha256=Pq1u7tAbD7kTZ84lK-7Fb9CyYKKKQt4fypG5BlSI6oQ,3774
75
+ openai_sdk_helpers/utils/encoding.py,sha256=oDtlNGZ5p-edXiHW76REs-0-8NXkQNReKJdj6sHLkt8,4615
76
+ openai_sdk_helpers/utils/instructions.py,sha256=trbjxjxv2otQR9VmBsPFk1_CJj8nA85Sgtj_5QmQOKI,942
77
+ openai_sdk_helpers/utils/langextract.py,sha256=wkEGbNHDiSX5WVURwCZZZDi23EpHsnO4JR_jJht99C0,5245
78
+ openai_sdk_helpers/utils/output_validation.py,sha256=3DC6Hr6vAFx_bQGaLsxkGN_LuKe_MugLpVogMBgG9tc,12621
79
+ openai_sdk_helpers/utils/path_utils.py,sha256=NOSX7553cc8LqxbnvmdYjgDBi5Le2W2LuMINwFsTzyM,1969
80
+ openai_sdk_helpers/utils/registry.py,sha256=FJvQEZ19vmgfhd1QR5JHb-jIite5fB-bSEOMTGkY7iQ,6680
81
+ openai_sdk_helpers/utils/validation.py,sha256=ZjnZNOy5AoFlszRxarNol6YZwfgw6LnwPtkCekZmwAU,7826
82
+ openai_sdk_helpers/utils/json/__init__.py,sha256=wBm1DBgfy_n1uSUcnCPyqBn_cCq41mijjPigSMZJZqg,2118
83
+ openai_sdk_helpers/utils/json/base_model.py,sha256=DXxKT3CuTNrzUDc9zq7c32EQ18WLyifXG33XOWZxiBk,14122
84
+ openai_sdk_helpers/utils/json/data_class.py,sha256=Bobc5yCZPMh093-0fiWaYNcEH7gUXUV2Itd-tPXH15w,6476
85
+ openai_sdk_helpers/utils/json/ref.py,sha256=FqBIRWIw33Up3rFyTlLYljcuUjg43f6Nu5wX3tOXn54,2809
86
+ openai_sdk_helpers/utils/json/utils.py,sha256=iyc25tnObqXQJWPKLZMVts932GArdKer59KuC8aQKsY,5948
87
+ openai_sdk_helpers/vector_storage/__init__.py,sha256=L5LxO09puh9_yBB9IDTvc1CvVkARVkHqYY1KX3inB4c,975
88
+ openai_sdk_helpers/vector_storage/cleanup.py,sha256=sZ4ZSTlnjF52o9Cc8A9dTX37ZYXXDxS_fdIpoOBWvrg,3666
89
+ openai_sdk_helpers/vector_storage/storage.py,sha256=t_ukacaXRa9EXE4-3BxsrB4Rjhu6nTu7NA9IjCJBIpQ,24259
90
+ openai_sdk_helpers/vector_storage/types.py,sha256=jTCcOYMeOpZWvcse0z4T3MVs-RBOPC-fqWTBeQrgafU,1639
91
+ openai_sdk_helpers-0.5.1.dist-info/METADATA,sha256=mOcLvFFUKvKuK-wOiK2A-fZcGe2y-oJdUBVEY9RkXcw,24185
92
+ openai_sdk_helpers-0.5.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
93
+ openai_sdk_helpers-0.5.1.dist-info/entry_points.txt,sha256=gEOD1ZeXe8d2OP-KzUlG-b_9D9yUZTCt-GFW3EDbIIY,63
94
+ openai_sdk_helpers-0.5.1.dist-info/licenses/LICENSE,sha256=CUhc1NrE50bs45tcXF7OcTQBKEvkUuLqeOHgrWQ5jaA,1067
95
+ openai_sdk_helpers-0.5.1.dist-info/RECORD,,
@@ -1,75 +0,0 @@
1
- """Developer configuration for the example Streamlit chat app."""
2
-
3
- import json
4
- from openai_sdk_helpers.agent.search.web import WebAgentSearch
5
- from openai_sdk_helpers.settings import OpenAISettings
6
- from openai_sdk_helpers.response.base import ResponseBase
7
- from openai_sdk_helpers.structure.web_search import WebSearchStructure
8
- from openai_sdk_helpers.structure.prompt import PromptStructure
9
- from openai_sdk_helpers.tools import ToolSpec, build_tool_definitions
10
- from openai_sdk_helpers.utils import coerce_jsonable, customJSONEncoder
11
- from openai_sdk_helpers.environment import DEFAULT_MODEL
12
-
13
-
14
- class StreamlitWebSearch(ResponseBase[WebSearchStructure]):
15
- """Response tuned for a generic chat experience with structured output.
16
-
17
- Methods
18
- -------
19
- __init__()
20
- Configure a general-purpose response session using OpenAI settings.
21
- """
22
-
23
- def __init__(self) -> None:
24
- settings = OpenAISettings.from_env()
25
- if not settings.default_model:
26
- settings = settings.model_copy(update={"default_model": DEFAULT_MODEL})
27
- super().__init__(
28
- name="streamlit_web_search",
29
- instructions="Perform web searches and generate reports.",
30
- tools=build_tool_definitions(
31
- [
32
- ToolSpec(
33
- structure=PromptStructure,
34
- tool_name="perform_search",
35
- tool_description="Tool to perform web searches and generate reports.",
36
- output_structure=WebSearchStructure,
37
- )
38
- ]
39
- ),
40
- output_structure=WebSearchStructure,
41
- tool_handlers={"perform_search": perform_search},
42
- openai_settings=settings,
43
- )
44
-
45
-
46
- async def perform_search(tool) -> str:
47
- """Perform a web search and return structured results."""
48
- structured_data = PromptStructure.from_tool_arguments(tool.arguments)
49
- web_result = await WebAgentSearch(default_model=DEFAULT_MODEL).run_agent_async(
50
- structured_data.prompt
51
- )
52
- payload = coerce_jsonable(web_result)
53
- return json.dumps(payload, cls=customJSONEncoder)
54
-
55
-
56
- APP_CONFIG = {
57
- "response": StreamlitWebSearch,
58
- "display_title": "Web Search Assistant",
59
- "description": "configuration-driven chat experience for performing web searches.",
60
- }
61
-
62
- if __name__ == "__main__":
63
- web_search_instance = StreamlitWebSearch()
64
- import asyncio
65
-
66
- result = asyncio.run(
67
- web_search_instance.run_async("What are the 2026 advancements in AI?")
68
- )
69
- if result:
70
- print(web_search_instance.get_last_tool_message())
71
- else:
72
- print("No result returned.")
73
- filepath = f"./data/{web_search_instance.name}.{web_search_instance.uuid}.json"
74
- web_search_instance.save(filepath)
75
- web_search_instance.close()
@@ -1,86 +0,0 @@
1
- openai_sdk_helpers/__init__.py,sha256=X3447C4KKq-SlGTiKsKdgwH0zXffqo-7vwrgjtz1Vdo,4034
2
- openai_sdk_helpers/cli.py,sha256=BDc08NqWVfL4GBekxMfN5IPPB4pmN1Od9sVpKtIJRZk,8025
3
- openai_sdk_helpers/environment.py,sha256=mNoswzIdv37tTRhFwA2B6_Onxsm7vhfjPArfwhYuL7g,1825
4
- openai_sdk_helpers/errors.py,sha256=0TLrcpRXPBvk2KlrU5I1VAQl-sYy-d15h_SMDkEawvI,2757
5
- openai_sdk_helpers/files_api.py,sha256=uMKHvGg1Od0J95Izl3AG9ofQYq8EDJXEty7zP0oKjJM,12569
6
- openai_sdk_helpers/logging.py,sha256=JcR0FTWht1tYdwD-bXH835pr0JV0RwHfY3poruiZGHM,795
7
- openai_sdk_helpers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- openai_sdk_helpers/settings.py,sha256=xK_u0YNKgtPrLrZrVr4F4k0CvSuYbsmkqqw9mCMdyF8,10932
9
- openai_sdk_helpers/tools.py,sha256=Awj5htt1ImBbNToM1u6qdrIZ-7MiPZAXZ_oKKiWivy8,10547
10
- openai_sdk_helpers/types.py,sha256=ejCG0rYqJhjOQvKLoNnzq-TzcKCFt69GVfi7y805NkU,1451
11
- openai_sdk_helpers/agent/__init__.py,sha256=RilrkE6Qz1oV7FMedRDSbpH7p7D4cXYa7tJD6BAJrwE,1074
12
- openai_sdk_helpers/agent/base.py,sha256=84mleMjJUDwi6wImHhzpL2Tl6PCtK1bE5n-tvcmWVQ0,27333
13
- openai_sdk_helpers/agent/configuration.py,sha256=t2ZpWdpTcBRc_4UJFnEMyjxEmQuX_BffU1DHv1Z-SpY,14702
14
- openai_sdk_helpers/agent/coordinator.py,sha256=Hb0o-pdoLJoM1MPOzBYY8KJkMxR3zWqV-GlpsCs9lqs,18052
15
- openai_sdk_helpers/agent/runner.py,sha256=aOVN1OYKK5_u7oFBqRCOOeTgcb-lLl4kZGxuPLmJrMw,4884
16
- openai_sdk_helpers/agent/summarizer.py,sha256=w_E1-7b1nQwMDAJK_TFLNoUmxjoXNEYfaFINgxbCw-w,4221
17
- openai_sdk_helpers/agent/translator.py,sha256=MTqRukv1RL8K8fnqfk1xhc_SgRCDo-pWAVfbdAMw8DA,6341
18
- openai_sdk_helpers/agent/utils.py,sha256=DTD5foCqGYfXf13F2bZMYIQROl7SbDSy5GDPGi0Zl-0,1089
19
- openai_sdk_helpers/agent/validator.py,sha256=zWtmjdg4AGV8d6PNlUpuzH-KrofJAsOMazK5BxPeOMY,5147
20
- openai_sdk_helpers/agent/search/__init__.py,sha256=LXXzEcX2MU7_htHRdRCGPw0hsr9CrZn0ESii7GZJMBw,806
21
- openai_sdk_helpers/agent/search/base.py,sha256=0LYbFdammTHzBbhhM1Vc4pFFRCQXvs65T2mDQ_lprjY,10279
22
- openai_sdk_helpers/agent/search/vector.py,sha256=zs0pE2l8bVnsn7yrg04IXd0y9xHmtnLLkKOjt47njqU,15994
23
- openai_sdk_helpers/agent/search/web.py,sha256=RzI30rUTn50k323VyG4fZ0se91qGM5TvJ2hRtvFpPIk,11234
24
- openai_sdk_helpers/enums/__init__.py,sha256=aFf79C4JBeLC3kMlJfSpehyjx5uNCtW6eK5rD6ZFfhM,322
25
- openai_sdk_helpers/enums/base.py,sha256=cNllDtzcgI0_eZYXxFko14yhxwicX6xbeDfz9gFE3qo,2753
26
- openai_sdk_helpers/prompt/__init__.py,sha256=MOqgKwG9KLqKudoKRlUfLxiSmdOi2aD6hNrWDFqLHkk,418
27
- openai_sdk_helpers/prompt/base.py,sha256=6X0zeopEvO0ba8207O8Nnj1QvFZEZier7kNNh4qkcmE,7782
28
- openai_sdk_helpers/prompt/summarizer.jinja,sha256=jliSetWDISbql1EkWi1RB8-L_BXUg8JMkRRsPRHuzbY,309
29
- openai_sdk_helpers/prompt/translator.jinja,sha256=SZhW8ipEzM-9IA4wyS_r2wIMTAclWrilmk1s46njoL0,291
30
- openai_sdk_helpers/prompt/validator.jinja,sha256=6t8q_IdxFd3mVBGX6SFKNOert1Wo3YpTOji2SNEbbtE,547
31
- openai_sdk_helpers/prompt/vector_planner.jinja,sha256=szzuJu6ZawYWuARgQn4DykBLigHfCd0lKYM-GRgoR30,282
32
- openai_sdk_helpers/prompt/vector_search.jinja,sha256=KPEYQDRKsUesadSyQcBBiqYQEDL1NLN6BQsqw-GcKMA,249
33
- openai_sdk_helpers/prompt/vector_writer.jinja,sha256=q5osfexGvt1xn8ZPtBWUP36n_1HK_Ziu8dkmCZDVamc,342
34
- openai_sdk_helpers/response/__init__.py,sha256=Kizjl1wVQpPP6JN9_TOW7Auvidkfj1g5lNNGQDv438k,1893
35
- openai_sdk_helpers/response/base.py,sha256=bhohz1lFskMohud43xIHkkq8Bqr4jODv_a_DkdOxTA0,34867
36
- openai_sdk_helpers/response/configuration.py,sha256=G3gSxDYZI9XfqDUJRO-w9JfXAK39ZbbjTCdJuLAXSxI,9339
37
- openai_sdk_helpers/response/files.py,sha256=6iHXeNZg4R08ilQ7D53qIJDQGYPpTLcByAhNJlEwbZ4,13226
38
- openai_sdk_helpers/response/messages.py,sha256=qX3sW79rLuJEys28zyv5MovZikwGOaLevzdVN0VYMRE,10104
39
- openai_sdk_helpers/response/planner.py,sha256=AuNMZkd4TGnvybSJaf2iMbvfPINbusrWucWBk2uQN_g,340
40
- openai_sdk_helpers/response/prompter.py,sha256=TLRLmNwPcxaaB_X76BbvwXlphducPKYVbn-afTqN2Rk,344
41
- openai_sdk_helpers/response/runner.py,sha256=Rg8XmxU5UwxJc3MjPlYlXWDimxy_cjxzefGiruNZK6s,4269
42
- openai_sdk_helpers/response/tool_call.py,sha256=c9Filh4IG5H_RWuJlYl6KUZDaF7mCjkabFRQMNiz7zM,7422
43
- openai_sdk_helpers/response/vector_store.py,sha256=cG5Mzdhjw5FsX1phgclIGz2MQ8f8uMKBaage1O2EZQU,3074
44
- openai_sdk_helpers/streamlit_app/__init__.py,sha256=3yAkl6qV71cqtT5YFZuC9Bkqit0NtffDV6jmMWpT1k4,812
45
- openai_sdk_helpers/streamlit_app/app.py,sha256=D5MtvvDoksE-uIQ4ci52zJnXXVNbX75nIOtZHZpzmWg,17505
46
- openai_sdk_helpers/streamlit_app/configuration.py,sha256=0KeJ4HqCNFthBHsedV6ptqHluAcTPBb5_TujFOGkIUU,16685
47
- openai_sdk_helpers/streamlit_app/streamlit_web_search.py,sha256=SNyToeeUzxriQKl9sGlDcHzejQiluvnR_PQnlww5NQc,2817
48
- openai_sdk_helpers/structure/__init__.py,sha256=jROw0IbXYVRD2Eb3dBMsB6amQZrX8X7XSgGh_zjsZWc,3469
49
- openai_sdk_helpers/structure/agent_blueprint.py,sha256=VyJWkgPNzAYKRDMeR1M4kE6qqQURnwqtrrEn0TRJf0g,9698
50
- openai_sdk_helpers/structure/base.py,sha256=7JuHxKkLR5gP0RWGQIjOQlvySfain6LrB4-zHb0oFxo,25298
51
- openai_sdk_helpers/structure/prompt.py,sha256=Pp3j-fOG0SWQO5Ts9zS86n8cveSB6kWzSGHW6J9MlcY,1075
52
- openai_sdk_helpers/structure/responses.py,sha256=eqCcW4d8lwhUF5kzHMA4FR9uNkaBHl8CuZk7a8YrenI,4868
53
- openai_sdk_helpers/structure/summary.py,sha256=iP1uffqve18B9HXceP4rV0Ho5AaDZXMmC66tRKDNx3c,3143
54
- openai_sdk_helpers/structure/translation.py,sha256=rBSzGBX6hGaETD43340z9MbKGsxWekjRD4xEZz67SnI,712
55
- openai_sdk_helpers/structure/validation.py,sha256=D03rlyBDn22qNjTGaGsjhsk3g50oPmzYMFqycYF2_CU,2409
56
- openai_sdk_helpers/structure/vector_search.py,sha256=XNQsG6_-c7X6TpXjqWOdKCmqXatX1gwd0zq-hII3cz4,5782
57
- openai_sdk_helpers/structure/web_search.py,sha256=8ETWc2G1eO3dWkNQrs5rsxvHHyhyG1puEYUVRNCLUYI,4572
58
- openai_sdk_helpers/structure/plan/__init__.py,sha256=IGr0Tk4inN_8o7fT2N02_FTi6U6l2T9_npcQHAlBwKA,1076
59
- openai_sdk_helpers/structure/plan/enum.py,sha256=seESSwH-IeeW-9BqIMUQyk3qjtchfU3TDhF9HPDB1OM,3079
60
- openai_sdk_helpers/structure/plan/helpers.py,sha256=Vc6dBTMFrNWlsaCTpEImEIKjfFq4BSSxNjB4K8dywOQ,5139
61
- openai_sdk_helpers/structure/plan/plan.py,sha256=CStfSfCdcv7HfLWV_G09xElJvq_kAKi_6JDkB3I7cSI,9663
62
- openai_sdk_helpers/structure/plan/task.py,sha256=FSdt2OJ_arC60zMoWIUHMT3U1syWM_7svyTpOIwiRSM,4580
63
- openai_sdk_helpers/structure/plan/types.py,sha256=7y9QEVdZreQUXV7n-R4RoNZzw5HeOVbJGWx9QkSfuNY,418
64
- openai_sdk_helpers/utils/__init__.py,sha256=BVfxiZX-wLiPDUQiWCUHORqzR73bhni8StuummuaN7M,3508
65
- openai_sdk_helpers/utils/async_utils.py,sha256=9KbPEVfi6IXdbwkTUE0h5DleK8TI7I6P_VPL8UgUv98,3689
66
- openai_sdk_helpers/utils/coercion.py,sha256=Pq1u7tAbD7kTZ84lK-7Fb9CyYKKKQt4fypG5BlSI6oQ,3774
67
- openai_sdk_helpers/utils/encoding.py,sha256=oDtlNGZ5p-edXiHW76REs-0-8NXkQNReKJdj6sHLkt8,4615
68
- openai_sdk_helpers/utils/instructions.py,sha256=trbjxjxv2otQR9VmBsPFk1_CJj8nA85Sgtj_5QmQOKI,942
69
- openai_sdk_helpers/utils/output_validation.py,sha256=3DC6Hr6vAFx_bQGaLsxkGN_LuKe_MugLpVogMBgG9tc,12621
70
- openai_sdk_helpers/utils/path_utils.py,sha256=NOSX7553cc8LqxbnvmdYjgDBi5Le2W2LuMINwFsTzyM,1969
71
- openai_sdk_helpers/utils/registry.py,sha256=FJvQEZ19vmgfhd1QR5JHb-jIite5fB-bSEOMTGkY7iQ,6680
72
- openai_sdk_helpers/utils/validation.py,sha256=ZjnZNOy5AoFlszRxarNol6YZwfgw6LnwPtkCekZmwAU,7826
73
- openai_sdk_helpers/utils/json/__init__.py,sha256=wBm1DBgfy_n1uSUcnCPyqBn_cCq41mijjPigSMZJZqg,2118
74
- openai_sdk_helpers/utils/json/base_model.py,sha256=6sFZWEzqbKmsAf5ZR-RnX820iBWxmYBotYN2GGROwDc,5107
75
- openai_sdk_helpers/utils/json/data_class.py,sha256=Bobc5yCZPMh093-0fiWaYNcEH7gUXUV2Itd-tPXH15w,6476
76
- openai_sdk_helpers/utils/json/ref.py,sha256=FqBIRWIw33Up3rFyTlLYljcuUjg43f6Nu5wX3tOXn54,2809
77
- openai_sdk_helpers/utils/json/utils.py,sha256=iyc25tnObqXQJWPKLZMVts932GArdKer59KuC8aQKsY,5948
78
- openai_sdk_helpers/vector_storage/__init__.py,sha256=L5LxO09puh9_yBB9IDTvc1CvVkARVkHqYY1KX3inB4c,975
79
- openai_sdk_helpers/vector_storage/cleanup.py,sha256=ImWIE-9lli-odD8qIARvmeaa0y8ZD4pYYP-kT0O3178,3552
80
- openai_sdk_helpers/vector_storage/storage.py,sha256=CcpATTNdeppmMfbQLnhv29hdEfE3wtAVsyKHNCrL-cI,23657
81
- openai_sdk_helpers/vector_storage/types.py,sha256=jTCcOYMeOpZWvcse0z4T3MVs-RBOPC-fqWTBeQrgafU,1639
82
- openai_sdk_helpers-0.4.3.dist-info/METADATA,sha256=q5i3RZC6CLUeT2vSy8FSpKjwyAqV8Nfy1MP7zyS-ibs,23638
83
- openai_sdk_helpers-0.4.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
84
- openai_sdk_helpers-0.4.3.dist-info/entry_points.txt,sha256=gEOD1ZeXe8d2OP-KzUlG-b_9D9yUZTCt-GFW3EDbIIY,63
85
- openai_sdk_helpers-0.4.3.dist-info/licenses/LICENSE,sha256=CUhc1NrE50bs45tcXF7OcTQBKEvkUuLqeOHgrWQ5jaA,1067
86
- openai_sdk_helpers-0.4.3.dist-info/RECORD,,