明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 989|回复: 5

[讨论] 蹭蹭chatGPT的热度,CAD内置聊天。附 json 解析函数。

[复制链接]
发表于 2022-12-9 11:08 | 显示全部楼层 |阅读模式
本帖最后由 vitalgg 于 2022-12-9 14:57 编辑

命令行输入 @C 或 chat 开始聊天。
可以查命令,查变量,查函数,查组码










该解析函数只支持 stringify 格式的 json 字符串,即属性必须有引号。
  1. (defun json:parse (str)
  2.   "Json 字符串转化为 lisp 列表。"
  3.   "list"
  4.   (setq lst-str (vl-string->list str))
  5.   (setq flag-escape nil)
  6.   (setq flag-quote nil)
  7.   (setq flag-keylevel 0)
  8.   (setq flag-arraylevel 0)
  9.   (setq atom-str-lst '())
  10.   ;;(setq res nil)

  11.   (while lst-str
  12.     (setq curr-char (car lst-str))
  13.     (cond
  14.      ((= (ascii "\\") curr-char)
  15.       (setq flag-escape (not flag-escape))
  16.       (setq atom-str-lst (cons curr-char atom-str-lst))
  17.       )
  18.      ((and (= (ascii "\"") curr-char)
  19.      (null flag-escape))
  20.       (setq flag-escape nil)
  21.       (setq flag-quote (not flag-quote))
  22.       (setq atom-str-lst (cons curr-char atom-str-lst))
  23.       )
  24.      (t
  25.       (setq flag-escape nil)
  26.       (if flag-quote
  27.     (setq atom-str-lst (cons curr-char atom-str-lst))
  28.     (cond
  29.      ((= (ascii "{") curr-char)
  30.       ;;对象 key/value mode
  31.       (setq flag-keylevel (1+ flag-keylevel))
  32.       (setq atom-str-lst (cons (ascii "(") atom-str-lst))
  33.       )
  34.      ((= (ascii "[") curr-char)
  35.       ;;array mode
  36.       (setq flag-arraylevel (1+ flag-arraylevel))
  37.       (if(= pre-char (ascii ":"))
  38.     (setq atom-str-lst (cons (ascii "(") (cdddr atom-str-lst)))
  39.         (setq atom-str-lst (cons (ascii "(") atom-str-lst)))
  40.       )
  41.      ((= (ascii "}") curr-char)
  42.       ;;对象 key/value mode
  43.       (setq flag-keylevel (1- flag-keylevel))
  44.       (setq atom-str-lst (cons (ascii ")") atom-str-lst))
  45.       )
  46.      ((= (ascii "]") curr-char)
  47.       ;;array mode
  48.       (setq flag-arraylevel (1- flag-arraylevel))
  49.       (setq atom-str-lst (cons (ascii ")") atom-str-lst)))
  50.      
  51.      ((= (ascii ":") curr-char)
  52.       ;; 处理 key
  53.       (setq atom-str-lst
  54.       (cons (ascii " ")
  55.       (cons (ascii ".")
  56.             (cons (ascii " ") atom-str-lst))))
  57.       )
  58.      ((= (ascii ",")curr-char)
  59.       ;; value
  60.       (setq atom-str-lst
  61.       (cons (ascii "(")
  62.       (cons (ascii ")")
  63.             atom-str-lst)))
  64.       )
  65.      (t (setq atom-str-lst (cons curr-char atom-str-lst)))
  66.      ))))
  67.     (setq pre-char curr-char)
  68.     (setq lst-str(cdr lst-str))
  69.     )
  70.   
  71.   (read(strcat "(" (vl-list->string (reverse atom-str-lst)) ")"))
  72.   )







本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2022-12-9 14:11 | 显示全部楼层
是自己编的一个类似于chatGPT的,在CAD中使用,用于CAD方面智能聊天程序吗?
 楼主| 发表于 2022-12-9 14:42 | 显示全部楼层
VBALISPER 发表于 2022-12-9 14:11
是自己编的一个类似于chatGPT的,在CAD中使用,用于CAD方面智能聊天程序吗?

没有chatGPT的大数据量。
目前只是收集了,命令,变量,lisp函数 和 @lisp函数库的说明用法等。
模糊匹配聊天用户发送的内容,并返回相关内容。

支持智能搜索和一些简单的日常聊天。
发表于 2022-12-9 15:12 | 显示全部楼层
chatGPT是不是一个升级版的搜索引擎?
 楼主| 发表于 2022-12-9 15:23 | 显示全部楼层
guosheyang 发表于 2022-12-9 15:12
chatGPT是不是一个升级版的搜索引擎?

我的理解是chatGPT 将互联网上的内容收集,归类。

根据用户请求内容,按一定规则和逻辑整理后发送给用户。
广义上也算是一种搜索引擎,但是内容是多少加工过的,不是原汁原味的东西。


那个生成插件的代码,基本上是一个模式,像是八股文。
发表于 2022-12-9 15:39 | 显示全部楼层
vitalgg 发表于 2022-12-9 15:23
我的理解是chatGPT 将互联网上的内容收集,归类。

根据用户请求内容,按一定规则和逻辑整理后发送给用 ...

嗯 也就是加上人工智能内容  如果引入超级计算机计算  达到像阿尔法狗的那种效果   这世界很多人就会没事儿干了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-21 13:39 , Processed in 0.640885 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表