command | description |
---|---|
ctrl + a | Goto BEGINNING of command line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$npx genaiscript run genaisrc/demo01.genai.mjs | |
genaiscript: genaisrc/demo01.genai.mjs | |
trace: /.genaiscript/runs/demo01/2024-11-04T08-11-49-564Z.trace.md | |
prompting openai:gpt-4o (~543 tokens) | |
```json schema=CITY_SCHEMA | |
[ | |
{ | |
"name": "Bangkok", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a = await ai.languageModel.capabilities() | |
console.log(a.available); | |
// ถ้าขึ้นคำว่า readily แสดงว่าเราสามารถใช้งานได้เลย | |
// แต่ถ้าไม่ ให้ทำการสร้างดังนี้ | |
await ai.languageModel.create(); | |
ทำการตรวจสอบใน browser = chrome://components | |
* Optimization Guide On Device Model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For OTLP - OTLP Prometheus endpoint, OTLP requires pushing | |
management.otlp.metrics.export.url=http://localhost:9090/api/v1/otlp/v1/metrics | |
# only for demo purposes | |
management.otlp.metrics.export.step=2s | |
# All traces should be sent to latency analysis tool | |
management.tracing.sampling.probability=1.0 | |
# OTLP endpoint - OTLP Tempo endpoint | |
management.zipkin.tracing.endpoint=http://localhost:4318/v1/traces | |
management.zipkin.tracing.encoding=PROTO3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$node --test --experimental-test-coverage | |
▶ getUserById | |
✔ should fetch user data successfully (4.168291ms) | |
✔ getUserById (4.678666ms) | |
ℹ tests 1 | |
ℹ suites 1 | |
ℹ pass 1 | |
ℹ fail 0 | |
ℹ cancelled 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DatabaseSync } from "node:sqlite"; | |
const db = new DatabaseSync(":memory:"); | |
db.exec(` | |
CREATE TABLE data( | |
key TEXT PRIMARY KEY, | |
value TEXT | |
) STRICT | |
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pytest --cov=main --cov-report=html | |
================================= test session starts ================================== | |
platform darwin -- Python 3.12.5, pytest-8.3.3, pluggy-1.5.0 | |
rootdir: python-test | |
plugins: time-machine-2.14.2, cov-5.0.0, anyio-4.4.0, Faker-25.2.0 | |
collected 2 items | |
test_main.py .. [100%] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
app = FastAPI() | |
@app.get("/", tags=["Main"]) | |
async def root(): | |
return {"message": "Hello World"} | |
@app.get("/products/{product_id}", tags=["Product"]) | |
async def get_product(product_id: int): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<document> | |
{{WHOLE_DOCUMENT}} | |
</document> | |
Here is the chunk we want to situate within the whole document | |
<chunk> | |
{{CHUNK_CONTENT}} | |
</chunk> | |
Please give a short succinct context to situate this chunk within the overall document | |
for the purposes of improving search retrieval of the chunk. | |
Answer only with the succinct context and nothing else. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ติดตั้ง | |
$pip install -U ell-ai | |
$python -c "import ell; print(ell.__version__)" | |
0.0.4 | |
# ใช้งาน OpenAI | |
$pip install openai | |
$export OPENAI_API_KEY='your-openai-api-key' | |
$python hello.py |