模糊操作语法语言与虚拟机

F.O.G.是一种功能语言和虚拟机,旨在通过可编程和可组合的函数/工具调用来扩展和增强AI模型的能力。核心是Fog Machine,一个解释器和运行时,使LLM能够使用简单的功能中间表示(IR)生成、计划和执行指令。

  • by 0div
  • Go
  • 本地部署
  • 4 星标
  • 更新于

使用说明

FOG(在中文中通常可直接音译为“福格”,但具体含义需根据上下文确定)

  ░▒▓██████████████████████████▓▒░         
 ░▒▓█▀▀░█░█░▀▀█░▀▀█░█░█░▒▓██▓▒░░░                        
 ░▒▓█▀▀░█░█░▄▀░░▄▀░░░█░░▒▓██▓▒░░░                        
 ░▒▓▀░░░▀▀▀░▀▀▀░▀▀▀░░▀░░▒▓██▓▒░░░                        
  ░▒▓██████████████████████████▓▒░         
 ░▒▓█▀█░█▀█░█▀▀░█▀▄░█▀█░▀█▀░▀█▀░█▀█░█▀█░█▀█░█▓▒▒▒░
 ░▒▓█░█░█▀▀░█▀▀░█▀▄░█▀█░░█░░░█░░█░█░█░█░█▀█░█▓▒▒▒░
 ░▒▓▀▀▀░▀░░░▀▀▀░▀░▀░▀░▀░░▀░░▀▀▀░▀▀▀░▀░▀░▀░▀░▀▀▀▓▒░
  ░▒▓██████████████████████████▓▒░         
 ░▒▓█▀▀░█▀▄░█▀█░█▄█░█▄█░█▀█░█▀▄░▒▓██▓▒░                 
 ░▒▓█░█░█▀▄░█▀█░█░█░█░█░█▀█░█▀▄░▒▓██▓▒░                 
 ░▒▓▀▀▀░▀░▀░▀░▀░▀░▀░▀░▀░▀░▀░▀░▀░▒▓██▓▒░                 
  ░▒▓██████████████████████████▓▒░

描述

F.O.G.(模糊操作语法)是一种功能语言和虚拟机,专为通过程序化和可组合的函数/工具调用来扩展和增强人工智能模型而设计。其核心在于 _烟雾机_一个解释器和运行时环境,使大型语言模型(LLMs)能够使用简单的函数式中间表示(IR)来生成、规划和执行指令。

作为大型语言模型(LLM)代理的计算和行动层,FOG使得构建复杂、动态且可扩展的工作流程成为可能,让人工智能模型不仅能在明确定义且受控的范围内“思考”,还能“行动”。

建筑

flowchart LR
    A[Prompt] ---> B[LLM]
    B --->|IR AST| C[IR Interpreter]
    C ---->|F.O.G. AST| D[Interpreter]
    C ---> E[(Vector Heap)]

    subgraph Fuzzy Syntax Analysis
        B
    end

    subgraph Fog Machine
        C
        E
    end

    subgraph Execution
        D
    end

开始入门

# Fill in the configuration from template
$ cp .env.template .env.local

# Start services in a separate terminal
$ docker compose up

# Install the binary
$ go install

# Migrate up
$ fog migrate postgres up

# Seed the DB
$ fog seed

# Run the fog REPL 
$ fog

# Help
$ fog -h

# Run example
$ fog -d


         ░░▒▒▓▓██▓▓▒▒░
        ░▒▓█████████▓▒░
        ▒▓▓▓ F O G ▓▓▓▒
        ░▒▓█████████▓▒░
         ░░▒▒▓▓██▓▓▒▒░


>  get weather in my current city

╔════════════════════════════════════════════════════════════╗
║         Parsing prompt into the Intermediate AST...        ║
╚════════════════════════════════════════════════════════════╝

{
  "type": "FunctionCall",
  "description": "get the weather in a given city",
  "children": [
    {
      "type": "FunctionCall",
      "description": "get the location coordinates for the current city"
    }
  ]
}

╔════════════════════════════════════════════════════════════╗
║         Compiling Intermediate AST into FOG AST...         ║
╚════════════════════════════════════════════════════════════╝

{
  "type": "FunctionCall",
  "name": "getWeather",
  "description": "get the weather in a given city",
  "js": "function getWeather(city) { return { city: city, temp: 70, condition: \"sunny\" }; }",
  "distance": 0.05404893369210706,
  "children": [
    {
      "type": "FunctionCall",
      "name": "__getCurrentCity__",
      "description": "get the location coordinates for the current city",
      "js": "function __getCurrentCity__() { return \"Tokyo\"; }",
      "distance": 0.18011193097638434
    }
  ]
}

╔════════════════════════════════════════════════════════════╗
║           Evaluating the Intermediate AST...               ║
╚════════════════════════════════════════════════════════════╝

Result: map[city:Tokyo condition:sunny temp:70]

添加功能

将您预定义的JS函数添加到 `seed_data.json` 翻译成中文是:“种子数据.json” 文件。

待办事项

  • [ ] 当函数缺失或距离过低时自动生成代码
  • [ ] 将MCP集成到函数调用中
  • [ ] 缓存高置信度的AST(抽象语法树)评估结果
  • [ ] 创建内置原语以实现安全和私有函数调用
  • [ ] 添加测试