Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.4 #79

Merged
merged 26 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b8abe9b
Update pandas DataFrame demo
forrestbao Nov 30, 2023
f575fc9
fix: external scripts load
Colerar Nov 30, 2023
d9291a8
docs: update GenAI example
Yazawazi Nov 30, 2023
97fb02b
feat: support docstring as description
Yazawazi Dec 1, 2023
83568e0
fix: docstring bug
Yazawazi Dec 1, 2023
31222ae
feat: support label in sheet
Yazawazi Dec 6, 2023
7963f90
fix: markdown list in toc
Yazawazi Dec 6, 2023
f4ac543
feat: sort string in list
Yazawazi Dec 6, 2023
d084052
feat: support "*" syntax sugar
Colerar Dec 6, 2023
8e43162
feat: support "*" in label
Yazawazi Dec 6, 2023
c3b9fc7
feat: support glob and regex as key
Colerar Dec 7, 2023
38dab28
fix: run script in HTML type
Yazawazi Dec 7, 2023
8f02273
feat: add wordle example
Yazawazi Dec 8, 2023
bf9c04a
feat: try to support reactive argument
Yazawazi Dec 11, 2023
d466de5
fix: do not update when function has no reactive
Yazawazi Dec 12, 2023
3db6efd
feat: better rate limit error display
Yazawazi Dec 12, 2023
d6508ac
feat: add empty function list check
Yazawazi Dec 12, 2023
a8993b7
feat: if Literal args less than 8 use radio
Yazawazi Dec 12, 2023
9250251
fix: improve class init error message
Colerar Dec 13, 2023
2527d7c
feat: support camera and microphone input
Yazawazi Dec 15, 2023
340f6d8
update openAI demos in compliance with new openAI API
Dec 18, 2023
b3c2a24
feat: add a simple privacy policy and disclaimer
Yazawazi Dec 18, 2023
1d98273
feat: backend telemetry
Colerar Dec 18, 2023
5756642
feat: add SQLAlchemy
Colerar Dec 18, 2023
3118171
feat: update gitignore
Colerar Dec 18, 2023
d87f896
fix: replace UTC with timezone
Yazawazi Dec 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ dist/
.lh
.env
backend/funix/build
*.db
*.db-*
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ For example, the OpenAI's ChatGPT function below, which str-to-str.
import os # Python's native
import openai # you cannot skip it

openai.api_key = os.environ.get("OPENAI_KEY")

def ChatGPT(prompt: str) -> str:
completion = openai.ChatCompletion.create(
client = openai.Client()
response = client.chat.completions.create(
messages=[{"role": "user", "content": prompt}],
model="gpt-3.5-turbo"
)
return completion["choices"][0]["message"]["content"]
return response.choices[0].message.content
```

With the magical command `funix -l chatGPT_lazy.py`, you will get a web app like this:
Expand Down
6 changes: 6 additions & 0 deletions backend/funix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ def run(
default=default,
)

if decorator.is_empty_function_list():
print(
"No functions nor classes decorated by Funix. Could you wanna enable the lazy mode (add -l flag)?"
)
sys.exit(1)

parsed_ip = ip_address(host)
parsed_port = get_unused_port_from(port, parsed_ip)

Expand Down
72 changes: 72 additions & 0 deletions backend/funix/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""
Save the app instance here
"""
import json
import os
import re
from datetime import datetime, timezone
from secrets import token_hex

from flask import Flask, Response, abort, request
from flask_sock import Sock
from sqlalchemy import create_engine, text
from sqlalchemy.pool import SingletonThreadPool

app = Flask(__name__)
app.secret_key = token_hex(16)
Expand All @@ -26,6 +31,73 @@ def funix_auto_cors(response: Response) -> Response:
return response


if os.environ.get("DISABLE_FUNIX_TELEMETRY") is None:
telemetry_db = os.environ.get("FUNIX_TELEMETRY_DB", default="sqlite:///logs.db")
engine = create_engine(telemetry_db, poolclass=SingletonThreadPool)
with engine.connect() as con:
create_table = """
CREATE TABLE IF NOT EXISTS logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
log_time TEXT NOT NULL,
request TEXT NOT NULL,
response TEXT NOT NULL
);
"""
con.execute(text(create_table))
con.commit()

@app.after_request
def funix_logger(response: Response) -> Response:
global con

do_not_log_me = request.cookies.get("DO_NOT_LOG_ME")
if do_not_log_me is not None and do_not_log_me == "YES":
return response

try:
req_json = request.json
except:
return response

if req_json is None:
return response

try:
resp_json = response.json
except:
return response

if resp_json is None:
return response

dumped_req = json.dumps(
{
"url": request.url,
"headers": dict(request.headers),
"data": req_json,
}
)

dumped_resp = json.dumps(resp_json)

with engine.connect() as con:
con.execute(
text(
"INSERT INTO logs (log_time, request, response) VALUES (:time, :req, :resp)"
),
[
{
"time": datetime.now(timezone.utc).isoformat(),
"req": dumped_req,
"resp": dumped_resp,
}
],
)
con.commit()

return response


regex_string = None


Expand Down
Loading