当前位置: 首页 > news >正文

找人做网站去哪里找物联网平台有哪些

找人做网站去哪里找,物联网平台有哪些,手机网站开发位置定位,网页设计作品及代码要进一步提升智能编码助手的效率,我觉得需要做到两点 1) 进一步让主人聚焦于设计输入以及结果验证的循环 2) 进一步让智能编码助手聚焦于代码实现和程序流程(保存、打开,修订、执行、合并…) 正好接触到LLM…

要进一步提升智能编码助手的效率,我觉得需要做到两点
1) 进一步让主人聚焦于设计输入以及结果验证的循环
2) 进一步让智能编码助手聚焦于代码实现和程序流程(保存、打开,修订、执行、合并…)
正好接触到LLM的LangChain的框架,那么初步体验一把利用其Agent实现代码生成,保存与执行
LangChain的中文官网

参考借鉴链接 :阿里通义千问结合Langchain基于程序运行结果回答问题
链接中有一篇介绍,要求AI计算给定阶数(文中是10阶)斐波那契数列,代码生成和执行已经有了,所以我的诉求,看上去挺简单,增加一个保存有效代码的功能就OK了
初步改造如下,新增存盘的函数和相关调用:

#**新增存盘函数**
def saveFile(replyMessages: str):print('... to save the file ...')python_path="/home/cfets/eclipse-workspace/TestAI/testchain/"now_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime())i = random.randint(1, 100)code_file = python_path + "pyAITest_" + now_time + '_' + str(i) + ".py"# 保存至文件res_content=Falsetry:with open(code_file, 'w') as f:f.write(replyMessages)res_content =Trueexcept Exception as e:print('Error: %s' % e)return res_content@tool
def py_repl_tool(code: str):"""Returns the result of execution."""_, after = code.split("```py")realcode = code.split("```")[0]# **新增保存文件**if saveFile(realcode):print('file is saved ... ')py_repl=PythonREPL()return py_repl.run(realcode)if __name__ == '__main__':os.environ["DASHSCOPE_API_KEY"] = dashscope.api_keytools = [Tool(name = "python repl",func=py_repl_tool.run,description="useful for when you need to use python to answer a question."+"You should input python code in correct format and keep the logic as simple as possible. If you want to see the output of a value, you should print it out with `print(...)`.")]agent = initialize_agent(llm=tongyi.Tongyi(model_name="qwen-max",temperature=0.1), tools=tools,verbose=True,max_iterations=3,
)agent.run("What is the 10th fibonacci number?")#agent.run("How many letters in string: Helllomyyfrienddds?")

但很遗憾,测试的结果是,计算的结果与文章一致,10阶斐波那契数列,但保存的文件是空的
在这里插入图片描述

实际上,原代码中split不靠谱,按源代码realcode是空的,需要修改

@tool
def py_repl_tool(code: str):"""Returns the result of execution."""_, after = code.split("```py")# realcode = code.split("```")[0]   原文档的错误#修订后realcode = after.split("```")[0]#print('realcode:  %s' % realcode)# **新增保存文件**if saveFile(realcode):print('file is saved ... ')py_repl=PythonREPL()return py_repl.run(realcode)

修改后执行就OK
主程序执行结果:
在这里插入图片描述
与保存的程序执行结果一致
在这里插入图片描述
但是计算结果是34 这是9阶的斐波那契数列,而不是55——10阶的斐波那契数列,原链接中的结果
在这里插入图片描述
可以把这段代码cp下来算一下,fibonacci(10)=34 , fibonacci(11)才是55
考虑到原代码realcode实际上为空的问题,我觉得原先的agent是分别生成了代码,但没有执行代码(realcode是空,执行啥?)而是找了答案,但无法确认… 所以AI自动生成代码还是保存后检查执行的,这算是歪打正着吧。

最后一个问题,根据初步了解 agent相关tool生成结果跟description描述有直接关系,如果直接引用原来的描述

description="useful for when you need to use python to answer a question.
You should input python code in correct format and keep the logic as simple as possible.   
If you want to see the output of a value, you should print it out with `print(...)`."

agent生成结果会呈现不稳定,有的时候’‘’ py …‘’’ 有的时候 ‘’’ python …‘’’
那么就会报错,参考原文,整理出一个较为完整的描述(description,相当于需求或者设计描述)
完整代码如下:

