Maplemx / Agently

[AI Agent Application Development Framework] - 🚀 Build AI agent native application in very few code 💬 Easy to interact with AI agent in code using structure data and chained-calls syntax 🧩 Enhance AI Agent using plugins instead of rebuild a whole new agent
http://agently.tech
Apache License 2.0
1.07k stars 122 forks source link

代码换行符被替换没了 #37

Closed duolabmeng6 closed 9 months ago

duolabmeng6 commented 9 months ago

image

正常的输出是这样子的

{
    "code": "def bubble_sort(arr):\n    \"\"\"\n    冒泡排序函数\n\n    Args:\n        arr (list): 待排序的列表\n\n    Returns:\n        None\n    \"\"\"\n    n = len(arr)\n\n    for i in range(n - 1):\n        for j in range(0, n - i - 1):\n            if arr[j] > arr[j + 1]:\n                arr[j], arr[j + 1] = arr[j + 1], arr[j]\n\n    my_list = [64, 34, 25, 12, 22, 11, 90]\n    bubble_sort(my_list)\n    print(\"排序后的列表:\", my_list)\n"
}

经过这个函数就变成了 完全没法用了哦

{"code":"def bubble_sort(arr):        冒泡排序函数    Args:        arr (list): 待排序的列表    Returns:        None        n = len(arr)    for i in range(n - 1):        for j in range(0, n - i - 1):            if arr[j] > arr[j + 1]:                arr[j], arr[j + 1] = arr[j + 1], arr[j]    my_list = [64, 34, 25, 12, 22, 11, 90]    bubble_sort(my_list)    print(排序后的列表:, my_list)"}
duolabmeng6 commented 9 months ago
import re
def find_all_jsons(origin: str):
    # 使用正则表达式找到所有 ```json ``` 标记的内容
    pattern = r"```json(.*?)```"
    matches = re.findall(pattern, origin, re.DOTALL)

    # 创建一个列表来存储找到的 JSON 内容
    json_blocks = [match.strip() for match in matches]

    return json_blocks
duolabmeng6 commented 9 months ago

修复了

duolabmeng6 commented 9 months ago

Agently\utils\transform.py

duolabmeng6 commented 9 months ago

image 问题挺多的 token消耗非常多 如果是 pro版本 一次7000 token...啊这 优化一下代码返回的吧

duolabmeng6 commented 9 months ago

image 似乎代码逻辑是 格式不正确就继续问 啊这...我第一次用发现token怎么没了那么多..

Maplemx commented 9 months ago

格式不正确只会修复一次,还修复不了就会抛出错误

find json那个不能直接用'''json来替换,模型不一定会那样输出,换行问题的确是的,我来看看怎么修复

Maplemx commented 9 months ago

image 问题挺多的 token消耗非常多 如果是 pro版本 一次7000 token...啊这 优化一下代码返回的吧

这个是在跑智能体协同沙盒那个任务吗?

duolabmeng6 commented 9 months ago

image 问题挺多的 token消耗非常多 如果是 pro版本 一次7000 token...啊这 优化一下代码返回的吧

这个是在跑智能体协同沙盒那个任务吗?

https://aistudio.baidu.com/projectdetail/7245939

https://aistudio.baidu.com/application/detail/12682
昨天刚刚开发好的 然后昨天晚上刚好看到你的视频 我想着接口格式挺好的 我就想换上去结果效果非常的糟糕啊 完全是不可以用的状态 尝试修了一下依然不行..改回去了.

有交流的微信群吗

Maplemx commented 9 months ago

代码换行的确是我们没处理好。有微信群,您discord上私我一下微信号,我来加

Maplemx commented 9 months ago

fixed in https://github.com/Maplemx/Agently/commit/24b28ddcb9dabf2500311910aa50e74f1f61ad23

Maplemx commented 9 months ago

released in 3.0.5.post3