You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Chat completion client for OpenAI hosted models.
855
+
856
+
You can also use this client for OpenAI-compatible ChatCompletion endpoints.
857
+
**Using this client for non-OpenAI models is not tested or guaranteed.**
858
+
859
+
For non-OpenAI models, please first take a look at our `community extensions <https://microsoft.github.io/autogen/dev/user-guide/extensions-user-guide/index.html>`_
860
+
for additional model clients.
861
+
862
+
Args:
863
+
model (str): The model to use. **Required.**
864
+
api_key (str): The API key to use. **Required if 'OPENAI_API_KEY' is not found in the environment variables.**
865
+
timeout (optional, int): The timeout for the request in seconds.
866
+
max_retries (optional, int): The maximum number of retries to attempt.
867
+
organization_id (optional, str): The organization ID to use.
868
+
base_url (optional, str): The base URL to use. **Required if the model is not hosted on OpenAI.**
869
+
model_capabilities (optional, ModelCapabilities): The capabilities of the model. **Required if the model name is not a valid OpenAI model.**
870
+
871
+
To use this client, you must install the `openai` extension:
872
+
873
+
.. code-block:: bash
874
+
875
+
pip install 'autogen-ext[openai]==0.4.0.dev6'
876
+
877
+
The following code snippet shows how to use the client with an OpenAI model:
878
+
879
+
.. code-block:: python
880
+
881
+
from autogen_ext.models import OpenAIChatCompletionClient
882
+
from autogen_core.components.models import UserMessage
883
+
884
+
opneai_model_client = OpenAIChatCompletionClient(
885
+
model="gpt-4o-2024-08-06",
886
+
# api_key="sk-...", # Optional if you have an OPENAI_API_KEY environment variable set.
887
+
)
888
+
889
+
result = await opneai_model_client.create([UserMessage(content="What is the capital of France?", source="user")])
890
+
print(result)
891
+
892
+
893
+
To use the client with a non-OpenAI model, you need to provide the base URL of the model and the model capabilities:
894
+
895
+
.. code-block:: python
896
+
897
+
from autogen_ext.models import OpenAIChatCompletionClient
898
+
from autogen_core.components.models import UserMessage
"""Chat completion client for Azure OpenAI hosted models.
940
+
941
+
Args:
942
+
azure_endpoint (str): The endpoint for the Azure model. **Required for Azure models.**
943
+
model (str): The deployment ID for the Azure model. **Required for Azure models.**
944
+
api_version (str): The API version to use. **Required for Azure models.**
945
+
azure_ad_token (str): The Azure AD token to use. Provide this or `azure_ad_token_provider` for token-based authentication.
946
+
azure_ad_token_provider (Callable[[], Awaitable[str]]): The Azure AD token provider to use. Provide this or `azure_ad_token` for token-based authentication.
947
+
model_capabilities (ModelCapabilities): The capabilities of the model. **Required for Azure models.**
948
+
api_key (optional, str): The API key to use, use this if you are using key based authentication. It is optional if you are using Azure AD token based authentication or `AZURE_OPENAI_API_KEY` environment variable.
949
+
timeout (optional, int): The timeout for the request in seconds.
950
+
max_retries (optional, int): The maximum number of retries to attempt.
951
+
952
+
To use this client, you must install the `azure` and `openai` extensions:
To use the client, you need to provide your deployment id, Azure Cognitive Services endpoint,
959
+
api version, and model capabilities.
960
+
For authentication, you can either provide an API key or an Azure Active Directory (AAD) token credential.
961
+
962
+
The following code snippet shows how to use AAD authentication.
963
+
The identity used must be assigned the `Cognitive Services OpenAI User <https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/role-based-access-control#cognitive-services-openai-user>`_ role.
964
+
965
+
.. code-block:: python
966
+
967
+
from autogen_ext.models import AzureOpenAIChatCompletionClient
968
+
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
azure_ad_token_provider=token_provider, # Optional if you choose key-based authentication.
978
+
# api_key="sk-...", # For key-based authentication. `AZURE_OPENAI_API_KEY` environment variable can also be used instead.
979
+
model_capabilities={
980
+
"vision": True,
981
+
"function_calling": True,
982
+
"json_output": True,
983
+
},
984
+
)
985
+
986
+
See `here <https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/managed-identity#chat-completions>`_ for how to use the Azure client directly or for more info.
Copy file name to clipboardexpand all lines: python/packages/autogen-studio/README.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,7 @@ AutoGen Studio also takes several parameters to customize the application:
85
85
- `--port <port>` argument to specify the port number. By default, it is set to `8080`.
86
86
- `--reload` argument to enable auto-reloading of the server when changes are made to the code. By default, it is set to `False`.
87
87
- `--database-uri` argument to specify the database URI. Example values include `sqlite:///database.sqlite`forSQLite and `postgresql+psycopg://user:password@localhost/dbname` for PostgreSQL. If this is not specified, the database URIL defaults to a `database.sqlite` filein the `--appdir` directory.
88
+
- `--upgrade-database` argument to upgrade the database schema to the latest version. By default, it is set to `False`.
88
89
89
90
Now that you have AutoGen Studio installed and running, you are ready to explore its capabilities, including defining and modifying agent workflows, interacting with agents and sessions, and expanding agent skills.
90
91
@@ -115,12 +116,11 @@ npm run start
115
116
We welcome contributions to AutoGen Studio. We recommend the following general steps to contribute to the project:
116
117
117
118
- Review the overall AutoGen project [contribution guide](https://github.com/microsoft/autogen?tab=readme-ov-file#contributing)
118
-
- Please review the AutoGen Studio [roadmap](https://github.com/microsoft/autogen/issues/737) to get a sense of the current priorities for the project. Help is appreciated especially with Studio issues tagged with `help-wanted`
119
+
- Please review the AutoGen Studio [roadmap](https://github.com/microsoft/autogen/issues/4006) to get a sense of the current priorities for the project. Help is appreciated especially with Studio issues tagged with `help-wanted`
119
120
- Please initiate a discussion on the roadmap issue or a new issue to discuss your proposed contribution.
120
-
- Please review the autogenstudio dev branch here [dev branch](https://github.com/microsoft/autogen/tree/autogenstudio) and use as a base foryour contribution. This way, your contribution will be aligned with the latest changesin the AutoGen Studio project.
121
121
- Submit a pull request with your contribution!
122
122
- If you are modifying AutoGen Studio, it has its own devcontainer. See instructions in`.devcontainer/README.md` to use it
123
-
- Please use the tag `studio`for any issues, questions, and PRs related to Studio
123
+
- Please use the tag `proj-studio`for any issues, questions, and PRs related to Studio
0 commit comments