-
Notifications
You must be signed in to change notification settings - Fork 299
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
Chatgpt Agent #1822
Closed
Future-Outlier
wants to merge
98
commits into
flyteorg:master
from
Future-Outlier:chatgpt-agent-sync-plugin
Closed
Chatgpt Agent #1822
Changes from 86 commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
540eb5d
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
984d44a
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
3d936fc
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
931533a
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
8365c53
drafte chatgpt agent
25d6a5d
others
970bf3b
sync plugin, DoTask function interface
b5a74d8
Merge branch 'flyteorg:master' into chatgpt-agent-sync-plugin
Future-Outlier 6087c5f
requester agent base and chatgpt agent
f8680a1
Merge branch 'chatgpt-agent-sync-plugin' of https://github.com/Future…
b225310
Add do task interface
09bc23a
fix lint
bd5dbd7
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
aeb5ea1
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
0717e2c
Merge branch 'chatgpt-agent-sync-plugin' of https://github.com/Future…
54d2ddf
Merge branch 'flyteorg:master' into master
Future-Outlier 541edc6
Merge branch 'flyteorg:master' into master
Future-Outlier 7c9dcbc
upload data v1
18a9e5d
base_requester and chatgpt_requester succeed
75573ab
Merge branch 'flyteorg:master' into master
Future-Outlier 61e0a76
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
8de3fa8
chatgpt requester v2
be7d22d
output type
bca202b
dispatcher
c0139db
Merge pull request #19 from flyteorg/master
Future-Outlier cf9ff07
move to plugins directory
3b13b48
do task agent service
24df7b3
Merge branch 'flyteorg:master' into master
Future-Outlier 563ca22
Merge branch 'flyteorg:master' into master
Future-Outlier 5fa4f18
Merge branch 'flyteorg:master' into master
Future-Outlier 5f1183b
Merge branch 'flyteorg:master' into master
Future-Outlier 203d2d4
Merge branch 'flyteorg:master' into master
Future-Outlier 9366dfb
Merge branch 'flyteorg:master' into master
Future-Outlier 66f5e60
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
3249963
merge master
558c6bd
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
9f5dd0a
Merge branch 'master' of https://github.com/Future-Outlier/flytekit
c91ee4c
refactor
pingsutw 4adf029
refactor
pingsutw 402e1a9
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
2db4de7
Merge branch 'master' into chatgpt-agent-sync-plugin
420cbf5
chatgpt sync plugin succeed v1
1208268
chatgpt syncplugin succeed
a64f6ee
remove unused task metadata
815dde4
add base_task RuntimeMetadata test and push for gitsha
9f3072e
fix ExternalApiTask import
713db18
add for flyteidl version remove for building image
0ecebdf
ciruclar import
a058734
add tests and lints
719ae32
final all tests
5823cb1
move to flytekit-openai-chatgpt dir and add setup.py python 3.11 test
c6058fc
delete flytekit-chatgpt
e6482ae
databricks api bug
c6343ec
remove output_prefix
ee0b829
make lint will make logger can't be import
a9b16c8
improve excutor task
d2ebf6c
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
a660fc1
FLYTE_OPENAI_ACCESS_TOKEN
a3b0ecc
add requirements
bc9fb27
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
6de876b
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
f785a19
use openai async create function and change test
ff44060
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
8892dee
change the runtime flavor by specifying str value
1810a7b
add depedencies
8d5bb61
add timeout seconds in ChatGPT
fd8dd5d
change await place in async do task function
36b315e
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
e6b0ba0
fix circular import
dc87c81
Update flytekit/extend/backend/base_agent.py
Future-Outlier 8ea1a9d
Update tests/flytekit/unit/core/test_task_metadata.py
Future-Outlier 42b8d90
add runtime flavor variavle in all async plugin and sync plugin test
14a2698
add TaskExecutor comment
67582fd
change the argument task type used in sensor engine and api_task engi…
c273689
support more arguments in do task agent
232c80c
add annotations
f842fdd
move argument openai_organization to optional
835c48a
SyncAgentServiceServicer
d1e99be
make organization as a required arguement back
b0670d3
use is_sync_plugin varaible
6e8f30d
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
104ba6f
ruff fmt
ec35714
add todo
c463992
use plugin_metadata by default
9758ce6
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
868f81b
remove print debug
0068137
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
6d15fdc
move to rich click
b56c845
Merge branch 'master' of https://github.com/Future-Outlier/flytekit i…
510711e
change to agentServicer, agentExecutorMixin, and use is_sync attribute
9d1e5bd
rename async agent service
b09a627
remove is_sync
5a0348b
remove is_sync
ea91dc7
fix pickle error
7786aca
remove new line
ca34c61
rename task config
1d9535d
use SyncAgentBase
68fd527
remove print
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import collections | ||
import inspect | ||
from abc import abstractmethod | ||
from typing import Any, Dict, Optional, TypeVar | ||
|
||
import jsonpickle | ||
from flyteidl.admin.agent_pb2 import DoTaskResponse | ||
from typing_extensions import get_type_hints | ||
|
||
from flytekit.configuration import SerializationSettings | ||
from flytekit.core.base_task import PythonTask | ||
from flytekit.core.interface import Interface | ||
from flytekit.extend.backend.base_agent import SyncAgentExecutorMixin | ||
|
||
T = TypeVar("T") | ||
TASK_MODULE = "task_module" | ||
TASK_NAME = "task_name" | ||
TASK_CONFIG_PKL = "task_config_pkl" | ||
TASK_TYPE = "api_task" | ||
|
||
|
||
class ExternalApiTask(SyncAgentExecutorMixin, PythonTask): | ||
""" | ||
Base class for all external API tasks. External API tasks are tasks that are designed to run until they receive a | ||
response from an external service. When the response is received, the task will complete. External API tasks are | ||
designed to be run by the flyte agent. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
config: Optional[T] = None, | ||
task_type: str = TASK_TYPE, | ||
return_type: Optional[Any] = None, | ||
**kwargs, | ||
): | ||
type_hints = get_type_hints(self.do, include_extras=True) | ||
signature = inspect.signature(self.do) | ||
inputs = collections.OrderedDict() | ||
outputs = collections.OrderedDict({"o0": return_type}) if return_type else collections.OrderedDict() | ||
|
||
for k, _ in signature.parameters.items(): # type: ignore | ||
annotation = type_hints.get(k, None) | ||
inputs[k] = annotation | ||
|
||
super().__init__( | ||
task_type=task_type, | ||
name=name, | ||
task_config=config, | ||
interface=Interface(inputs=inputs, outputs=outputs), | ||
is_sync_plugin=True, | ||
**kwargs, | ||
) | ||
|
||
self._config = config | ||
|
||
@abstractmethod | ||
async def do(self, **kwargs) -> DoTaskResponse: | ||
""" | ||
Initiate an HTTP request to an external service such as OpenAI or Vertex AI and retrieve the response. | ||
""" | ||
raise NotImplementedError | ||
|
||
def get_custom(self, settings: SerializationSettings = None) -> Dict[str, Any]: | ||
cfg = { | ||
TASK_MODULE: type(self).__module__, | ||
TASK_NAME: type(self).__name__, | ||
} | ||
|
||
if self._config is not None: | ||
cfg[TASK_CONFIG_PKL] = jsonpickle.encode(self._config) | ||
|
||
return cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we have to use pickle?
cc @pingsutw do you know? is this to maintain simply python coversion? This is potentially dangerous as it may break across python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pickle is faster, we've talked about this before and Kevin told me that it might be ok.
Will there be multiple python versions usecases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot control backend and flytekit version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, I fix it!
Thank you very much for your advice!