mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
Fmt
This commit is contained in:
@@ -12,7 +12,9 @@
|
||||
"source": [
|
||||
"# Code generation with flow\n",
|
||||
"\n",
|
||||
"AlphaCodium presented an approach for code generation [that uses a`flow` paradigm to construct an answer to a coding question iteratively.](https://x.com/karpathy/status/1748043513156272416?s=20). \n",
|
||||
"AlphaCodium presented an approach for code generation that uses control flow.\n",
|
||||
"\n",
|
||||
"Main idea: [construct an answer to a coding question iteratively.](https://x.com/karpathy/status/1748043513156272416?s=20). \n",
|
||||
"\n",
|
||||
"[AlphaCodium](https://github.com/Codium-ai/AlphaCodium) iteravely tests and improves an answer on public and AI-generated tests for a particular question. \n",
|
||||
"\n",
|
||||
@@ -32,7 +34,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" ! pip install -U langchain_community langchain-openai langchain-anthropic langchain langgraph"
|
||||
" ! pip install -U langchain_community langchain-openai langchain-anthropic langchain langgraph bs4"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -79,9 +81,7 @@
|
||||
"\n",
|
||||
"### Code solution\n",
|
||||
"\n",
|
||||
"We can consider [Claude3](https://docs.anthropic.com/claude/docs/models-overview) variants, too.\n",
|
||||
"\n",
|
||||
"We de-couple code solution and code formatting so that any LLM can be used for code solution. "
|
||||
"Try OpenAI and [Claude3](https://docs.anthropic.com/claude/docs/models-overview) with function calling."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -165,7 +165,7 @@
|
||||
"\n",
|
||||
"structured_llm_claude = llm.with_structured_output(code, include_raw=True)\n",
|
||||
"\n",
|
||||
"# Check for errors\n",
|
||||
"# Optional: Check for errors in case tool use is flaky\n",
|
||||
"def check_claude_output(tool_output):\n",
|
||||
" \"\"\"Check for parse error or failure to call the tool\"\"\"\n",
|
||||
"\n",
|
||||
@@ -218,7 +218,9 @@
|
||||
" \n",
|
||||
" return solution['parsed']\n",
|
||||
"\n",
|
||||
"# Wtih re-try\n",
|
||||
"# Wtih re-try to correct for failure to invoke tool\n",
|
||||
"# TODO: Annoying errors w/ \"user\" vs \"assistant\" \n",
|
||||
"# Roles must alternate between \"user\" and \"assistant\", but found multiple \"user\" roles in a row\n",
|
||||
"code_gen_chain = code_gen_chain_re_try | parse_output\n",
|
||||
"\n",
|
||||
"# No re-try\n",
|
||||
|
||||
Reference in New Issue
Block a user