Skip to content

Commit

Permalink
Make suggestions from soumik
Browse files Browse the repository at this point in the history
  • Loading branch information
ash0ts committed Aug 12, 2024
1 parent 5fa9587 commit 8a64310
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
14 changes: 8 additions & 6 deletions docs/docs/guides/cookbooks/codegen/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Code Generation using Weave and OpenAI

---
hide_table_of_contents: true
---

# Code Generation using Weave and OpenAI

Generating high-quality code with proper structure, documentation, and tests is a challenging task. This guide demonstrates how to implement a code generation pipeline using Weave, a powerful framework for building, tracking, and evaluating LLM applications. By combining OpenAI's language models with Weave's robust tooling, you'll learn to create a code generation pipeline that produces high-quality Python functions, complete with main program runners and unit tests, while gaining insights into the generation process.

Expand All @@ -17,7 +19,7 @@ Our pipeline will:

For a visual demonstration of the code generation pipeline using Weave, Groq, and E2B check out this video:

[![Code Generation Pipeline Demo](https://img.youtube.com/vi/B70jJYPVAzE/0.jpg)](https://www.youtube.com/watch?v=B70jJYPVAzE&t=1561s)
<iframe width="560" height="315" src="https://www.youtube.com/embed/B70jJYPVAzE?si=75Z4Fg_DBxAiu9_6&amp" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

This video provides a step-by-step walkthrough of the process, showcasing how Weave integrates with Groq to create a powerful code generation tool and then running the code in E2B, to validate the code.

Expand Down Expand Up @@ -58,9 +60,9 @@ weave.init(WEAVE_PROJECT)
client = OpenAI()
```


> [!NOTE]
> Weave automatically tracks OpenAI API calls, including inputs, outputs, and metadata. This means you don't need to add any additional logging code for your OpenAI interactions – Weave handles it seamlessly in the background.
:::note
Weave automatically tracks OpenAI API calls, including inputs, outputs, and metadata. This means you don't need to add any additional logging code for your OpenAI interactions – Weave handles it seamlessly in the background.
:::

## Leveraging Structured Outputs and Pydantic Models

Expand Down
18 changes: 14 additions & 4 deletions examples/cookbooks/codegen/codegen.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install -qU autopep8 autoflake weave isort openai set-env-colab-kaggle-dotenv\n"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -14,12 +23,14 @@
"import isort\n",
"import weave\n",
"from autoflake import fix_code\n",
"from dotenv import load_dotenv\n",
"from openai import OpenAI\n",
"from pydantic import BaseModel\n",
"from weave import Dataset, Evaluation\n",
"\n",
"load_dotenv()"
"from set_env import set_env\n",
"\n",
"set_env(\"WANDB_API_KEY\")\n",
"set_env(\"OPENAI_API_KEY\")\n"
]
},
{
Expand Down Expand Up @@ -335,8 +346,7 @@
" dataset=prompt_dataset,\n",
" scorers=[test_result_scorer]\n",
" )\n",
" results = await evaluation.evaluate(pipeline)\n",
" print(results)"
" results = await evaluation.evaluate(pipeline)"
]
}
],
Expand Down

0 comments on commit 8a64310

Please sign in to comment.