q2wxec / langgraph-demo Goto Github PK
View Code? Open in Web Editor NEWlanggraph-demo
langgraph-demo
PS D:\data\langgraph-demo-master\codeagent> python .\workflow.py
---GENERATE SOLUTION---
code_solution:To implement the merge sort algorithm in Python, you can define a function that recursively splits the input list into smaller sublists, sorts them, and then merges them back together in s
orted order.
Imports:
# No specific imports are required for implementing merge sort
Code:
def merge_sort(arr):
if len(arr) > 1:
mid = len(arr) // 2
left_half = arr[:mid]
right_half = arr[mid:]
merge_sort(left_half)
merge_sort(right_half)
i = j = k = 0
while i < len(left_half) and j < len(right_half):
if left_half[i] < right_half[j]:
arr[k] = left_half[i]
i += 1
else:
arr[k] = right_half[j]
j += 1
k += 1
while i < len(left_half):
arr[k] = left_half[i]
i += 1
k += 1
while j < len(right_half):
arr[k] = right_half[j]
j += 1
k += 1
return arr
This merge_sort
function takes a list arr
as input and sorts it using the merge sort algorithm. It recursively divides the input list into smaller sublists until each sublist contains only one eleme
nt. Then it merges the sublists back together in sorted order.
You can use this function by passing a list to it, for example:
my_list = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
sorted_list = merge_sort(my_list)
print(sorted_list)
---CHECKING CODE ---
mentor:{'correct': True}
Traceback (most recent call last):
File "D:\data\langgraph-demo-master\codeagent\workflow.py", line 26, in
app.invoke({"keys": {"question": "如何实现归并排序算法?", "iterations": 0}})
File "C:\Users\xie\AppData\Local\Programs\Python\Python39\lib\site-packages\langgraph\pregel_init_.py", line 1171, in invoke
for chunk in self.stream(
File "C:\Users\xie\AppData\Local\Programs\Python\Python39\lib\site-packages\langgraph\pregel_init_.py", line 774, in stream
"feedback": mentor['feedback'],
KeyError: 'feedback'
**不知道为什么把addendum改成下面中文的,就报以上错误
addendum = """
你先前尝试解决过这个问题。
这是你的解决方案:
{generation}
这是来自代码导师的指导:
{feedback}
请重新尝试回答这个问题。
用对代码解决方案的描述,结构化你的答案。
然后列出要导入的内容。
最后列出功能性的代码块。
用户的问题如下:
{question}**
TypeError: can only concatenate list (not "tuple") to list。这是什么报错?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.