Skip to content

Commit 339e7af

Browse files
committed
add openai cli example
1 parent 27cb78e commit 339e7af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+9746
-21
lines changed

.vscode/settings.json

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"typescript.preferences.importModuleSpecifier": "non-relative",
4+
"typescript.enablePromptUseWorkspaceTsdk": true,
45
"editor.formatOnSave": true,
5-
}
6+
"eslint.format.enable": true,
7+
"[json]": {
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
},
10+
"[markdown]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
},
13+
"[javascript]": {
14+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
15+
},
16+
"[javascriptreact]": {
17+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
18+
},
19+
"[typescript]": {
20+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
21+
},
22+
"[typescriptreact]": {
23+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
24+
},
25+
"eslint.validate": ["markdown", "javascript", "typescript"],
26+
"editor.codeActionsOnSave": {
27+
"source.fixAll.eslint": "explicit"
28+
},
29+
"editor.quickSuggestions": {
30+
"other": true,
31+
"comments": false,
32+
"strings": false
33+
},
34+
"editor.acceptSuggestionOnCommitCharacter": true,
35+
"editor.acceptSuggestionOnEnter": "on",
36+
"editor.quickSuggestionsDelay": 10,
37+
"editor.suggestOnTriggerCharacters": true,
38+
"editor.tabCompletion": "off",
39+
"editor.suggest.localityBonus": true,
40+
"editor.suggestSelection": "recentlyUsed",
41+
"editor.wordBasedSuggestions": "matchingDocuments",
42+
"editor.parameterHints.enabled": true,
43+
"files.watcherExclude": {
44+
"**/target": true
45+
},
46+
"files.insertFinalNewline": true
47+
}

cli-openai/.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

cli-openai/.eslintrc.cjs

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* eslint-disable no-undef */
2+
module.exports = {
3+
ignorePatterns: ["dist", "*.mjs", "docs", "*.md"],
4+
parser: "@typescript-eslint/parser",
5+
parserOptions: {
6+
ecmaVersion: 2018,
7+
sourceType: "module"
8+
},
9+
settings: {
10+
"import/parsers": {
11+
"@typescript-eslint/parser": [".ts", ".tsx"]
12+
},
13+
"import/resolver": {
14+
typescript: {
15+
alwaysTryTypes: true
16+
}
17+
}
18+
},
19+
extends: [
20+
"eslint:recommended",
21+
"plugin:@typescript-eslint/eslint-recommended",
22+
"plugin:@typescript-eslint/recommended",
23+
"plugin:@effect/recommended"
24+
],
25+
plugins: ["deprecation", "import", "sort-destructure-keys", "simple-import-sort", "codegen"],
26+
rules: {
27+
"codegen/codegen": "error",
28+
"no-fallthrough": "off",
29+
"no-irregular-whitespace": "off",
30+
"object-shorthand": "error",
31+
"prefer-destructuring": "off",
32+
"sort-imports": "off",
33+
"no-unused-vars": "off",
34+
"prefer-rest-params": "off",
35+
"prefer-spread": "off",
36+
"import/first": "error",
37+
"import/no-cycle": "error",
38+
"import/newline-after-import": "error",
39+
"import/no-duplicates": "error",
40+
"import/no-unresolved": "off",
41+
"import/order": "off",
42+
"simple-import-sort/imports": "off",
43+
"sort-destructure-keys/sort-destructure-keys": "error",
44+
"deprecation/deprecation": "off",
45+
"@typescript-eslint/array-type": ["warn", { "default": "generic", "readonly": "generic" }],
46+
"@typescript-eslint/member-delimiter-style": 0,
47+
"@typescript-eslint/no-non-null-assertion": "off",
48+
"@typescript-eslint/ban-types": "off",
49+
"@typescript-eslint/no-explicit-any": "off",
50+
"@typescript-eslint/no-empty-interface": "off",
51+
"@typescript-eslint/consistent-type-imports": "warn",
52+
"@typescript-eslint/no-unused-vars": ["error", {
53+
"argsIgnorePattern": "^_",
54+
"varsIgnorePattern": "^_"
55+
}],
56+
"@typescript-eslint/ban-ts-comment": "off",
57+
"@typescript-eslint/camelcase": "off",
58+
"@typescript-eslint/explicit-function-return-type": "off",
59+
"@typescript-eslint/explicit-module-boundary-types": "off",
60+
"@typescript-eslint/interface-name-prefix": "off",
61+
"@typescript-eslint/no-array-constructor": "off",
62+
"@typescript-eslint/no-use-before-define": "off",
63+
"@typescript-eslint/no-namespace": "off",
64+
"@effect/dprint": [
65+
"error",
66+
{
67+
config: {
68+
"indentWidth": 2,
69+
"lineWidth": 100,
70+
"semiColons": "asi",
71+
"quoteStyle": "alwaysDouble",
72+
"trailingCommas": "never",
73+
"operatorPosition": "maintain",
74+
"arrowFunction.useParentheses": "force"
75+
}
76+
}
77+
]
78+
}
79+
}

