Skip to content

ChatGPT Agent#2226

Merged
pingsutw merged 8 commits into
masterfrom
chatgpt-agent-with-sync-agent-base
Mar 2, 2024
Merged

ChatGPT Agent#2226
pingsutw merged 8 commits into
masterfrom
chatgpt-agent-with-sync-agent-base

Conversation

@Future-Outlier

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

Copy link
Copy Markdown
Member

Tracking issue

flyteorg/flyte#3936

Why are the changes needed?

We want to support chatgpt agent and provide example for users to develop sync agent.

What changes were proposed in this pull request?

  • add openai-chatgpt plugin

How was this patch tested?

Setup process

  1. Set up my local single binary environment. (use pyflyte serve agent)
  2. Build a docker image with sync agent proto and chatgpt agent's gitsha.
  3. Test the chatgpt task in both local and remote scenarios.
tasks:
  task-plugins:
    enabled-plugins:
      - container
      - sidecar
      - K8S-ARRAY
      - agent-service
      
    default-for-task-types:
      chatgpt: agent-service
      custom_task: agent-service
      container: container
      container_array: K8S-ARRAY

plugins:
  agent-service:
    supportedTaskTypes:
      - sensor
      - spark
      - default_task
      - custom_task
      - chatgpt
      - sensor
      - airflow
    defaultAgent:
      endpoint: "dns:///localhost:8000"
      insecure: true
      timeouts:
        GetTask: 100s
      defaultTimeout: 100s
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@c9972bf023d10bef3aefa9fa6763c6b35aec5693
RUN pip install -U git+https://github.com/flyteorg/flytekit.git@c9972bf023d10bef3aefa9fa6763c6b35aec5693#subdirectory=plugins/flytekit-openai
from flytekit import task, workflow
from flytekitplugins.chatgpt 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

if __name__ == "__main__":
    print(wf())

Screenshots

Local Scenario

python chatgpt_chain.py

image

Remote Scenario

pyflyte run --remote --image futureoutlier/flytekit:chatgpt-0301 chatgpt_chain.py wf --message hi

image
image
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

#1822
#2085

Docs link

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 1, 2024
@codecov

codecov Bot commented Mar 1, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 97.19626% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 85.98%. Comparing base (f66fa66) to head (5af7404).
Report is 1 commits behind head on master.

Files Patch % Lines
flytekit/extend/backend/base_agent.py 66.66% 2 Missing ⚠️
...ns/flytekit-openai/flytekitplugins/chatgpt/task.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2226      +/-   ##
==========================================
+ Coverage   83.28%   85.98%   +2.69%     
==========================================
  Files         178      320     +142     
  Lines       17689    24246    +6557     
  Branches     3666     3666              
==========================================
+ Hits        14732    20847    +6115     
- Misses       2305     2747     +442     
  Partials      652      652              

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

Comment thread plugins/flytekit-openai/setup.py Outdated
@Future-Outlier

Copy link
Copy Markdown
Member Author

local failure case
image

remote failure case
image

Comment thread plugins/flytekit-openai/flytekitplugins/chatgpt/agent.py Outdated
Comment thread plugins/flytekit-openai/flytekitplugins/chatgpt/agent.py
Comment thread plugins/flytekit-openai/setup.py
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Future-Outlier <eric901201@gmail.com>
@Future-Outlier Future-Outlier force-pushed the chatgpt-agent-with-sync-agent-base branch from 2ef167f to 86a9618 Compare March 2, 2024 00:23
Comment thread Dockerfile.agent Outdated
Signed-off-by: Future-Outlier <eric901201@gmail.com>
@pingsutw pingsutw changed the title ChatGPT Agent V3 ChatGPT Agent Mar 2, 2024
@dosubot dosubot Bot added the lgtm This PR has been approved by maintainer label Mar 2, 2024
@pingsutw pingsutw merged commit d7c6029 into master Mar 2, 2024
@Future-Outlier Future-Outlier mentioned this pull request May 9, 2024
3 tasks
fiedlerNr9 pushed a commit that referenced this pull request Jul 25, 2024
Signed-off-by: Future-Outlier <eric901201@gmail.com>
Signed-off-by: Jan Fiedler <jan@union.ai>
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants