From e1aa8b5ae0719e4d9931476f2c3c096744921494 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Thu, 25 Apr 2024 19:24:51 +0530 Subject: [PATCH 01/12] add openai batch example Signed-off-by: Samhita Alla --- docs/index.md | 1 + docs/integrations.md | 2 + examples/openai_batch_agent/Dockerfile | 23 +++++ examples/openai_batch_agent/README.md | 47 ++++++++++ .../openai_batch_agent/__init__.py | 52 +++++++++++ .../openai_batch_agent/data.jsonl | 52 +++++++++++ .../openai_batch_agent_example_usage.py | 86 +++++++++++++++++++ examples/openai_batch_agent/requirements.in | 1 + 8 files changed, 264 insertions(+) create mode 100644 examples/openai_batch_agent/Dockerfile create mode 100644 examples/openai_batch_agent/README.md create mode 100644 examples/openai_batch_agent/openai_batch_agent/__init__.py create mode 100644 examples/openai_batch_agent/openai_batch_agent/data.jsonl create mode 100644 examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py create mode 100644 examples/openai_batch_agent/requirements.in diff --git a/docs/index.md b/docs/index.md index 01dd8eb35..9e3cfeb60 100644 --- a/docs/index.md +++ b/docs/index.md @@ -120,6 +120,7 @@ auto_examples/mmcloud_agent/index auto_examples/modin_plugin/index auto_examples/kfmpi_plugin/index auto_examples/onnx_plugin/index +auto_examples/openai_batch_agent/index auto_examples/papermill_plugin/index auto_examples/pandera_plugin/index auto_examples/kfpytorch_plugin/index diff --git a/docs/integrations.md b/docs/integrations.md index 688b85042..5336c997f 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -100,6 +100,8 @@ orchestrated by Flyte itself, within its provisioned Kubernetes clusters. - Run Databricks jobs in your workflows with the Databricks agent. * - {doc}`Memory Machine Cloud ` - Execute tasks using the MemVerge Memory Machine Cloud agent. +* - {doc}`OpenAI Batch ` + - Submit requests for asynchronous batch processing on OpenAI. * - {doc}`SageMaker Inference ` - Deploy models and create, as well as trigger inference endpoints on SageMaker. * - {doc}`Sensor ` diff --git a/examples/openai_batch_agent/Dockerfile b/examples/openai_batch_agent/Dockerfile new file mode 100644 index 000000000..0c46be23a --- /dev/null +++ b/examples/openai_batch_agent/Dockerfile @@ -0,0 +1,23 @@ +# ###################### +# NOTE: For CI/CD only # +######################## +FROM python:3.11-slim-buster +LABEL org.opencontainers.image.source=https://github.com/flyteorg/flytesnacks + +WORKDIR /root +ENV VENV /opt/venv +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 +ENV PYTHONPATH /root + +# Install Python dependencies +COPY requirements.in /root +RUN pip install -r /root/requirements.in + +# Copy the actual code +COPY . /root/ + +# This tag is supplied by the build script and will be used to determine the version +# when registering tasks, workflows, and launch plans +ARG tag +ENV FLYTE_INTERNAL_IMAGE $tag diff --git a/examples/openai_batch_agent/README.md b/examples/openai_batch_agent/README.md new file mode 100644 index 000000000..93d6a344e --- /dev/null +++ b/examples/openai_batch_agent/README.md @@ -0,0 +1,47 @@ +(openai_batch_agent)= + +# OpenAI Batch Agent + +```{eval-rst} +.. tags:: Integration, Intermediate, OpenAI +``` +The Batch API agent allows you to submit requests for asynchronous batch processing on OpenAI. +You can provide either a JSONL file or a JSON iterator, and the agent handles the upload to OpenAI, +creation of the batch, and downloading of the output and error files. + +## Installation + +To use the OpenAI Batch agent, run the following command: + +``` +pip install flytekitplugins-openai +``` + +## Example usage + +For a usage example, see {doc}`OpenAI Batch agent example usage `. + +## Local testing + +To test an agent locally, create a class for the agent task that inherits from +[SyncAgentExecutorMixin](https://github.com/flyteorg/flytekit/blob/master/flytekit/extend/backend/base_agent.py#L222-L256) +or [AsyncAgentExecutorMixin](https://github.com/flyteorg/flytekit/blob/master/flytekit/extend/backend/base_agent.py#L259-L354). +These mixins can handle synchronous and synchronous tasks, respectively, +and allow flytekit to mimic FlytePropeller's behavior in calling the agent. +For more information, see "[Testing agents locally](https://docs.flyte.org/en/latest/flyte_agents/testing_agents_locally.html)". + +## Flyte deployment configuration + +```{note} +If you are using a managed deployment of Flyte, you will need to contact your deployment administrator to configure agents in your deployment. +``` + +To enable the OpenAI Batch agent in your Flyte deployment, refer to the +{ref}`OpenAI Batch agent setup guide `. + +```{toctree} +:maxdepth: -1 +:hidden: + +openai_batch_agent_example_usage +``` diff --git a/examples/openai_batch_agent/openai_batch_agent/__init__.py b/examples/openai_batch_agent/openai_batch_agent/__init__.py new file mode 100644 index 000000000..3ad5f19ff --- /dev/null +++ b/examples/openai_batch_agent/openai_batch_agent/__init__.py @@ -0,0 +1,52 @@ +from typing import Iterator + +from flytekit import workflow +from flytekit.types.file import FlyteFile, JSONLFile +from flytekit.types.iterator import JSON +from flytekitplugins.openai import create_batch + + +def jsons(): + for x in [ + { + "custom_id": "request-1", + "method": "POST", + "url": "/v1/chat/completions", + "body": { + "model": "gpt-3.5-turbo", + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "What is 2+2?"}, + ], + }, + }, + { + "custom_id": "request-2", + "method": "POST", + "url": "/v1/chat/completions", + "body": { + "model": "gpt-3.5-turbo", + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Who won the world series in 2020?"}, + ], + }, + }, + ]: + yield x + + +batch = create_batch( + name="gpt-3.5-turbo", + openai_organization="your-org", +) + + +@workflow +def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> dict[str, FlyteFile]: + return batch(jsonl_in=json_vals) + + +@workflow +def jsonl_wf() -> dict[str, FlyteFile]: + return batch(jsonl_in=JSONLFile("data.jsonl")) \ No newline at end of file diff --git a/examples/openai_batch_agent/openai_batch_agent/data.jsonl b/examples/openai_batch_agent/openai_batch_agent/data.jsonl new file mode 100644 index 000000000..e54e82d10 --- /dev/null +++ b/examples/openai_batch_agent/openai_batch_agent/data.jsonl @@ -0,0 +1,52 @@ +{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is 2+2?"}]}} +{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you explain the concept of recursion in programming?"}]}} +{"custom_id": "request-3", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Write a brief summary of the novel 'To Kill a Mockingbird' by Harper Lee."}]}} +{"custom_id": "request-4", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you provide some tips for effective time management?"}]}} +{"custom_id": "request-5", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I improve my public speaking skills?"}]}} +{"custom_id": "request-6", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are some healthy ways to cope with stress?"}]}} +{"custom_id": "request-7", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you explain the difference between SQL and NoSQL databases?"}]}} +{"custom_id": "request-8", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "How can I start learning to code?"}]}} +{"custom_id": "request-9", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What are some effective study techniques for exam preparation?"}]}} +{"custom_id": "request-10", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm looking to start a book club and want suggestions for some classic novels we could read and discuss. What books would you recommend for a diverse group?"}]}} +{"custom_id": "request-11", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm trying to revamp my resume to make it stand out more. Beyond the usual content, what formatting or design tips would you suggest to make it really pop?"}]}} +{"custom_id": "request-12", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I keep hearing about machine learning and deep learning, but I'm not totally clear on the difference between the two. Can you explain it in simple terms?"}]}} +{"custom_id": "request-13", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What methods have you found most effective for learning a new language? I'm looking to pick up Spanish and want to use a good strategy from the start."}]}} +{"custom_id": "request-14", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me a high-level overview of ancient Roman history - the major events, influential figures, cultural achievements and eventual downfall of the empire."}]}} +{"custom_id": "request-15", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "As a working professional, I often struggle to balance my job with life outside of work. What are your top tips for achieving a healthier work-life balance?"}]}} +{"custom_id": "request-16", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I keep hearing about blockchain, but I'm a little hazy on what it actually is and how it works. Can you break it down for me in simple terms?"}]}} +{"custom_id": "request-17", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I want to get better at managing my money - budgeting, saving, investing wisely. What are some of the most important personal finance habits I should focus on?"}]}} +{"custom_id": "request-18", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Walk me through the major milestones and turning points of World War II, from the initial invasions to the eventual Allied victory."}]}} +{"custom_id": "request-19", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I've been put in charge of a big project at work and want to make sure I execute it successfully. What project management strategies would you recommend?"}]}} +{"custom_id": "request-20", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain to me the process of photosynthesis in plants - how they convert light energy, carbon dioxide and water into oxygen and glucose."}]}} +{"custom_id": "request-21", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I've been really stressed and anxious lately. Beyond just trying to relax, what are some healthy coping techniques you'd suggest to manage those feelings better?"}]}} +{"custom_id": "request-22", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm looking to learn more about the fundamentals of economics. Could you give me an overview of some of the core economic principles and concepts?"}]}} +{"custom_id": "request-23", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm trying to expand my professional network. What tips do you have for effective networking and building lasting connections?"}]}} +{"custom_id": "request-24", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What exactly is the difference between prose and poetry as literary forms? How do they differ in structure, style and purpose?"}]}} +{"custom_id": "request-25", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm looking to pick up a new hobby or learn a new skill. What process would you recommend for effectively learning something new in your free time?"}]}} +{"custom_id": "request-26", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me an overview of the American Civil Rights Movement, including the major events, key leaders and the significance of the movement."}]}} +{"custom_id": "request-27", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In a professional environment, email is crucial for communication. What are your top tips for writing effective emails that get the message across clearly?"}]}} +{"custom_id": "request-28", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "As a software developer, I've heard the term 'iterative development' quite a bit. But I'm still a little fuzzy on exactly what it means - can you explain the concept?"}]}} +{"custom_id": "request-29", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I manage a remote team that is spread across different locations. What are your top strategies for effectively leading and keeping a virtual workforce motivated and collaborative?"}]}} +{"custom_id": "request-30", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'd like a broad overview of the key events and major players involved in the French Revolution - what led to it, the different factions, how it unfolded, etc."}]}} +{"custom_id": "request-31", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Whether it's business deals or personal disagreements, conflict resolution is an important skill. What techniques do you recommend for effectively negotiating and resolving conflicts?"}]}} +{"custom_id": "request-32", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm trying to level up my programming skills by learning object-oriented concepts. Can you explain to me what object-oriented programming is and its core principles?"}]}} +{"custom_id": "request-33", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Stress management and work-life balance are struggles for me. What are your most effective tips for reducing stress levels and finding more equilibrium?"}]}} +{"custom_id": "request-34", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'd like a high-level overview of the Renaissance period - the catalysts that sparked it, major developments and achievements, as well as key figures of the era."}]}} +{"custom_id": "request-35", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Good project planning and execution is crucial for success. What methodologies or frameworks would you recommend for effective project management?"}]}} +{"custom_id": "request-36", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "As a programmer, I've come across functional and object-oriented paradigms. Could you explain the key differences between these two programming approaches?"}]}} +{"custom_id": "request-37", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Healthy relationships, whether romantic, family or friendships, are so important. What habits or practices would you recommend for building and maintaining positive relationships?"}]}} +{"custom_id": "request-38", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me an overview of the Industrial Revolution - what catalyzed it, major technological advancements, how it transformed societies and economies, etc."}]}} +{"custom_id": "request-39", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I often struggle with making tough decisions when faced with a difficult problem. What systematic approach would you recommend for more effective problem-solving and decision-making?"}]}} +{"custom_id": "request-40", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "In computer science, I keep hearing about data structures and algorithms as fundamentally important concepts. Can you explain what they are and why they matter?"}]}} +{"custom_id": "request-41", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'd like to get better at managing my personal finances and creating a budget. What are some effective budgeting strategies and financial habits I should focus on developing?"}]}} +{"custom_id": "request-42", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me an overview of the key events, major figures and significance of the American Revolutionary War that led to independence from Britain."}]}} +{"custom_id": "request-43", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "As a leader, what skills and practices are most important for effectively managing and motivating a team? Share your top leadership principles."}]}} +{"custom_id": "request-44", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I've been hearing a lot about cloud computing lately. Can you explain what it is and the key benefits of using cloud services and infrastructure?"}]}} +{"custom_id": "request-45", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I often feel like an imposter and doubt my abilities, even when I'm successful. How can I build more self-confidence?"}]}} +{"custom_id": "request-46", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me a brief rundown of the major events and key figures of the Scientific Revolution period."}]}} +{"custom_id": "request-47", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Communication is key in both personal and professional settings. What techniques can I use to improve my communication skills, especially active listening?"}]}} +{"custom_id": "request-48", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm learning software development and keep hearing about 'design patterns.' Could you explain what design patterns are and why they're important?"}]}} +{"custom_id": "request-49", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "They say you should embrace a 'growth mindset' and be a lifelong learner. What are some practical ways to develop that kind of mindset?"}]}} +{"custom_id": "request-50", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me the highlights of the Cold War period - the key events, major figures, and the tension between the US and Soviet Union."}]}} +{"custom_id": "request-51", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm looking for ways to generate more creative ideas, whether for projects at work or just in my personal life. What brainstorming techniques would you recommend?"}]}} +{"custom_id": "request-52", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you explain the main differences between imperative, functional and object-oriented programming paradigms?"}]}} Copy \ No newline at end of file diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py new file mode 100644 index 000000000..c15d6ce77 --- /dev/null +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -0,0 +1,86 @@ +# %% [markdown] +# (openai_batch_agent_example_usage)= +# +# # Batching Requests for Asynchronous Processing +# +# This example demonstrates how to send a batch of API requests to GPT models for asynchronous processing. +# +# Every batch input should include `custom_id`, `method`, `url`, and `body`. +# You can provide either a `JSONLFile` or `Iterator[JSON]`, and the agent handles the file upload to OpenAI, +# creation of the batch, and downloading of the output and error files. +# +# ## Using `Iterator` +# +# Here's how you can provide an `Iterator` as an input to the agent: +# %% +from typing import Iterator + +from flytekit import workflow +from flytekit.types.file import JSONLFile +from flytekit.types.iterator import JSON +from flytekitplugins.openai import BatchResult, create_batch + + +def jsons(): + for x in [ + { + "custom_id": "request-1", + "method": "POST", + "url": "/v1/chat/completions", + "body": { + "model": "gpt-3.5-turbo", + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "What is 2+2?"}, + ], + }, + }, + { + "custom_id": "request-2", + "method": "POST", + "url": "/v1/chat/completions", + "body": { + "model": "gpt-3.5-turbo", + "messages": [ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Who won the world series in 2020?"}, + ], + }, + }, + ]: + yield x + + +batch = create_batch( + name="gpt-3.5-turbo", + openai_organization="your-org", +) + + +@workflow +def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: + return batch(jsonl_in=json_vals) + +# %% [markdown] +# The `create_batch` function returns an imperative workflow responsible for uploading the JSON data to OpenAI, +# creating a batch, polling the status of the batch to check for completion, and downloading the +# output and error files. It also accepts a `config` parameter, allowing you to provide `metadata`, `endpoint`, +# and `completion_window` values. These parameters default to their respective default values. +# +# `BatchResult` is a `NamedTuple` that contains the paths to the output file and the error file. +# +# ## Using `JSONLFile` +# +# The following code snippet demonstrates how to send a JSONL file to the `create_batch` function: +# %% +@workflow +def jsonl_wf() -> BatchResult: + return batch(jsonl_in=JSONLFile("data.jsonl")) + +# %% [markdown] +# The iterator streams JSONs to reduce the memory footprint. If you have large batches of requests that are huge in size, +# you can leverage the iterator. It streams the data to a JSONL file and uploads it to OpenAI, whereas `JSONLFile` +# downloads the file in its entirety at once and uploads it to OpenAI. +# +# You can find more info about the [Batch API in the OpenAI docs](https://help.openai.com/en/articles/9197833-batch-api-faq). +# %% \ No newline at end of file diff --git a/examples/openai_batch_agent/requirements.in b/examples/openai_batch_agent/requirements.in new file mode 100644 index 000000000..e0457edf1 --- /dev/null +++ b/examples/openai_batch_agent/requirements.in @@ -0,0 +1 @@ +flytekitplugins-openai From 7457de9cf017fc063a1d2a749999f8c3cf3d662a Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Fri, 26 Apr 2024 12:27:17 +0530 Subject: [PATCH 02/12] nit Signed-off-by: Samhita Alla --- examples/openai_batch_agent/README.md | 2 +- .../openai_batch_agent/openai_batch_agent_example_usage.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/openai_batch_agent/README.md b/examples/openai_batch_agent/README.md index 93d6a344e..815805f37 100644 --- a/examples/openai_batch_agent/README.md +++ b/examples/openai_batch_agent/README.md @@ -19,7 +19,7 @@ pip install flytekitplugins-openai ## Example usage -For a usage example, see {doc}`OpenAI Batch agent example usage `. +For a usage example, see {doc}`OpenAI Batch agent example usage `. ## Local testing diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index c15d6ce77..05eebebb2 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -83,4 +83,4 @@ def jsonl_wf() -> BatchResult: # downloads the file in its entirety at once and uploads it to OpenAI. # # You can find more info about the [Batch API in the OpenAI docs](https://help.openai.com/en/articles/9197833-batch-api-faq). -# %% \ No newline at end of file +# %% From ef941a4fea33f82baff4c9fd8db987599f2cb76c Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Fri, 26 Apr 2024 12:32:51 +0530 Subject: [PATCH 03/12] nit Signed-off-by: Samhita Alla --- .../openai_batch_agent_example_usage.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index 05eebebb2..30dd1f669 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -4,7 +4,7 @@ # # Batching Requests for Asynchronous Processing # # This example demonstrates how to send a batch of API requests to GPT models for asynchronous processing. -# +# # Every batch input should include `custom_id`, `method`, `url`, and `body`. # You can provide either a `JSONLFile` or `Iterator[JSON]`, and the agent handles the file upload to OpenAI, # creation of the batch, and downloading of the output and error files. @@ -18,7 +18,7 @@ from flytekit import workflow from flytekit.types.file import JSONLFile from flytekit.types.iterator import JSON -from flytekitplugins.openai import BatchResult, create_batch +from flytekitplugins.openai import BatchResult, create_batch def jsons(): @@ -61,14 +61,15 @@ def jsons(): def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: return batch(jsonl_in=json_vals) + # %% [markdown] # The `create_batch` function returns an imperative workflow responsible for uploading the JSON data to OpenAI, -# creating a batch, polling the status of the batch to check for completion, and downloading the -# output and error files. It also accepts a `config` parameter, allowing you to provide `metadata`, `endpoint`, +# creating a batch, polling the status of the batch to check for completion, and downloading the +# output and error files. It also accepts a `config` parameter, allowing you to provide `metadata`, `endpoint`, # and `completion_window` values. These parameters default to their respective default values. # # `BatchResult` is a `NamedTuple` that contains the paths to the output file and the error file. -# +# # ## Using `JSONLFile` # # The following code snippet demonstrates how to send a JSONL file to the `create_batch` function: @@ -77,10 +78,10 @@ def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: def jsonl_wf() -> BatchResult: return batch(jsonl_in=JSONLFile("data.jsonl")) + # %% [markdown] # The iterator streams JSONs to reduce the memory footprint. If you have large batches of requests that are huge in size, -# you can leverage the iterator. It streams the data to a JSONL file and uploads it to OpenAI, whereas `JSONLFile` +# you can leverage the iterator. It streams the data to a JSONL file and uploads it to OpenAI, whereas `JSONLFile` # downloads the file in its entirety at once and uploads it to OpenAI. # # You can find more info about the [Batch API in the OpenAI docs](https://help.openai.com/en/articles/9197833-batch-api-faq). -# %% From bd5c9ae681fc1a13f9f923e6ed597720acee7c0d Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Fri, 26 Apr 2024 12:52:45 +0530 Subject: [PATCH 04/12] update jsonl file Signed-off-by: Samhita Alla --- examples/openai_batch_agent/openai_batch_agent/data.jsonl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/data.jsonl b/examples/openai_batch_agent/openai_batch_agent/data.jsonl index e54e82d10..ea729f88b 100644 --- a/examples/openai_batch_agent/openai_batch_agent/data.jsonl +++ b/examples/openai_batch_agent/openai_batch_agent/data.jsonl @@ -49,4 +49,4 @@ {"custom_id": "request-49", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "They say you should embrace a 'growth mindset' and be a lifelong learner. What are some practical ways to develop that kind of mindset?"}]}} {"custom_id": "request-50", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Give me the highlights of the Cold War period - the key events, major figures, and the tension between the US and Soviet Union."}]}} {"custom_id": "request-51", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "I'm looking for ways to generate more creative ideas, whether for projects at work or just in my personal life. What brainstorming techniques would you recommend?"}]}} -{"custom_id": "request-52", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you explain the main differences between imperative, functional and object-oriented programming paradigms?"}]}} Copy \ No newline at end of file +{"custom_id": "request-52", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-3.5-turbo", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Can you explain the main differences between imperative, functional and object-oriented programming paradigms?"}]}} From a23afe53a95ed797057fca62e94659cdb92998ba Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Fri, 26 Apr 2024 12:55:52 +0530 Subject: [PATCH 05/12] update init.py Signed-off-by: Samhita Alla --- .../openai_batch_agent/__init__.py | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/__init__.py b/examples/openai_batch_agent/openai_batch_agent/__init__.py index 3ad5f19ff..e69de29bb 100644 --- a/examples/openai_batch_agent/openai_batch_agent/__init__.py +++ b/examples/openai_batch_agent/openai_batch_agent/__init__.py @@ -1,52 +0,0 @@ -from typing import Iterator - -from flytekit import workflow -from flytekit.types.file import FlyteFile, JSONLFile -from flytekit.types.iterator import JSON -from flytekitplugins.openai import create_batch - - -def jsons(): - for x in [ - { - "custom_id": "request-1", - "method": "POST", - "url": "/v1/chat/completions", - "body": { - "model": "gpt-3.5-turbo", - "messages": [ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "What is 2+2?"}, - ], - }, - }, - { - "custom_id": "request-2", - "method": "POST", - "url": "/v1/chat/completions", - "body": { - "model": "gpt-3.5-turbo", - "messages": [ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Who won the world series in 2020?"}, - ], - }, - }, - ]: - yield x - - -batch = create_batch( - name="gpt-3.5-turbo", - openai_organization="your-org", -) - - -@workflow -def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> dict[str, FlyteFile]: - return batch(jsonl_in=json_vals) - - -@workflow -def jsonl_wf() -> dict[str, FlyteFile]: - return batch(jsonl_in=JSONLFile("data.jsonl")) \ No newline at end of file From 5d2c08595c1103a218636bd51e09cde54246c9e9 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Wed, 15 May 2024 23:20:31 +0530 Subject: [PATCH 06/12] update doc Signed-off-by: Samhita Alla --- examples/openai_batch_agent/README.md | 1 + .../openai_batch_agent_example_usage.py | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/examples/openai_batch_agent/README.md b/examples/openai_batch_agent/README.md index 815805f37..e2f416846 100644 --- a/examples/openai_batch_agent/README.md +++ b/examples/openai_batch_agent/README.md @@ -5,6 +5,7 @@ ```{eval-rst} .. tags:: Integration, Intermediate, OpenAI ``` + The Batch API agent allows you to submit requests for asynchronous batch processing on OpenAI. You can provide either a JSONL file or a JSON iterator, and the agent handles the upload to OpenAI, creation of the batch, and downloading of the output and error files. diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index 30dd1f669..ed90b2ef0 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -15,7 +15,7 @@ # %% from typing import Iterator -from flytekit import workflow +from flytekit import workflow, Secret from flytekit.types.file import JSONLFile from flytekit.types.iterator import JSON from flytekitplugins.openai import BatchResult, create_batch @@ -51,15 +51,16 @@ def jsons(): yield x -batch = create_batch( +iterator_batch = create_batch( name="gpt-3.5-turbo", openai_organization="your-org", + secret=Secret(group="openai", key="api-key"), ) @workflow def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: - return batch(jsonl_in=json_vals) + return iterator_batch(json_iterator=json_vals) # %% [markdown] @@ -68,20 +69,28 @@ def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: # output and error files. It also accepts a `config` parameter, allowing you to provide `metadata`, `endpoint`, # and `completion_window` values. These parameters default to their respective default values. # -# `BatchResult` is a `NamedTuple` that contains the paths to the output file and the error file. +# `BatchResult` is a dataclass that contains the paths to the output file and the error file. # # ## Using `JSONLFile` # # The following code snippet demonstrates how to send a JSONL file to the `create_batch` function: # %% +file_batch = create_batch( + name="gpt-3.5-turbo", + openai_organization="your-org", + secret=Secret(group="openai", key="api-key"), + is_json_iterator=False, +) + + @workflow -def jsonl_wf() -> BatchResult: - return batch(jsonl_in=JSONLFile("data.jsonl")) +def jsonl_wf(jsonl_file: JSONLFile = "data.jsonl") -> BatchResult: + return file_batch(jsonl_file=jsonl_file) # %% [markdown] # The iterator streams JSONs to reduce the memory footprint. If you have large batches of requests that are huge in size, -# you can leverage the iterator. It streams the data to a JSONL file and uploads it to OpenAI, whereas `JSONLFile` +# we recommend you use the iterator. It streams the data to a JSONL file and uploads it to OpenAI, whereas `JSONLFile` # downloads the file in its entirety at once and uploads it to OpenAI. # # You can find more info about the [Batch API in the OpenAI docs](https://help.openai.com/en/articles/9197833-batch-api-faq). From 93a6f727e6729a5ee4000c783e88e6c23ed546c2 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Wed, 15 May 2024 23:23:46 +0530 Subject: [PATCH 07/12] lint Signed-off-by: Samhita Alla --- .../openai_batch_agent/openai_batch_agent_example_usage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index ed90b2ef0..51e7fc972 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -15,7 +15,7 @@ # %% from typing import Iterator -from flytekit import workflow, Secret +from flytekit import Secret, workflow from flytekit.types.file import JSONLFile from flytekit.types.iterator import JSON from flytekitplugins.openai import BatchResult, create_batch From 51885a5e651c6a47ad267b17e43f5f0c208f7f4c Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Fri, 17 May 2024 15:50:22 +0530 Subject: [PATCH 08/12] update doc Signed-off-by: Samhita Alla --- .../openai_batch_agent_example_usage.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index 51e7fc972..7cbe00f67 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -60,7 +60,7 @@ def jsons(): @workflow def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: - return iterator_batch(json_iterator=json_vals) + return iterator_batch(jsonl_in=json_vals) # %% [markdown] @@ -85,12 +85,11 @@ def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: @workflow def jsonl_wf(jsonl_file: JSONLFile = "data.jsonl") -> BatchResult: - return file_batch(jsonl_file=jsonl_file) + return file_batch(jsonl_in=jsonl_file) # %% [markdown] -# The iterator streams JSONs to reduce the memory footprint. If you have large batches of requests that are huge in size, -# we recommend you use the iterator. It streams the data to a JSONL file and uploads it to OpenAI, whereas `JSONLFile` -# downloads the file in its entirety at once and uploads it to OpenAI. -# +# The iterator **streams JSON objects to a JSONL file**. If you have large batches of requests or have distinct JSON objects that +# you want to run predictions on, we recommend you use the iterator. +# # You can find more info about the [Batch API in the OpenAI docs](https://help.openai.com/en/articles/9197833-batch-api-faq). From 32b49ba0ebdf3e1cd35770dc1f17bd6b18392c84 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Fri, 17 May 2024 16:01:44 +0530 Subject: [PATCH 09/12] lint Signed-off-by: Samhita Alla --- .../openai_batch_agent/openai_batch_agent_example_usage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index 7cbe00f67..9e16eb896 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -89,7 +89,7 @@ def jsonl_wf(jsonl_file: JSONLFile = "data.jsonl") -> BatchResult: # %% [markdown] -# The iterator **streams JSON objects to a JSONL file**. If you have large batches of requests or have distinct JSON objects that +# The iterator **streams JSON objects to a JSONL file**. If you have large batches of requests or have distinct JSON objects that # you want to run predictions on, we recommend you use the iterator. -# +# # You can find more info about the [Batch API in the OpenAI docs](https://help.openai.com/en/articles/9197833-batch-api-faq). From 4da8e6717a27ae5b485cf905dae7a66930236387 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Wed, 22 May 2024 22:02:51 +0530 Subject: [PATCH 10/12] debug Signed-off-by: Samhita Alla --- .github/workflows/monodocs_build.yml | 1 + examples/openai_batch_agent/requirements.in | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monodocs_build.yml b/.github/workflows/monodocs_build.yml index 66f4e1a4e..1a10a4f83 100644 --- a/.github/workflows/monodocs_build.yml +++ b/.github/workflows/monodocs_build.yml @@ -39,6 +39,7 @@ jobs: run: | conda activate monodocs-env pip install ./flyteidl + pip install flytekit==1.12.1b2 conda info conda list conda config --show-sources diff --git a/examples/openai_batch_agent/requirements.in b/examples/openai_batch_agent/requirements.in index e0457edf1..9657054c5 100644 --- a/examples/openai_batch_agent/requirements.in +++ b/examples/openai_batch_agent/requirements.in @@ -1 +1 @@ -flytekitplugins-openai +flytekitplugins-openai>=1.12.1b2 From 9919e17e6ba53b7c91a801aa64b19e369eec1342 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Wed, 22 May 2024 22:35:24 +0530 Subject: [PATCH 11/12] data jsonl file location Signed-off-by: Samhita Alla --- .../openai_batch_agent/openai_batch_agent_example_usage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index 9e16eb896..16b9fa0be 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -13,6 +13,7 @@ # # Here's how you can provide an `Iterator` as an input to the agent: # %% +import os from typing import Iterator from flytekit import Secret, workflow @@ -84,7 +85,7 @@ def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: @workflow -def jsonl_wf(jsonl_file: JSONLFile = "data.jsonl") -> BatchResult: +def jsonl_wf(jsonl_file: JSONLFile = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data.jsonl")) -> BatchResult: return file_batch(jsonl_in=jsonl_file) From da418961e1e54e3104dc0478bd5a9cd2e6c73a07 Mon Sep 17 00:00:00 2001 From: Samhita Alla Date: Wed, 22 May 2024 22:55:01 +0530 Subject: [PATCH 12/12] lint Signed-off-by: Samhita Alla --- .github/workflows/monodocs_build.yml | 1 - .../openai_batch_agent/openai_batch_agent_example_usage.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/monodocs_build.yml b/.github/workflows/monodocs_build.yml index 1a10a4f83..66f4e1a4e 100644 --- a/.github/workflows/monodocs_build.yml +++ b/.github/workflows/monodocs_build.yml @@ -39,7 +39,6 @@ jobs: run: | conda activate monodocs-env pip install ./flyteidl - pip install flytekit==1.12.1b2 conda info conda list conda config --show-sources diff --git a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py index 16b9fa0be..6c10b78b1 100644 --- a/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py +++ b/examples/openai_batch_agent/openai_batch_agent/openai_batch_agent_example_usage.py @@ -85,7 +85,9 @@ def json_iterator_wf(json_vals: Iterator[JSON] = jsons()) -> BatchResult: @workflow -def jsonl_wf(jsonl_file: JSONLFile = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data.jsonl")) -> BatchResult: +def jsonl_wf( + jsonl_file: JSONLFile = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data.jsonl") +) -> BatchResult: return file_batch(jsonl_in=jsonl_file)