cli-openai/.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
coverage/
2+
*.tsbuildinfo
3+
node_modules/
4+
.DS_Store
5+
tmp/
6+
dist/
7+
.direnv/
8+
.env
9+
*.sqlite
10+
*.sqlite-shm
11+
*.sqlite-wal
12+
tempo-data/

cli-openai/.gitpod.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tasks:
2+
- name: Install Packages
3+
init: pnpm install

cli-openai/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020-present The Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

cli-openai/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[![Open in Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/Effect-TS/effect-openai)
2+
3+
# Effect OpenAI
4+
5+
An OpenAI client written with Effect which demonstrates many of the concepts that will be reviewed during the Advanced Effect Workshop and Effect Days Vienna 2024.
6+
7+
## Get the Code
8+
9+
There are three primary methods which you can use to get access to this project:
10+
11+
| Method | Description |
12+
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
13+
| Clone Locally | Clone the project locally (optionally use Nix to install dependencies) |
14+
| [![Open in Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/IMax153/effect-openai) | Open the project in [Gitpod](https://gitpod.io/) |
15+
| [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/IMax153/effect-openai) | Open the project in [Stackblitz](https://stackblitz.com/) |

cli-openai/docker-compose.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: "3.9"
2+
3+
services:
4+
# Grafana
5+
grafana:
6+
image: grafana/grafana:10.2.3
7+
container_name: grafana
8+
deploy:
9+
resources:
10+
limits:
11+
memory: 100M
12+
environment:
13+
- GF_AUTH_ANONYMOUS_ENABLED=true
14+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
15+
- GF_AUTH_DISABLE_LOGIN_FORM=true
16+
volumes:
17+
- ./infra/grafana/grafana.ini:/etc/grafana/grafana.ini
18+
- ./infra/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yml
19+
- ./infra/grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yml
20+
- ./infra/grafana/dashboards:/etc/dashboards
21+
ports:
22+
- 30001:3000
23+
24+
# Prometheus
25+
prometheus:
26+
image: prom/prometheus:latest
27+
container_name: prometheus
28+
command:
29+
- --config.file=/etc/prometheus.yaml
30+
- --web.enable-remote-write-receiver
31+
- --enable-feature=exemplar-storage
32+
volumes:
33+
- ./infra/prometheus/prometheus.yaml:/etc/prometheus.yaml
34+
ports:
35+
- 9090:9090
36+
37+
tempo:
38+
image: grafana/tempo:latest
39+
command: ["-config.file=/etc/tempo.yml"]
40+
volumes:
41+
- ./infra/tempo/tempo.yaml:/etc/tempo.yml
42+
- ./tempo-data:/tmp/tempo
43+
ports:
44+
- "14268:14268" # jaeger ingest
45+
- "3200:3200" # tempo
46+
- "9095:9095" # tempo grpc
47+
- "4317:4317" # otlp grpc
48+
- "4318:4318" # otlp http
49+
- "9411:9411" # zipkin

0 commit comments

Comments
 (0)