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

docs: initial Jupyter support for website docs, move config notebook #1448

Merged
merged 11 commits into from
Jan 30, 2024
10 changes: 9 additions & 1 deletion .devcontainer/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM python:3.11-slim-bookworm
# Update and install necessary packages
RUN apt-get update && apt-get -y update
# added vim and nano for convenience
RUN apt-get install -y sudo git npm vim nano curl
RUN apt-get install -y sudo git npm vim nano curl wget

# Setup a non-root user 'autogen' with sudo access
RUN adduser --disabled-password --gecos '' autogen
Expand Down Expand Up @@ -32,6 +32,14 @@ RUN sudo pip install pydoc-markdown
RUN cd website
RUN yarn install --frozen-lockfile --ignore-engines

RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-${arch}.tar.gz && \
mkdir -p /home/autogen/quarto/ && \
tar -xzf quarto-1.4.549-linux-${arch}.tar.gz --directory /home/autogen/quarto/ && \
rm quarto-1.4.549-linux-${arch}.tar.gz

ENV PATH="${PATH}:/home/autogen/quarto/quarto-1.4.549/bin/"

# Exposes the Yarn port for Docusaurus
EXPOSE 3000

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ jobs:
- name: pydoc-markdown run
run: |
pydoc-markdown
- name: quarto install
working-directory: ${{ runner.temp }}
run: |
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-amd64.tar.gz
tar -xzf quarto-1.4.549-linux-amd64.tar.gz
echo "$(pwd)/quarto-1.4.549/bin/" >> $GITHUB_PATH
- name: quarto run
run: |
quarto render .
- name: Test Build
run: |
if [ -e yarn.lock ]; then
Expand Down Expand Up @@ -75,6 +84,15 @@ jobs:
- name: pydoc-markdown run
run: |
pydoc-markdown
- name: quarto install
working-directory: ${{ runner.temp }}
run: |
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-amd64.tar.gz
tar -xzf quarto-1.4.549-linux-amd64.tar.gz
echo "$(pwd)/quarto-1.4.549/bin/" >> $GITHUB_PATH
- name: quarto run
run: |
quarto render .
- name: Build website
run: |
if [ -e yarn.lock ]; then
Expand Down
4 changes: 4 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package-lock.json
.cache-loader
docs/reference

docs/llm_endpoint_configuration.mdx

# Misc
.DS_Store
.env.local
Expand All @@ -20,3 +22,5 @@ docs/reference
npm-debug.log*
yarn-debug.log*
yarn-error.log*

/.quarto/
9 changes: 8 additions & 1 deletion website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ cd website
yarn install
```

### Install Quarto

`quarto` is used to render notebooks.

Install it [here](https://quarto.org/docs/get-started/).

## Local Development

Navigate to the website folder and run:
Navigate to the `website` folder and run:

```console
pydoc-markdown
quarto render ./docs
yarn start
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,57 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# In-depth Guide to OpenAI Utility Functions\n",
"---\n",
"custom_edit_url: https://github.com/microsoft/autogen/edit/main/website/docs/llm_endpoint_configuration.ipynb\n",
"---\n",
"\n",
"# LLM Endpoint Configuration\n",
"\n",
"## TL;DR\n",
"\n",
"For just getting started with AutoGen you can use the following to define your LLM endpoint configuration:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import autogen\n",
"\n",
"config_list = autogen.get_config_list([\"YOUR_OPENAI_API_KEY\"], api_type=\"openai\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\\:\\:\\:danger \n",
"\n",
"Never commit secrets into your code. Before committing, change the code to use a different way of providing your API keys as described below.\n",
"\n",
"\\:\\:\\:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"## In-depth\n",
"\n",
"Managing API configurations can be tricky, especially when dealing with multiple models and API versions. The provided utility functions assist users in managing these configurations effectively. Ensure your API keys and other sensitive data are stored securely. You might store keys in `.txt` or `.env` files or environment variables for local development. Never expose your API keys publicly. If you insist on storing your key files locally on your repo (you shouldn't), ensure the key file path is added to the `.gitignore` file.\n",
"\n",
"#### Steps:\n",
"### Steps:\n",
"1. Obtain API keys from OpenAI and optionally from Azure OpenAI (or other provider).\n",
"2. Store them securely using either:\n",
" - Environment Variables: `export OPENAI_API_KEY='your-key'` in your shell.\n",
" - Text File: Save the key in a `key_openai.txt` file.\n",
" - Env File: Save the key to a `.env` file eg: `OPENAI_API_KEY=sk-********************`\n",
"3. [Ensure `pyautogen` is installed](./installation/Installation.mdx)\n",
"\n",
"---\n",
"\n",
"**TL;DR:** <br>\n",
"There are many ways to generate a `config_list` depending on your use case:\n",
"\n",
"- `get_config_list`: Generates configurations for API calls, primarily from provided API keys.\n",
Expand All @@ -26,14 +63,14 @@
"- `config_list_from_models`: Creates configurations based on a provided list of models, useful when targeting specific models without manually specifying each configuration.\n",
"- `config_list_from_dotenv`: Constructs a configuration list from a `.env` file, offering a consolidated way to manage multiple API configurations and keys from a single file.\n",
"\n",
"If mutiple models are provided, the Autogen client (`OpenAIWrapper`) and agents don't choose the \"best model\" on any criteria - inference is done through the very first model and the next one is used only if the current model fails (e.g. API throttling by the provider or a filter condition is unsatisfied)."
"If multiple models are provided, the Autogen client (`OpenAIWrapper`) and agents don't choose the \"best model\" on any criteria - inference is done through the very first model and the next one is used only if the current model fails (e.g. API throttling by the provider or a filter condition is unsatisfied)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### What is a `config_list`?\n",
"### What is a `config_list`?\n",
"When instantiating an assistant, such as the example below, it is passed a `config_list`. This is used to tell the `AssistantAgent` which models or configurations it has access to:\n",
"```python\n",
"\n",
Expand All @@ -56,24 +93,6 @@
"Different tasks may require different models, and the `config_list` aids in dynamically selecting the appropriate model configuration, managing API keys, endpoints, and versions for efficient operation of the intelligent assistant. In summary, the `config_list` helps the agents work efficiently, reliably, and optimally by managing various configurations and interactions with the OpenAI API - enhancing the adaptability and functionality of the agents."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# %pip install \"pyautogen>=0.2.3\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import autogen"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
},
{'Use Cases': [{type: 'autogenerated', dirName: 'Use-Cases'}]},
'llm_endpoint_configuration',
'Contribute',
'Research',
'Migration-Guide'
Expand Down
Loading