doc: Runtime readme.md

This commit is contained in:
Dan Chen
2024-03-21 16:21:09 +08:00
parent 11e1659e22
commit 5e2d68230b
3 changed files with 17 additions and 10 deletions

16
runtime/READMD.md Normal file
View File

@ -0,0 +1,16 @@
# Runtime
一台VM運行時用於隔離租戶環境與服務器環境提供腿本用於調用模型流。
# 語法
```
// 使用//註解
// "雙引號字符串"
let s = "hello"
// 整數
let i = 10
// 浮點數
let f = 1.2
// 動態類型
s = i
// 返回值
return s
```

View File

@ -60,14 +60,7 @@ class Runtime:
def variable_declaration(self, ast): def variable_declaration(self, ast):
id = ast.get("identifier").get("name") id = ast.get("identifier").get("name")
v = ast.get("value") v = ast.get("value")
if self._is_literal(v): self.records[id] = self.unquote(v)
l = self.literal(v)
if l != None:
self.records[id] = l
else:
raise Exception("Unknown literal type: " + v.get("type"))
if self._is_identifier(v):
self.records[id] = self.records.get(v.get("name"))
def literal(self, ast): def literal(self, ast):
if ast.get("type") == "StringLiteral": if ast.get("type") == "StringLiteral":

View File

@ -1,11 +1,9 @@
import io import io
from typing import Any, Coroutine
from fastapi import Request, Response, status from fastapi import Request, Response, status
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from .blackbox import Blackbox from .blackbox import Blackbox
from tts.tts_service import TTService from tts.tts_service import TTService
import time
class TTS(Blackbox): class TTS(Blackbox):