-
Notifications
You must be signed in to change notification settings - Fork 132
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
github models support #600
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: github models smoke tests | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- yarn.lock | ||
- ".github/workflows/github-models.yml" | ||
- "packages/core/**/*" | ||
- "packages/cli/**/*" | ||
- "packages/samples/**/*" | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- yarn.lock | ||
- ".github/workflows/github-models.yml" | ||
- "packages/core/**/*" | ||
- "packages/cli/**/*" | ||
- "packages/samples/**/*" | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-github-models | ||
cancel-in-progress: true | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: "recursive" | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
cache: yarn | ||
- run: yarn install --frozen-lockfile | ||
- name: typecheck | ||
run: yarn typecheck | ||
- name: compile | ||
run: yarn compile | ||
- name: run summarize github-gpt4o | ||
run: yarn test:summarize --model github:gpt-4o --out ./temp | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,51 @@ GENAISCRIPT_DEFAULT_MODEL=openai:gpt-4o | |
|
||
::: | ||
|
||
## GitHub Models | ||
<a id="github" href=""></a> | ||
|
||
The [GitHub Models](https://github.com/marketplace/models) provider, `github`, allows running models through the GitHub Marketplace. | ||
This provider is useful for prototyping and subject to [rate limits](https://docs.github.com/en/github-models/prototyping-with-ai-models#rate-limits) | ||
depending on your subscription. | ||
|
||
<Steps> | ||
|
||
<ol> | ||
|
||
<li> | ||
|
||
Open the [GitHub Marketplace](https://github.com/marketplace/models) and find the model you want to use. | ||
|
||
</li> | ||
|
||
<li> | ||
|
||
Click **Get Started** and follow the instructions to configure the github token, or start a codespace! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The instruction "Click Get Started and follow the instructions to configure the github token, or start a codespace!" is ambiguous. It should clarify whether configuring the GitHub token and starting a codespace are two separate options or part of the same process.
|
||
|
||
</li> | ||
|
||
<li> | ||
|
||
Copy the model name from the Javascript/Python samples | ||
|
||
```js "Phi-3-mini-4k-instruct" | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const modelName = "Phi-3-mini-4k-instruct"; | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code block is incorrectly annotated with "js" and a string "Phi-3-mini-4k-instruct" which seems to be a mistake. The code block should only specify the language (js) without the model name string.
|
||
|
||
to configure your script. | ||
|
||
```js | ||
script({ | ||
model: "github:Phi-3-mini-4k-instruct" | ||
}) | ||
``` | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</li> | ||
|
||
</ol> | ||
|
||
</Steps> | ||
|
||
## Azure OpenAI | ||
<a id="azure" href=""></a> | ||
|
||
|
@@ -269,7 +314,7 @@ script({ | |
|
||
</Steps> | ||
|
||
## GitHub Copilot Models | ||
## GitHub Copilot in Visual Studio Code | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The section title "GitHub Copilot Models" has been changed to "GitHub Copilot in Visual Studio Code" which might imply a change in content scope or focus. Ensure that the content of the section aligns with the new title.
|
||
|
||
If you have access to **GitHub Copilot in Visual Studio Code**, | ||
GenAIScript will be able to leverage those [language models](https://code.visualstudio.com/api/extension-guides/language-model) as well. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,21 @@ import { | |
DEFAULT_TEMPERATURE, | ||
DOCS_CONFIGURATION_AICI_URL, | ||
DOCS_CONFIGURATION_AZURE_OPENAI_URL, | ||
DOCS_CONFIGURATION_GITHUB_URL, | ||
DOCS_CONFIGURATION_LITELLM_URL, | ||
DOCS_CONFIGURATION_LLAMAFILE_URL, | ||
DOCS_CONFIGURATION_LOCALAI_URL, | ||
DOCS_CONFIGURATION_OLLAMA_URL, | ||
DOCS_CONFIGURATION_OPENAI_URL, | ||
DOT_ENV_FILENAME, | ||
GITHUB_MODELS_BASE, | ||
LITELLM_API_BASE, | ||
LLAMAFILE_API_BASE, | ||
LOCALAI_API_BASE, | ||
MODEL_PROVIDER_AICI, | ||
MODEL_PROVIDER_AZURE, | ||
MODEL_PROVIDER_CLIENT, | ||
MODEL_PROVIDER_GITHUB, | ||
MODEL_PROVIDER_LITELLM, | ||
MODEL_PROVIDER_LLAMAFILE, | ||
MODEL_PROVIDER_OLLAMA, | ||
|
@@ -99,6 +102,24 @@ export async function parseTokenFromEnv( | |
} | ||
} | ||
|
||
if (provider === MODEL_PROVIDER_GITHUB) { | ||
const token = env.GITHUB_TOKEN | ||
if (!token) throw new Error("GITHUB_TOKEN must be set") | ||
const type = "openai" | ||
const base = GITHUB_MODELS_BASE | ||
return { | ||
provider, | ||
model, | ||
base, | ||
type, | ||
token, | ||
source: "env: GITHUB_TOKEN", | ||
curlHeaders: { | ||
Authorization: `Bearer $GITHUB_TOKEN`, | ||
|
||
}, | ||
} | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
if (provider === MODEL_PROVIDER_AZURE) { | ||
const tokenVar = env.AZURE_OPENAI_API_KEY | ||
? "AZURE_OPENAI_API_KEY" | ||
|
@@ -298,6 +319,16 @@ OPENAI_API_TYPE="localai" | |
model: `${MODEL_PROVIDER_OPENAI}:gpt-3.5-turbo`, | ||
} | ||
|
||
if (provider === MODEL_PROVIDER_GITHUB) | ||
return { | ||
config: ` | ||
## GitHub Models ${DOCS_CONFIGURATION_GITHUB_URL} | ||
# use "${MODEL_PROVIDER_GITHUB}:<model>" in script({ model: ... }) | ||
GITHUB_TOKEN="${PLACEHOLDER_API_KEY}" | ||
`, | ||
model: `${MODEL_PROVIDER_GITHUB}:gpt-4o`, | ||
} | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The string
|
||
|
||
return { | ||
config: ` | ||
## OpenAI ${DOCS_CONFIGURATION_OPENAI_URL} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link provided for "GitHub Models" does not have a URL, it should point to the actual resource.