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

Add OpenAI CLI example #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
46 changes: 44 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": true,
}
"eslint.format.enable": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"eslint.validate": ["markdown", "javascript", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
},
"editor.acceptSuggestionOnCommitCharacter": true,
"editor.acceptSuggestionOnEnter": "on",
"editor.quickSuggestionsDelay": 10,
"editor.suggestOnTriggerCharacters": true,
"editor.tabCompletion": "off",
"editor.suggest.localityBonus": true,
"editor.suggestSelection": "recentlyUsed",
"editor.wordBasedSuggestions": "matchingDocuments",
"editor.parameterHints.enabled": true,
"files.watcherExclude": {
"**/target": true
},
"files.insertFinalNewline": true
}
1 change: 1 addition & 0 deletions cli-openai/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
79 changes: 79 additions & 0 deletions cli-openai/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable no-undef */
module.exports = {
ignorePatterns: ["dist", "*.mjs", "docs", "*.md"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module"
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
typescript: {
alwaysTryTypes: true
}
}
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@effect/recommended"
],
plugins: ["deprecation", "import", "sort-destructure-keys", "simple-import-sort", "codegen"],
rules: {
"codegen/codegen": "error",
"no-fallthrough": "off",
"no-irregular-whitespace": "off",
"object-shorthand": "error",
"prefer-destructuring": "off",
"sort-imports": "off",
"no-unused-vars": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"import/first": "error",
"import/no-cycle": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/order": "off",
"simple-import-sort/imports": "off",
"sort-destructure-keys/sort-destructure-keys": "error",
"deprecation/deprecation": "off",
"@typescript-eslint/array-type": ["warn", { "default": "generic", "readonly": "generic" }],
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",
"@effect/dprint": [
"error",
{
config: {
"indentWidth": 2,
"lineWidth": 100,
"semiColons": "asi",
"quoteStyle": "alwaysDouble",
"trailingCommas": "never",
"operatorPosition": "maintain",
"arrowFunction.useParentheses": "force"
}
}
]
}
}
12 changes: 12 additions & 0 deletions cli-openai/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
coverage/
*.tsbuildinfo
node_modules/
.DS_Store
tmp/
dist/
.direnv/
.env
*.sqlite
*.sqlite-shm
*.sqlite-wal
tempo-data/
3 changes: 3 additions & 0 deletions cli-openai/.gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tasks:
- name: Install Packages
init: pnpm install
21 changes: 21 additions & 0 deletions cli-openai/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-present The Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions cli-openai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[![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)

# Effect OpenAI

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.

## Get the Code

There are three primary methods which you can use to get access to this project:

| Method | Description |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| Clone Locally | Clone the project locally (optionally use Nix to install dependencies) |
| [![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/) |
| [![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/) |
49 changes: 49 additions & 0 deletions cli-openai/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.9"

services:
# Grafana
grafana:
image: grafana/grafana:10.2.3
container_name: grafana
deploy:
resources:
limits:
memory: 100M
environment:
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
volumes:
- ./infra/grafana/grafana.ini:/etc/grafana/grafana.ini
- ./infra/grafana/datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yml
- ./infra/grafana/dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yml
- ./infra/grafana/dashboards:/etc/dashboards
ports:
- 30001:3000

# Prometheus
prometheus:
image: prom/prometheus:latest
container_name: prometheus
command:
- --config.file=/etc/prometheus.yaml
- --web.enable-remote-write-receiver
- --enable-feature=exemplar-storage
volumes:
- ./infra/prometheus/prometheus.yaml:/etc/prometheus.yaml
ports:
- 9090:9090

tempo:
image: grafana/tempo:latest
command: ["-config.file=/etc/tempo.yml"]
volumes:
- ./infra/tempo/tempo.yaml:/etc/tempo.yml
- ./tempo-data:/tmp/tempo
ports:
- "14268:14268" # jaeger ingest
- "3200:3200" # tempo
- "9095:9095" # tempo grpc
- "4317:4317" # otlp grpc
- "4318:4318" # otlp http
- "9411:9411" # zipkin
Loading