microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
31.54k stars 4.59k forks source link

[Bug] handles py code? #1062

Closed lucasjinreal closed 5 months ago

lucasjinreal commented 9 months ago
请尝试使用以下更新的代码:
```py
# filename: news_report.py

import requests

url = 'https://newsapi.org/v2/top-headlines?country=us&apiKey=<your_api_key>'
response = requests.get(url)
data = response.json()

headlines = [article['title'] for article in data['articles']]
markdown_report = '\n'.join(['- ' + headline for headline in headlines])

print(markdown_report)

在您的计算机上创建一个名为news_report.py的新文件,并将此代码粘贴到其中。 然后,请替换<your_api_key>为您的News API密钥。 如果您没有密钥,请访问News API注册并获取一个免费的API密钥。 保存文件后,在命令行中运行以下命令以执行脚本:

python news_report.py

当脚本成功执行时,它将显示新闻标题列表。 请注意,由于API限制和网络延迟,结果可能有所不同。


EXECUTING CODE BLOCK 0 (inferred language is py)... user_proxy (to assistant):

exitcode: 1 (execution failed) Code output: unknown language py



How to handle py code?

Obviously, py is a valid lan in most markdown format...... and very human knows it's python, why this stupid agent not?
rickyloynd-microsoft commented 9 months ago

@lucasjinreal Can you provide a complete example in English only?

lucasjinreal commented 9 months ago

For summay, the code can not be executed when LLM produces code in markdown format with py code mark.

rickyloynd-microsoft commented 9 months ago

@sonichi

sonichi commented 9 months ago

Let's add "py" to line 1119 of conversable_agent.py

SANTHOSH-MAMIDISETTI commented 8 months ago

@rickyloynd-microsoft @sonichi is it solved or there is something to be worked on to solve it ?, If yes , I am interested in working on this issue ,

sonichi commented 8 months ago

It's not solved. You can assign yourself and work on it.

SANTHOSH-MAMIDISETTI commented 8 months ago

Let's add "py" to line 1119 of conversable_agent.py

@sonichi can you please elaborate what does this mean, I have briefly gone through the conversable_agent.py present at autogen/agentchat/conversable_agent.py and also the line number 1119 image

It was an else statement. Maybe I am missing a few more details , I am not quite sure of how to proceed

Let's add "py" to line 1119 of conversable_agent.py

suggestions are appreciated :)

SANTHOSH-MAMIDISETTI commented 8 months ago

I'm currently encountering difficulty in assigning myself.

It's not solved. You can assign yourself and work on it.

rickyloynd-microsoft commented 8 months ago

I'm currently encountering difficulty in assigning myself.

It's not solved. You can assign yourself and work on it.

I just assigned you.

sonichi commented 8 months ago

Let's add "py" to line 1119 of conversable_agent.py

@sonichi can you please elaborate what does this mean, I have briefly gone through the conversable_agent.py present at autogen/agentchat/conversable_agent.py and also the line number 1119 image

It was an else statement. Maybe I am missing a few more details , I am not quite sure of how to proceed

Let's add "py" to line 1119 of conversable_agent.py

suggestions are appreciated :)

The file is updated. The new line is: https://github.com/microsoft/autogen/blob/44260934f34b2e237fbf6d3da0cedd514642e294/autogen/agentchat/conversable_agent.py#L1395

SANTHOSH-MAMIDISETTI commented 8 months ago

Oh alright, in that case , I believe that the issue has been solved ? @sonichi @rickyloynd-microsoft

or the same line has to be added even at line 1119 as mentioned in the below

Let's add "py" to line 1119 of conversable_agent.py

sonichi commented 8 months ago

It hasn't been solved. Just the line number has changed.

debianmaster commented 8 months ago

can you also add support for language type "yaml" for which a file has to be created ? just guide me so i can change

sonichi commented 8 months ago

can you also add support for language type "yaml" for which a file has to be created ? just guide me so i can change

Two places need to be modified to add an "elif" branch: https://github.com/microsoft/autogen/blob/44260934f34b2e237fbf6d3da0cedd514642e294/autogen/code_utils.py#L224 https://github.com/microsoft/autogen/blob/44260934f34b2e237fbf6d3da0cedd514642e294/autogen/agentchat/conversable_agent.py#L1406

SANTHOSH-MAMIDISETTI commented 8 months ago

In that case, I think , adding "py" along with python and all other languages mentioned over there completes this issue , is that all ?