-
Notifications
You must be signed in to change notification settings - Fork 54
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
Sweep(slow): update readme and env example file #21
Comments
Actions (click)
Sandbox Execution ✓Here are the sandbox execution logs prior to making any changes: Sandbox logs for
|
File Path | Proposed Changes |
---|---|
.env.example |
Modify .env.example with contents: • Add the new environment variables that are used in the TypeScript files: - PUBLIC_RIGHT_ALIGN_MY_MSG= - PUBLIC_MIN_MESSAGES= - PUBLIC_MAX_TOKENS= - OPENAI_API_BASE_URL= - OPENAI_API_KEY= - HTTPS_PROXY= - UNDICI_UA= - TRANSCRIPT_TARGET_LANG= - TRANSCRIPT_PROMPT= - SITE_PASSWORD= - DEEPL_AUTH_TOKEN= - TRANSLATE_PROVIDER= - TRANSLATE_TARGET_LANG= - DEEPL_API_HOST= - PROD= - CF_ACCOUNT_ID= - CF_API_TOKEN= - PUBLIC_SECRET_KEY= - PUBLIC_CL100K_BASE_JSON_URL= - PUBLIC_TIKTOKEN_BG_WASM_URL= - OPENAI_API_MODEL= - OPENAI_API_TEMPERATURE= • Make sure to leave the value field blank, as these are placeholders for developers to fill in. |
README.md |
Modify README.md with contents: • Update the table to include the new environment variables that are used in the TypeScript files: - Add an entry for PUBLIC_RIGHT_ALIGN_MY_MSG - Update PUBLIC_SECRET_KEY to SECRET_KEY - Add an entry for PUBLIC_MIN_MESSAGES - Add an entry for PUBLIC_MAX_TOKENS - Add an entry for TRANSCRIPT_TARGET_LANG - Add an entry for TRANSCRIPT_PROMPT - Add an entry for DEEPL_AUTH_TOKEN - Add an entry for TRANSLATE_PROVIDER - Add an entry for TRANSLATE_TARGET_LANG - Add an entry for DEEPL_API_HOST - Add an entry for PROD - Add an entry for CF_ACCOUNT_ID - Add an entry for CF_API_TOKEN - Add an entry for PUBLIC_CL100K_BASE_JSON_URL - Add an entry for PUBLIC_TIKTOKEN_BG_WASM_URL • Each new entry should include the environment variable name, description, and default value similar to the existing entries. |
README.zh-CN.md |
Modify README.zh-CN.md with contents: • Repeat the same updates as for README.md , but the descriptions and text should be in Simplified Chinese.• Update the table to include the new environment variables with appropriate Chinese translations, using the same ordering as in the README.md . |
🎉 Latest improvements to Sweep:
- Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
- Sweep now uses the
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py
!
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Here's the PR! #22. See Sweep's process at dashboard.⚡ Sweep Basic Tier: I'm using GPT-4. You have 3 GPT-4 tickets left for the month and 3 for the day. (tracking ID:
6a2f10b9e9 )For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets). Actions (click)
Sandbox Execution ✓Here are the sandbox execution logs prior to making any changes: Sandbox logs for
|
/// <reference types="astro/client" /> | |
interface ImportMetaEnv { | |
readonly OPENAI_API_KEY: string | |
readonly HTTPS_PROXY: string | |
readonly OPENAI_API_BASE_URL: string | |
readonly HEAD_SCRIPTS: string | |
readonly SECRET_KEY: string | |
readonly SITE_PASSWORD: string | |
readonly OPENAI_API_MODEL: string | |
} | |
interface ImportMeta { | |
readonly env: ImportMetaEnv |
Lines 15 to 30 in 117c9ef
| `OPENAI_API_KEY` | Your API Key for OpenAI. | `null` | | |
| `OPENAI_API_TEMPERATURE` | Default `temperature` parameter for model. | `1.0` | | |
| `HTTPS_PROXY` | Provide proxy for OpenAI API. | `null` | | |
| `OPENAI_API_BASE_URL` | Custom base url for OpenAI API. | `https://api.openai.com` | | |
| `HEAD_SCRIPTS` | Inject analytics or other scripts before `</head>` of the page | `null` | | |
| `PUBLIC_SECRET_KEY` | Secret string for the project. Use for generating signatures for API calls | `null` | | |
| `SITE_PASSWORD` | Set password for site. If not set, site will be public | `null` | | |
| `OPENAI_API_MODEL` | ID of the model to use. [Model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) | `gpt-3.5-turbo-1106` | | |
| `TUTORIAL_MD_URL` | url of the tutorial markdown file | `null` | | |
| `PUBLIC_IFRAME_URL` | url of the advertisement iframe | `null` | | |
| `UNDICI_UA` | user-agent for backend requests | `(forward)` | | |
| `PUBLIC_RIGHT_ALIGN_MY_MSG` | whether user messages should be right-aligned | `null` | | |
| `PUBLIC_CL100K_BASE_JSON_URL` | CDN url for `cl100k_base.json`, such as [file at jsdelivr.net](https://cdn.jsdelivr.net/npm/tiktoken@1.0.10/encoders/cl100k_base.json) | `null` | | |
| `PUBLIC_TIKTOKEN_BG_WASM_URL` | CDN url for `tiktoken_bg.wasm`, such as [file at esm.sh](https://esm.sh/tiktoken/lite/tiktoken_bg.wasm) | `null` | | |
## Contributing |
Lines 1 to 15 in 117c9ef
<h1 align="center">Free Chat</h1> | |
<div align="center">English | <a href="./README.zh-CN.md">简体中文</a></div> | |
<br> | |
> Forked from [chatgpt-demo](https://github.com/anse-app/chatgpt-demo). Find deployment instructions in the original repository. | |
## Environment Variables | |
You can control the website through environment variables. | |
| Name | Description | Default | | |
| --- | --- | --- | | |
| `OPENAI_API_KEY` | Your API Key for OpenAI. | `null` | |
Lines 1 to 15 in 117c9ef
<h1 align="center">Free Chat</h1> | |
<div align="center"><a href="./README.md">English</a> | 简体中文</div> | |
<br> | |
> 源于 [chatgpt-demo](https://github.com/anse-app/chatgpt-demo). 部署方式参见原仓库 | |
## 环境变量 | |
配置本地或者部署的环境变量 | |
| 名称 | 描述 | 默认 | | |
| --- | --- | --- | | |
| `OPENAI_API_KEY` | 你的 OpenAI API Key | `null` | |
Step 2: ⌨️ Coding
- Modify
.env.example
! No changes made
Modify .env.example with contents:
• Search for all instances of `import.meta.env` in the codebase and identify any new environment variables that are not currently listed in the `.env.example` file.
• For each new environment variable, add a line in the `.env.example` file in the format `VARIABLE_NAME=null`. Replace `VARIABLE_NAME` with the name of the environment variable.
- Running GitHub Actions for
.env.example
✗
Check .env.example with contents:
- Modify
README.md
✓ 2b5d6be
Modify README.md with contents:
• For each new environment variable added to the `.env.example` file, add a row to the environment variables table in the `README.md` file.
• Each row should be in the format `| VARIABLE_NAME | Description | null |`. Replace `VARIABLE_NAME` with the name of the environment variable and `Description` with a brief explanation of what the environment variable is used for.
- Running GitHub Actions for
README.md
✓
Check README.md with contents:Ran GitHub Actions for 2b5d6beec2062f01f431115582edade969959f2d:
• Vercel Preview Comments: ✓
- Modify
README.zh-CN.md
! No changes made
Modify README.zh-CN.md with contents:
• For each new environment variable added to the `.env.example` file, add a row to the environment variables table in the `README.zh-CN.md` file.
• Each row should be in the format `| VARIABLE_NAME | 描述 | null |`. Replace `VARIABLE_NAME` with the name of the environment variable and `描述` with a brief explanation (in Simplified Chinese) of what the environment variable is used for.
- Running GitHub Actions for
README.zh-CN.md
✗
Check README.zh-CN.md with contents:
Step 3: 🔁 Code Review
I have finished reviewing the code for completeness. I did not find errors for sweep/update-env-and-readme
.
🎉 Latest improvements to Sweep:
- Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
- Sweep now uses the
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py
!
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord
✨ Track Sweep's progress on the new dashboard.⚡ Sweep Basic Tier: I'm using GPT-4. You have 2 GPT-4 tickets left for the month and 2 for the day. (tracking ID:
e8b27ecaef )For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets). Actions (click)
Sandbox Execution ✓Here are the sandbox execution logs prior to making any changes: Sandbox logs for
|
import { getHeaders } from '@/utils/header' | |
import type { APIRoute } from 'astro' | |
const baseUrl = ((import.meta.env.OPENAI_API_BASE_URL) || 'https://api.openai.com').trim().replace(/\/$/, '') | |
export const post: APIRoute = async(context) => { | |
const headers = getHeaders(context.request) | |
const prompt = '你好。\n\n你好。\n\n你好。\n\n' | |
const formData = new FormData() | |
formData.append('model', 'whisper-1') | |
formData.append('language', import.meta.env.TRANSCRIPT_TARGET_LANG ?? 'zh') | |
formData.append('response_format', 'text') | |
formData.append('prompt', import.meta.env.TRANSCRIPT_PROMPT ?? prompt) | |
formData.append('file', await context.request.blob(), 'file.webm') | |
const text = await fetch(`${baseUrl}/v1/audio/transcriptions`, { method: 'POST', headers, body: formData }).then(res => res.text()) | |
console.error({ text }) | |
return new Response(text.trim(), { headers: { 'Content-Type': 'text/plain' } }) |
free-chat/src/pages/api/translate.ts
Lines 1 to 17 in 117c9ef
import { run } from '../../utils/cf-workers-ai' | |
import type { APIRoute } from 'astro' | |
const deeplAuthKey = import.meta.env.DEEPL_AUTH_TOKEN | |
const useDeepL = deeplAuthKey && import.meta.env.TRANSLATE_PROVIDER !== 'cf' | |
const target_lang = import.meta.env.TRANSLATE_TARGET_LANG ?? (useDeepL ? 'ZH' : 'chinese') | |
export const get: APIRoute = async(context) => { | |
const text = context.url.searchParams.get('text') | |
if (useDeepL) { | |
const host = import.meta.env.DEEPL_API_HOST ?? (deeplAuthKey.endsWith(':fx') ? 'api-free.deepl.com' : 'api.deepl.com') | |
const headers = { 'Authorization': `DeepL-Auth-Key ${deeplAuthKey}`, 'Content-Type': 'application/json' } | |
const { translations: [{ text: translated_text, detected_source_language }] } = await fetch(`https://${host}/v2/translate`, { method: 'POST', headers, body: JSON.stringify({ text: [text], target_lang }) }).then(res => res.json()) | |
return new Response(translated_text, { headers: { 'x-detected-source-language': detected_source_language } }) | |
} | |
const { result: { translated_text } } = await run('@cf/meta/m2m100-1.2b', { text, target_lang }) | |
return new Response(translated_text) |
free-chat/src/utils/cf-workers-ai.ts
Lines 1 to 12 in 117c9ef
export async function run(model: string, input: any) { | |
if (!import.meta.env.CF_ACCOUNT_ID || !import.meta.env.CF_API_TOKEN) throw new Error('cloudflare configuration not found') | |
const res = await fetch( | |
`https://api.cloudflare.com/client/v4/accounts/${import.meta.env.CF_ACCOUNT_ID}/ai/run/${model}`, | |
{ | |
headers: { Authorization: `Bearer ${import.meta.env.CF_API_TOKEN}` }, | |
method: 'POST', | |
body: JSON.stringify(input), | |
}, | |
) | |
return res.json() |
Lines 15 to 30 in 117c9ef
| `OPENAI_API_KEY` | Your API Key for OpenAI. | `null` | | |
| `OPENAI_API_TEMPERATURE` | Default `temperature` parameter for model. | `1.0` | | |
| `HTTPS_PROXY` | Provide proxy for OpenAI API. | `null` | | |
| `OPENAI_API_BASE_URL` | Custom base url for OpenAI API. | `https://api.openai.com` | | |
| `HEAD_SCRIPTS` | Inject analytics or other scripts before `</head>` of the page | `null` | | |
| `PUBLIC_SECRET_KEY` | Secret string for the project. Use for generating signatures for API calls | `null` | | |
| `SITE_PASSWORD` | Set password for site. If not set, site will be public | `null` | | |
| `OPENAI_API_MODEL` | ID of the model to use. [Model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) | `gpt-3.5-turbo-1106` | | |
| `TUTORIAL_MD_URL` | url of the tutorial markdown file | `null` | | |
| `PUBLIC_IFRAME_URL` | url of the advertisement iframe | `null` | | |
| `UNDICI_UA` | user-agent for backend requests | `(forward)` | | |
| `PUBLIC_RIGHT_ALIGN_MY_MSG` | whether user messages should be right-aligned | `null` | | |
| `PUBLIC_CL100K_BASE_JSON_URL` | CDN url for `cl100k_base.json`, such as [file at jsdelivr.net](https://cdn.jsdelivr.net/npm/tiktoken@1.0.10/encoders/cl100k_base.json) | `null` | | |
| `PUBLIC_TIKTOKEN_BG_WASM_URL` | CDN url for `tiktoken_bg.wasm`, such as [file at esm.sh](https://esm.sh/tiktoken/lite/tiktoken_bg.wasm) | `null` | | |
## Contributing |
Step 2: ⌨️ Coding
-
.env.example
Modify .env.example with contents:
• Add the following environment variables to the `.env.example` file: * `OPENAI_API_BASE_URL`: The base URL for the OpenAI API. Default is 'https://api.openai.com'. * `TRANSCRIPT_TARGET_LANG`: The target language for the transcript. Default is 'zh'. * `TRANSCRIPT_PROMPT`: The prompt for the transcript. Default is '你好。\n\n你好。\n\n你好。\n\n'. * `DEEPL_AUTH_TOKEN`: The authentication token for DeepL. * `TRANSLATE_PROVIDER`: The provider for translation. If not 'cf', DeepL is used. * `TRANSLATE_TARGET_LANG`: The target language for translation. Default is 'ZH' for DeepL and 'chinese' for others. * `DEEPL_API_HOST`: The API host for DeepL. Default is 'api-free.deepl.com' if `DEEPL_AUTH_TOKEN` ends with ':fx', otherwise 'api.deepl.com'. * `CF_ACCOUNT_ID`: The account ID for Cloudflare. * `CF_API_TOKEN`: The API token for Cloudflare.
-
README.md
Modify README.md with contents:
• Update the environment variables section in the `README.md` file to include the above-mentioned environment variables along with their descriptions and default values.
Step 3: 🔁 Code Review
Working on it...
🎉 Latest improvements to Sweep:
- Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
- Sweep now uses the
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py
!
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord
Actions (click)
❌ Unable to Complete PRI'm sorry, but it looks like an error has occurred. Try changing the issue description to re-trigger Sweep. If this error persists report it at https://discord.gg/sweep. For bonus GPT-4 tickets, please report this bug on Discord (tracking ID: 🎉 Latest improvements to Sweep:
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. |
Here's the PR! #23. See Sweep's process at dashboard.⚡ Sweep Basic Tier: I'm using GPT-4. You have 5 GPT-4 tickets left for the month and 0 for the day. (tracking ID:
5f1f35acc5 )For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets). Actions (click)
Sandbox Execution ✓Here are the sandbox execution logs prior to making any changes: Sandbox logs for
|
/// <reference types="astro/client" /> | |
interface ImportMetaEnv { | |
readonly OPENAI_API_KEY: string | |
readonly HTTPS_PROXY: string | |
readonly OPENAI_API_BASE_URL: string | |
readonly HEAD_SCRIPTS: string | |
readonly SECRET_KEY: string | |
readonly SITE_PASSWORD: string | |
readonly OPENAI_API_MODEL: string | |
} | |
interface ImportMeta { | |
readonly env: ImportMetaEnv |
Lines 15 to 30 in 117c9ef
| `OPENAI_API_KEY` | Your API Key for OpenAI. | `null` | | |
| `OPENAI_API_TEMPERATURE` | Default `temperature` parameter for model. | `1.0` | | |
| `HTTPS_PROXY` | Provide proxy for OpenAI API. | `null` | | |
| `OPENAI_API_BASE_URL` | Custom base url for OpenAI API. | `https://api.openai.com` | | |
| `HEAD_SCRIPTS` | Inject analytics or other scripts before `</head>` of the page | `null` | | |
| `PUBLIC_SECRET_KEY` | Secret string for the project. Use for generating signatures for API calls | `null` | | |
| `SITE_PASSWORD` | Set password for site. If not set, site will be public | `null` | | |
| `OPENAI_API_MODEL` | ID of the model to use. [Model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility) | `gpt-3.5-turbo-1106` | | |
| `TUTORIAL_MD_URL` | url of the tutorial markdown file | `null` | | |
| `PUBLIC_IFRAME_URL` | url of the advertisement iframe | `null` | | |
| `UNDICI_UA` | user-agent for backend requests | `(forward)` | | |
| `PUBLIC_RIGHT_ALIGN_MY_MSG` | whether user messages should be right-aligned | `null` | | |
| `PUBLIC_CL100K_BASE_JSON_URL` | CDN url for `cl100k_base.json`, such as [file at jsdelivr.net](https://cdn.jsdelivr.net/npm/tiktoken@1.0.10/encoders/cl100k_base.json) | `null` | | |
| `PUBLIC_TIKTOKEN_BG_WASM_URL` | CDN url for `tiktoken_bg.wasm`, such as [file at esm.sh](https://esm.sh/tiktoken/lite/tiktoken_bg.wasm) | `null` | | |
## Contributing |
Step 2: ⌨️ Coding
- Modify
.env.example
✓ c86c8b3
Modify .env.example with contents:
• Search for `import.meta.env` in the codebase to identify any new environment variables.
• For each new environment variable, add a new line in the `.env.example` file with the format `VARIABLE_NAME=placeholder_value`. The placeholder value should be a generic value that indicates the expected type of the real value.
- Running GitHub Actions for
.env.example
✓
Check .env.example with contents:Ran GitHub Actions for c86c8b35f9da0d556bfab3658f49e50b400c7051:
• Vercel Preview Comments: ✓
- Modify
README.md
✓ 892358b
Modify README.md with contents:
• For each new environment variable, add a new row in the environment variables table in the `README.md` file. The row should contain the variable name, a description of its purpose, and its default value if any. The description can be obtained from the comments in the `src/env.d.ts` file or inferred from the variable name and its usage in the code.
- Running GitHub Actions for
README.md
✓
Check README.md with contents:Ran GitHub Actions for 892358b8ef9a20bf5c93ccebab060516830ac4a3:
• Vercel Preview Comments: ✓
- Modify
src/env.d.ts
✓ 3ee2206
Modify src/env.d.ts with contents:
• For each new environment variable, add a new line in the `ImportMetaEnv` interface in the `src/env.d.ts` file with the format `readonly VARIABLE_NAME: string`. This ensures that the TypeScript compiler recognizes the new environment variables.
- Running GitHub Actions for
src/env.d.ts
✓
Check src/env.d.ts with contents:Ran GitHub Actions for 3ee2206f813410e0a7e76e035d57b3102c9eba53:
• Vercel Preview Comments: ✓
Step 3: 🔁 Code Review
I have finished reviewing the code for completeness. I did not find errors for sweep/update-env-vars
.
🎉 Latest improvements to Sweep:
- Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
- Sweep now uses the
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py
!
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord
Details
There are some new env usages inside the code. Please search
import.meta.env
and update related information inside.env.example
andREADME*
files.Checklist
.env.example
✓ c86c8b3.env.example
✓README.md
✓ 892358bREADME.md
✓src/env.d.ts
✓ 3ee2206src/env.d.ts
✓The text was updated successfully, but these errors were encountered: