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

[Feature Request]: Whether autogen-studio supports exposing the workflow API for external applications #3080

Open
shanmu-raoyunfei opened this issue Jul 4, 2024 · 6 comments
Labels
enhancement New feature or request studio Related to AutoGen Studio.

Comments

@shanmu-raoyunfei
Copy link

Is your feature request related to a problem? Please describe.

Whether autogen-studio supports exposing the workflow API for external applications?This will be very useful

Describe the solution you'd like

No response

Additional context

No response

@shanmu-raoyunfei shanmu-raoyunfei added the enhancement New feature or request label Jul 4, 2024
@qingyun-wu
Copy link
Collaborator

Good question! @victordibia and @JingyaChen do we have this plan? It sounds like a very useful feature to have!

@victordibia victordibia added the studio Related to AutoGen Studio. label Jul 4, 2024
@victordibia
Copy link
Collaborator

victordibia commented Jul 4, 2024

Hi @shanmu-raoyunfei ,

Great question.
Yes, we have documentation here that shows how you can export your workflow as json and then import it in your python application using the workflow api.

image
}

from autogenstudio import WorkflowManager
# load workflow from exported json workflow file.
workflow_manager = WorkflowManager(workflow="path/to/your/workflow_.json")

# run the workflow on a task
task_query = "What is the height of the Eiffel Tower?. Dont write code, just respond to the question."
workflow_manager.run(message=task_query)

The workflow can be launched as an API endpoint from the command line using the autogenstudio commandline tool.

autogenstudio serve --workflow=workflow.json --port=5000

@shanmu-raoyunfei , does this address the needs you are describing?
Note: There may be slight changes to the api in the future.

@shanmu-raoyunfei
Copy link
Author

This will solve some of my problems. It would be nice to have direct access to workflow as an API endpoint. Running this workflow from the command line or from a separate application is cumbersome. Thank you very much for your reply

@sekharmalla
Copy link

I am having trouble as well with using workflow API in a python code.

There are two things here:

  • When I configured a model, An agent, A workflow and tested in the playground the results were amazing, but when I tried to export the workflow and use in a sample python code. It's just printing below:
    python spellingbee.py role='assistant' content='' meta={'messages': [], 'summary_method': 'none', 'time': 1.9073486328125e-06, 'files': [], 'task': 'What is the height of the Eiffel Tower?. Dont write code, just respond to the question.'} id=None created_at=datetime.datetime(2024, 7, 7, 13, 11, 27, 604561) updated_at=datetime.datetime(2024, 7, 7, 13, 11, 27, 604564) user_id=None session_id=None connection_id=None []
    After that I inspected the workflow json file and it has no information other than metadata. I am not sure how did that happened.
from autogenstudio import WorkflowManager

# load workflow from json file
workflow_manager = WorkflowManager(workflow="Spelling-bee-Workflow.json")

# run the workflow on a task
task_query = "What is the height of the Eiffel Tower?. Dont write code, just respond to the question."
result =  workflow_manager.run(message=task_query)
print(result)
history = workflow_manager.agent_history
print(history)

Spelling-bee-Workflow.json

{"user_id":"guestuser@gmail.com","version":"0.0.1","name":"Hacker News Workflow","description":"Hacker News Workflow","type":"sequential","summary_method":"none","sample_tasks":[]}

image

A Snapshot from Spelling-bee playground session

  • The Second thing I've tried autogenstudio serve --workflow=workflow.json --port=5000 as well but I couldn't figure out the request body (would be beneficial for beginners to have a small section in the documentation). If I figure out before anyone support me, I will contribute for the documentation of it.

Hoping to get some help from the community or maintainers.

Thank you for all for your hard work.
-Chandra

@victordibia
Copy link
Collaborator

@shanmu-raoyunfei ,

Thats a good point. AutoGen Studio actually exposes the API end point that is used by the UI.
The API endpoint is built using FastAPI and you can review the docs by

autogenstudio ui --port 8081 --docs 

Then go to http://localhost:8081/api/docs

image

In AGS, tasks are run within sessions and the endpoint for this is /sessions/{session_id}/workflow/{workflow_id}/run .
You can also look at the frontend code to see how this api is called from the frontend.

image
@victordibia
Copy link
Collaborator

@sekharmalla ,

Thanks for mentioning this. The behavior here is still being improved. There are currently two ways to download a workflow (which should be merged into one). The download button on the card has only the workflow definition. However, if you click export (see documentation here), there a download button that exports the entire workflow (with agents, skills, models etc). That is the workflow that can be integrated with code or command line etc.

The serve command uses a relatively simple FastAPI implementation (code here) and if you go to the url of the app :5000/docs this should describe the api endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request studio Related to AutoGen Studio.
4 participants