Skip to content

Commit

Permalink
explain LLM API key setup
Browse files Browse the repository at this point in the history
  • Loading branch information
allenanie committed Dec 10, 2024
1 parent d38580d commit 162767d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The table evaluates the frameworks in the following aspects:
We provide a comparison to validate our implementation of TextGrad in Trace:

<p align="center">
<img src="https://github.com/microsoft/Trace/blob/main/docs/images/compare_to_textgrad3.png" alt="drawing" width="100%"/>
<img src="https://github.com/microsoft/Trace/blob/main/docs/images/compare_to_textgrad3.png?raw=True" alt="drawing" width="100%"/>
</p>

To produce this table, we ran the TextGrad pip-installed repo on 2024-10-30, and we also include the numbers reported in the TextGrad paper.
Expand All @@ -269,6 +269,31 @@ The LLM APIs are called around the same time to ensure a fair comparison. TextGr
You can also easily implement your own optimizer that works directly with `TraceGraph` (more tutorials on how to work
with TraceGraph coming soon).

## LLM API Setup

Currently we rely on AutoGen for LLM caching and API-Key management.
AutoGen relies on `OAI_CONFIG_LIST`, which is a file you put in your working directory. It has the format of:

```json lines
[
{
"model": "gpt-4",
"api_key": "<your OpenAI API key here>"
},
{
"model": "claude-sonnet-3.5-latest",
"api_key": "<your Anthropic API key here>"
}
]
```
You switch between different LLM models by changing the `model` field in this configuration file.

You can also set an `os.environ` variable `OAI_CONFIG_LIST` to point to the location of this file or directly set a JSON string as the value of this variable.

For convenience, we also provide a method that directly grabs the API key from the environment variable `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`.
However, doing so, we specify the model version you use, which is `gpt-4o` for OpenAI and `claude-sonnet-3.5-latest` for Anthropic.


## Citation

If you use this code in your research please cite the following [publication](https://arxiv.org/abs/2406.16218):
Expand Down

0 comments on commit 162767d

Please sign in to comment.