import dashscope
import os
from langchain_community.llms import tongyi
from langchain.agents import initialize_agent
from langchain.agents.tools import Tool
from langchain.tools import tool
from langchain.utilities.python import PythonREPL
import re
import time
import randomdashscope.api_key="xxxxxx"  #请自行替换# 新增存盘函数
def saveFile(replyMessages: str):print('... to save the file ...')python_path="/home/cfets/eclipse-workspace/TestAI/testchain/"now_time = time.strftime('%Y-%m-%d_%H:%M:%S', time.localtime())i = random.randint(1, 100)code_file = python_path + "pyAITest_" + now_time + '_' + str(i) + ".py"# 保存至文件res_content=Falsetry:with open(code_file, 'w') as f:f.write(replyMessages)res_content =Trueexcept Exception as e:print('Error: %s' % e)return res_content@tool
def py_repl_tool(code: str):"""Returns the result of execution."""_, after = code.split("```python")  realcode = after.split("```")[0]   #修改了原代码错误py_repl=PythonREPL()#print('realcode:  %s' % realcode)# 新增保存文件if saveFile(realcode):print('file is saved ... ')return py_repl.run(realcode)if __name__ == '__main__':os.environ["DASHSCOPE_API_KEY"] = dashscope.api_keytools = [Tool(name = "python repl",func=py_repl_tool.run,description=""""useful for when you need to use python to answer a question. You should input python code in correct format and keep the logic as simple as possible. you should end the program with `print(...)` to print the output and return only python code in Markdown format, e.g.:```python....```""")     #修改了描述,指定了Markdown format]agent = initialize_agent(llm=tongyi.Tongyi(model_name="qwen-max",temperature=0.1), tools=tools,verbose=True,max_iterations=3,
)agent.run("What is the 10th fibonacci number?")

后续考虑几方面的进一步改进
对单一功能实现单元化设计,把多个功能集成串起来,包括前后台设计,形成较为复杂的程序, 再进一步开发本地的知识库/代码库, 同时再利用现有架构测试其他大模型。

最后,希望大家能不能帮我解决一个问题,就是在执行代码为空的时候 55到底是怎么得出来的,先行拜谢

http://www.yayakq.cn/news/692838/

相关文章:

  • 福州网站建设福州深圳住房保障和建设局官网
  • 哪些因素营销网站权重wordpress 自动退出
  • 网站建设和续费深圳上市公司100强
  • 设计互动网站建设做网站流量点击分析的软件
  • 天猫淘宝优惠券网站怎么做动态发布网站和静态发布网站
  • 广州做外贸网站公司wordpress发布文章 发布
  • 建站申请东莞php网站开发
  • 网站建设费 会计分录wordpress有用户主页吗
  • 网站一定要备案苏州最新情况最新消息今天
  • 有关网站开发的文献综述租赁模板建站 网站的名称归属
  • 瑶海区网站建设百度软件中心下载安装
  • 炫酷网站源码别人做的网站自己根目录吗
  • 务川县建设局官方网站国际国内新闻最新消息今天
  • 网站定位的核心意义网站建设岗位能力
  • 中国贸易网站网站关键词锚文本指向
  • 灵犀科技网站开发手机欧美视频网站模板下载 迅雷下载 迅雷下载地址
  • 做网站 空间手机网站前端
  • 做企业网站电话销售话术Wordpress主题 仿魅族
  • 专门做儿童的店铺网站seo是做什么工作的
  • 重点专业建设验收网站微信企业官方网站怎么做
  • 网站建设丨找王科杰信誉济南大型网站制作
  • 南沙滩做网站公司摄影网站免费源码
  • 企业型网站百度上可以做中英文网站吗
  • 池州建设网站网站在线访谈栏目建设
  • 哪里可以在百度做网站展示类网站建设
  • 温州网站排名优化如何去掉网站后缀wordpress
  • 北京制作网站的公司自己网站内容怎么才能被百度抓取
  • 网站建设谈客户说什么网站新建网页
  • 广州网站建设联享科技电商网站 厦门
  • 网站建设公司现在还挣钱吗工业设计网站哪个最