Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flytekitplugins] Rename ChatGPT module to OpenAI module #2263

Merged
merged 2 commits into from
Mar 26, 2024

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Mar 13, 2024

Tracking issue

flyteorg/flyte#3936

Why are the changes needed?

For a better API interface.

What changes were proposed in this pull request?

How was this patch tested?

unit test.
local execution.
remote execution.

Setup process

Dockerfile

FROM python:3.9-slim-buster
USER root
WORKDIR /root
ENV PYTHONPATH /root
RUN apt-get update && apt-get install build-essential -y
RUN apt-get install git -y

RUN pip install -U git+https://github.com/flyteorg/flytekit.git@f4b102e384f1312e2fbc427c4af43375a80fd433
RUN pip install -U git+https://github.com/flyteorg/flytekit.git@f4b102e384f1312e2fbc427c4af43375a80fd433#subdirectory=plugins/flytekit-openai

chatgpt chain

from flytekit import task, workflow
from flytekitplugins.openai import ChatGPTTask

chatgpt_small_job = ChatGPTTask(
    name="chatgpt gpt-3.5-turbo",
    openai_organization="org-NayNG68kGnVXMJ8Ak4PMgQv7",
    chatgpt_config={
            "model": "gpt-3.5-turbo",
            "temperature": 0.7,
    },
)

chatgpt_big_job = ChatGPTTask(
    name="chatgpt gpt-4",
    openai_organization="org-NayNG68kGnVXMJ8Ak4PMgQv7",
    chatgpt_config={
            "model": "gpt-4",
            "temperature": 0.7,
    },
)

@workflow
def wf(message: str) -> str:
    message = chatgpt_small_job(message=message)
    message = chatgpt_big_job(message=message)
    return message

chatgpt example

from flytekit import task, workflow
from flytekitplugins.openai import ChatGPTTask

chatgpt_new_job = ChatGPTTask(
            name="chatgpt",
            openai_organization="org-NayNG68kGnVXMJ8Ak4PMgQv7",
            # openai_organization="xxx",
            chatgpt_config={
                    "model": "gpt-3.5-turbo",
                    "temperature": 0.7,
            },
        )

@workflow
def wf() -> str:
    message = chatgpt_new_job(message="Hi")
    return t1(s=message)

@task
def t1(s: str) -> str:
    s = "Repsonse: " + s
    return s

Screenshots

chatgpt chain (only propeller)

image

chatgpt example (with new built image)

image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 13, 2024
Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.35%. Comparing base (a2888cf) to head (f4b102e).
Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2263      +/-   ##
==========================================
- Coverage   83.81%   83.35%   -0.47%     
==========================================
  Files         332      309      -23     
  Lines       25093    24011    -1082     
  Branches     3690     3478     -212     
==========================================
- Hits        21032    20014    -1018     
+ Misses       3441     3376      -65     
- Partials      620      621       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Future-Outlier <[email protected]>
@Future-Outlier Future-Outlier changed the title [flytekitplugins] Refactor ChatGPT module to OpenAI module [flytekitplugins] Rename ChatGPT module to OpenAI module Mar 22, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by maintainer label Mar 26, 2024
@eapolinario
Copy link
Collaborator

Remember to update the example once this change is out.

@eapolinario eapolinario merged commit fa2aa0b into master Mar 26, 2024
46 of 47 checks passed
fiedlerNr9 pushed a commit that referenced this pull request Jul 25, 2024
* refactor chagpt module to openai module

Signed-off-by: Future-Outlier <[email protected]>

* nit

Signed-off-by: Future-Outlier <[email protected]>

---------

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Jan Fiedler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants