Skip to content

Commit 162767d

Browse files
committed
explain LLM API key setup
1 parent d38580d commit 162767d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ The table evaluates the frameworks in the following aspects:
260260
We provide a comparison to validate our implementation of TextGrad in Trace:
261261

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

266266
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.
@@ -269,6 +269,31 @@ The LLM APIs are called around the same time to ensure a fair comparison. TextGr
269269
You can also easily implement your own optimizer that works directly with `TraceGraph` (more tutorials on how to work
270270
with TraceGraph coming soon).
271271

272+
## LLM API Setup
273+
274+
Currently we rely on AutoGen for LLM caching and API-Key management.
275+
AutoGen relies on `OAI_CONFIG_LIST`, which is a file you put in your working directory. It has the format of:
276+
277+
```json lines
278+
[
279+
{
280+
"model": "gpt-4",
281+
"api_key": "<your OpenAI API key here>"
282+
},
283+
{
284+
"model": "claude-sonnet-3.5-latest",
285+
"api_key": "<your Anthropic API key here>"
286+
}
287+
]
288+
```
289+
You switch between different LLM models by changing the `model` field in this configuration file.
290+
291+
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.
292+
293+
For convenience, we also provide a method that directly grabs the API key from the environment variable `OPENAI_API_KEY` or `ANTHROPIC_API_KEY`.
294+
However, doing so, we specify the model version you use, which is `gpt-4o` for OpenAI and `claude-sonnet-3.5-latest` for Anthropic.
295+
296+
272297
## Citation
273298

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

0 commit comments

Comments
 (0)