File tree Expand file tree Collapse file tree
frontend/packages/cozeloop Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # @cozeloop/i18n-adapter
1+ # @cozeloop/intl
22
3- I18n For CozeLoop
4-
5- ## Overview
6-
7- This package is part of the Coze Loop monorepo and provides internationalization functionality. It includes adapter.
8-
9- ## Getting Started
10-
11- ### Installation
12-
13- Add this package to your ` package.json ` :
14-
15- ``` json
16- {
17- "dependencies" : {
18- "@cozeloop/i18n-adapter" : " workspace:*"
19- }
20- }
21- ```
22-
23- Then run:
24-
25- ``` bash
26- rush update
27- ```
28-
29- ### Usage
30-
31- ``` typescript
32- import { /* exported functions/components */ } from ' @cozeloop/i18n-adapter' ;
33-
34- // Example usage
35- // TODO: Add specific usage examples
36- ```
37-
38- ## Features
39-
40- - Adapter
41-
42- ## API Reference
43-
44- ### Exports
45-
46- - ` initIntl, I18n `
47-
48-
49- For detailed API documentation, please refer to the TypeScript definitions.
50-
51- ## Development
52-
53- This package is built with:
54-
55- - TypeScript
56- - Modern JavaScript
57- - Vitest for testing
58- - ESLint for code quality
59-
60- ## Contributing
61-
62- This package is part of the Coze Loop monorepo. Please follow the monorepo contribution guidelines.
63-
64- ## License
65-
66- Apache-2.0
3+ Internationalization(intl) runtime for CozeLoop
Original file line number Diff line number Diff line change @@ -86,21 +86,22 @@ export const getInputVariablesFromPrompt = (messageList: Message[]) => {
8686
8787 const result = Array . from ( resultSet ) ;
8888
89- const placeholderArray = messageList . filter (
90- it => it . role === Role . Placeholder ,
91- ) ;
9289 const array : VariableDef [ ] = result . map ( key => ( {
9390 key,
9491 type : VariableType . String ,
9592 } ) ) ;
9693
97- const placeholderContentArray : VariableDef [ ] = placeholderArray
98- ?. filter ( it => {
99- const key = it ?. content ?. replace ( '{{' , '' ) ?. replace ( '}}' , '' ) ;
100- return result . every ( k => k !== key ) ;
101- } )
102- ?. map ( it => ( {
103- key : it ?. content ?. replace ( '{{' , '' ) ?. replace ( '}}' , '' ) ,
94+ const placeholderArray = messageList . filter (
95+ it => it . role === Role . Placeholder ,
96+ ) ;
97+ const placeholderKeys = placeholderArray . map ( it => it ?. content ) ;
98+ const placeholderKeysSet = new Set ( placeholderKeys ) ;
99+ const placeholderKeysArray = Array . from ( placeholderKeysSet ) ;
100+
101+ const placeholderContentArray : VariableDef [ ] = placeholderKeysArray
102+ ?. filter ( key => key && result . every ( k => k !== key ) )
103+ ?. map ( key => ( {
104+ key,
104105 type : VariableType . Placeholder ,
105106 } ) ) ;
106107
You can’t perform that action at this time.
0 commit comments