Skip to content

Commit dc27192

Browse files
committed
Initial commit
0 parents  commit dc27192

File tree

104 files changed

+11062
-0
lines changed

Some content is hidden

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

104 files changed

+11062
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
3+
{
4+
"name": "Development",
5+
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
6+
"features": {
7+
"ghcr.io/devcontainers/features/node:1": {}
8+
},
9+
"postCreateCommand": "yarn install",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"esbenp.prettier-vscode"
14+
]
15+
}
16+
}
17+
}

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
- next
10+
11+
jobs:
12+
lint:
13+
name: lint
14+
runs-on: ubuntu-latest
15+
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '18'
24+
25+
- name: Bootstrap
26+
run: ./scripts/bootstrap
27+
28+
- name: Check types
29+
run: ./scripts/lint
30+
31+
build:
32+
name: build
33+
runs-on: ubuntu-latest
34+
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- name: Set up Node
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: '18'
43+
44+
- name: Bootstrap
45+
run: ./scripts/bootstrap
46+
47+
- name: Check build
48+
run: ./scripts/build
49+
test:
50+
name: test
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Set up Node
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '18'
60+
61+
- name: Bootstrap
62+
run: ./scripts/bootstrap
63+
64+
- name: Run tests
65+
run: ./scripts/test

.github/workflows/examples.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Run Examples
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch: # Allows manual triggering
9+
schedule:
10+
- cron: '0 * * * *' # every hour
11+
12+
jobs:
13+
chat:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
- name: Install dependencies
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
24+
run: |
25+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
26+
yarn install
27+
- name: Run chat.ts
28+
env:
29+
LLAMA_API_KEY: ${{ secrets.LLAMA_API_KEY }}
30+
run: |
31+
yarn tsn -T examples/chat.ts
32+
33+
structured:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Set up Node
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '18'
41+
- name: Install dependencies
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
44+
run: |
45+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
46+
yarn install
47+
- name: Run structured.ts
48+
env:
49+
LLAMA_API_KEY: ${{ secrets.LLAMA_API_KEY }}
50+
run: |
51+
yarn tsn -T examples/structured.ts
52+
53+
tool_call:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Set up Node
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: '18'
61+
- name: Install dependencies
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
64+
run: |
65+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
66+
yarn install
67+
- name: Run tool_call.ts
68+
env:
69+
LLAMA_API_KEY: ${{ secrets.LLAMA_API_KEY }}
70+
run: |
71+
yarn tsn -T examples/tool_call.ts
72+
73+
vision:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
- name: Set up Node
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: '18'
81+
- name: Install dependencies
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
84+
run: |
85+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
86+
yarn install
87+
- name: Run vision.ts
88+
env:
89+
LLAMA_API_KEY: ${{ secrets.LLAMA_API_KEY }}
90+
run: |
91+
yarn tsn -T examples/vision.ts

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.watchman-cookie*
2+
.prism.log
3+
node_modules
4+
yarn-error.log
5+
codegen.log
6+
Brewfile.lock.json
7+
dist
8+
dist-deno
9+
/*.tgz
10+
.idea/
11+

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG.md
2+
/ecosystem-tests/*/**
3+
/node_modules
4+
/deno
5+
6+
# don't format tsc output, will break source maps
7+
/dist

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "always",
3+
"experimentalTernaries": true,
4+
"printWidth": 110,
5+
"singleQuote": true,
6+
"trailingComma": "all"
7+
}

.stats.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
configured_endpoints: 3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/meta%2Fllama-api-7ff4fcc96829051ab3c627d2a6eb15eae95e2faeceb6af5d69e91c5d01dc8781.yml
3+
openapi_spec_hash: 10455d7d46f2f4c88d427cc7b0a4ebee
4+
config_hash: bc2644b02f8a40dc1cfbb206af1f623d

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
brew "node"

CODE_OF_CONDUCT.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to make participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies within all project spaces, and it also applies when
49+
an individual is representing the project or its community in public spaces.
50+
Examples of representing a project or community include using an official
51+
project e-mail address, posting via an official social media account, or acting
52+
as an appointed representative at an online or offline event. Representation of
53+
a project may be further defined and clarified by project maintainers.
54+
55+
This Code of Conduct also applies outside the project spaces when there is a
56+
reasonable belief that an individual's behavior may have a negative impact on
57+
the project or its community.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported by contacting the project team at <[email protected]>. All
63+
complaints will be reviewed and investigated and will result in a response that
64+
is deemed necessary and appropriate to the circumstances. The project team is
65+
obligated to maintain confidentiality with regard to the reporter of an incident.
66+
Further details of specific enforcement policies may be posted separately.
67+
68+
Project maintainers who do not follow or enforce the Code of Conduct in good
69+
faith may face temporary or permanent repercussions as determined by other
70+
members of the project's leadership.
71+
72+
## Attribution
73+
74+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
75+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
76+
77+
[homepage]: https://www.contributor-covenant.org
78+
79+
For answers to common questions about this code of conduct, see
80+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## Setting up the environment
2+
3+
This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install).
4+
Other package managers may work but are not officially supported for development.
5+
6+
To set up the repository, run:
7+
8+
```sh
9+
$ yarn
10+
$ yarn build
11+
```
12+
13+
This will install all the required dependencies and build output files to `dist/`.
14+
15+
## Modifying/Adding code
16+
17+
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
18+
result in merge conflicts between manual patches and changes from the generator. The generator will never
19+
modify the contents of the `src/lib/` and `examples/` directories.
20+
21+
## Adding and running examples
22+
23+
All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.
24+
25+
```ts
26+
// add an example to examples/<your-example>.ts
27+
28+
#!/usr/bin/env -S npm run tsn -T
29+
30+
```
31+
32+
```sh
33+
$ chmod +x examples/<your-example>.ts
34+
# run the example against your api
35+
$ yarn tsn -T examples/<your-example>.ts
36+
```
37+
38+
## Using the repository from source
39+
40+
If you’d like to use the repository from source, you can either install from git or link to a cloned repository:
41+
42+
To install via git:
43+
44+
```sh
45+
$ npm install git+ssh://[email protected]:meta-llama/llama-api-typescript.git
46+
```
47+
48+
Alternatively, to link a local copy of the repo:
49+
50+
```sh
51+
# Clone
52+
$ git clone https://www.github.com/meta-llama/llama-api-typescript
53+
$ cd llama-api-typescript
54+
55+
# With yarn
56+
$ yarn link
57+
$ cd ../my-package
58+
$ yarn link llama-api-client
59+
60+
# With pnpm
61+
$ pnpm link --global
62+
$ cd ../my-package
63+
$ pnpm link -—global llama-api-client
64+
```
65+
66+
## Running tests
67+
68+
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
69+
70+
```sh
71+
$ npx prism mock path/to/your/openapi.yml
72+
```
73+
74+
```sh
75+
$ yarn run test
76+
```
77+
78+
## Linting and formatting
79+
80+
This repository uses [prettier](https://www.npmjs.com/package/prettier) and
81+
[eslint](https://www.npmjs.com/package/eslint) to format the code in the repository.
82+
83+
To lint:
84+
85+
```sh
86+
$ yarn lint
87+
```
88+
89+
To format and fix all lint issues automatically:
90+
91+
```sh
92+
$ yarn fix
93+
```

0 commit comments

Comments
 (0)