Skip to content

feat: add coze-api#5

Open
jackshen310 wants to merge 4 commits into
mainfrom
feat/coze-api
Open

feat: add coze-api#5
jackshen310 wants to merge 4 commits into
mainfrom
feat/coze-api

Conversation

@jackshen310

Copy link
Copy Markdown
Collaborator

add coze openapi js sdk

Comment thread packages/coze-js/README.md Outdated
const v = await coze.chatV3Streaming({
const v = await client.chat.stream({
bot_id: botId,
user_id: '123***',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_id 不要做成必填。没传的话,给个默认值或取用户的真实 id

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件这么写也没啥用吧,Disallow 后面为空时,表示所有页面都允许被爬取

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是 create-react-app 生成的,我去掉也行

Comment thread packages/coze-js/README.md Outdated

const client = new CozeAPI({
token: 'your_token',
baseURL: 'https://api.coze.com',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 Readme 补充下:如果是中文,这里要使用 .cn

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考python sdk,提供两个常量:
const client = new CozeAPI({
token: 'your_token',
baseURL: COZE_COM_BASE_URL, // you can change to COZE_CN_BASE_URL
});

Comment thread packages/coze-js/src/fetcher.ts Outdated
adapter: options.isStreaming ? 'fetch' : undefined,
...options,
}).catch(error => {
console.log('fetchAPIerror', error);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.error ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Comment thread packages/coze-js/src/auth.ts Outdated
return `${baseUrl}/api/permission/oauth2/authorize?${params.toString()}`;
};

export const getPKCEAuthenticationUrl = async (config: {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config 等这些参数类型抽出来好些吧?export 出去,开发者使用的时候更方便些

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下同。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment thread packages/coze-js/src/constant.ts Outdated
@@ -0,0 +1 @@
export const DEFAULT_BASE_URL = 'https://api.coze.com';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.cn 也定义进来?使用的时候直接引用这两个就好

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jackshen310 jackshen310 changed the base branch from chore/setup-rush to main October 29, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants