-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
950 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"name": "encre-app", | ||
"version": "0.1.0", | ||
"repository": "https://github.com/VictorS67/encre", | ||
"author": "Encre", | ||
"license": "MIT", | ||
"private": true, | ||
"type": "commonjs", | ||
"packageManager": "[email protected]", | ||
"main": "build/electron/electron.js", | ||
"devDependencies": { | ||
"@atlaskit/eslint-plugin-design-system": "^4.11.2", | ||
"@babel/plugin-proposal-private-property-in-object": "^7.21.11", | ||
"@testing-library/jest-dom": "^6.1.3", | ||
"@testing-library/react": "^14.0.0", | ||
"@types/eslint": "^8.44.2", | ||
"@types/filesystem": "^0.0.33", | ||
"@types/jest": "^29.5.4", | ||
"@types/marked": "^5.0.1", | ||
"@types/node": "^20.6.0", | ||
"@types/react": "^18.2.21", | ||
"@types/react-dom": "^18.2.7", | ||
"@types/ws": "^8.5.5", | ||
"@typescript-eslint/eslint-plugin": "^6.7.0", | ||
"@typescript-eslint/parser": "^6.7.0", | ||
"concurrently": "^8.2.1", | ||
"electron": "^26.3.0", | ||
"eslint": "^8.49.0", | ||
"eslint-cjs-to-esm": "^2.2.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-config-standard-with-typescript": "^39.0.0", | ||
"eslint-import-resolver-typescript": "^3.6.0", | ||
"eslint-plugin-import": "^2.28.1", | ||
"eslint-plugin-n": "^16.1.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"prettier": "^3.0.3", | ||
"react-scripts": "5.0.1", | ||
"recoil-persist": "^5.1.0", | ||
"wait-on": "^7.0.1" | ||
}, | ||
"dependencies": { | ||
"@atlaskit/button": "^16.10.1", | ||
"@atlaskit/css-reset": "^6.5.4", | ||
"@atlaskit/tokens": "^1.25.2", | ||
"@dnd-kit/core": "^6.0.8", | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@floating-ui/react": "^0.26.0", | ||
"@floating-ui/react-dom": "^2.0.2", | ||
"@mui/material": "^5.14.9", | ||
"@mui/icons-material": "^5.14.12", | ||
"@mui/joy": "^5.0.0-beta.8", | ||
"ahooks": "^3.7.8", | ||
"clsx": "^2.0.0", | ||
"langchain": "^0.0.149", | ||
"marked": "^9.0.0", | ||
"openai": "^4.7.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-redux": "^8.1.2", | ||
"recoil": "^0.7.7", | ||
"recoil-persist": "^5.1.0", | ||
"ts-pattern": "^5.0.6", | ||
"tslog": "^4.9.2", | ||
"tsx": "^3.12.10", | ||
"typescript": "^5.2.2", | ||
"web-vitals": "^3.5.0", | ||
"ws": "^8.14.1", | ||
"yaml": "^2.3.2" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject", | ||
"lint": "eslint src/**/*.{ts,tsx} --quiet --fix", | ||
"lint-fix": "eslint --fix src/**/*.{ts,tsx}", | ||
"electron-build": "tsc -p electron/tsconfig.json", | ||
"electron-start": "yarn electron-build && electron .", | ||
"electron-dev": "concurrently \"yarn start\" \"wait-on http://localhost:3000 && yarn electron-start\"" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
...nts/inference/chat/llms/vertexai/gemini/tests/__snapshots__/chat.int.test.ts.snap.example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`test GeminiChat text 1`] = ` | ||
{ | ||
"generations": [ | ||
ChatGenerationChunk { | ||
"info": { | ||
"citationMetadata": undefined, | ||
"completion": 0, | ||
"finishMessage": undefined, | ||
"finishReason": "STOP", | ||
"safetyRatings": [ | ||
{ | ||
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
{ | ||
"category": "HARM_CATEGORY_HATE_SPEECH", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
{ | ||
"category": "HARM_CATEGORY_HARASSMENT", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
{ | ||
"category": "HARM_CATEGORY_DANGEROUS_CONTENT", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
], | ||
}, | ||
"message": { | ||
"_grp": 1, | ||
"_id": [ | ||
"input", | ||
"load", | ||
"msgs", | ||
"BotMessage", | ||
], | ||
"_kwargs": { | ||
"additional_kwargs": {}, | ||
"content": "I am a large language model, trained by Google.", | ||
}, | ||
"_type": "constructor", | ||
}, | ||
"output": "I am a large language model, trained by Google.", | ||
}, | ||
], | ||
"llmOutput": { | ||
"tokenUsage": { | ||
"completionTokens": 12, | ||
"promptTokens": 7, | ||
"totalTokens": 19, | ||
}, | ||
}, | ||
} | ||
`; | ||
|
||
exports[`test GeminiChat vision 1`] = ` | ||
{ | ||
"generations": [ | ||
ChatGenerationChunk { | ||
"info": { | ||
"citationMetadata": undefined, | ||
"completion": 0, | ||
"finishMessage": undefined, | ||
"finishReason": "STOP", | ||
"safetyRatings": [ | ||
{ | ||
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
{ | ||
"category": "HARM_CATEGORY_HATE_SPEECH", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
{ | ||
"category": "HARM_CATEGORY_HARASSMENT", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
{ | ||
"category": "HARM_CATEGORY_DANGEROUS_CONTENT", | ||
"probability": "NEGLIGIBLE", | ||
}, | ||
], | ||
}, | ||
"message": { | ||
"_grp": 1, | ||
"_id": [ | ||
"input", | ||
"load", | ||
"msgs", | ||
"BotMessage", | ||
], | ||
"_kwargs": { | ||
"additional_kwargs": {}, | ||
"content": " An airport departures board.", | ||
}, | ||
"_type": "constructor", | ||
}, | ||
"output": " An airport departures board.", | ||
}, | ||
], | ||
"llmOutput": { | ||
"tokenUsage": { | ||
"completionTokens": 6, | ||
"promptTokens": 266, | ||
"totalTokens": 272, | ||
}, | ||
}, | ||
} | ||
`; |
77 changes: 77 additions & 0 deletions
77
packages/core/src/events/inference/chat/llms/vertexai/gemini/tests/chat.int.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import url from 'url'; | ||
import { HarmBlockThreshold, HarmCategory } from '@google/generative-ai'; | ||
import { expect, test } from '@jest/globals'; | ||
import { HumanMessage } from '../../../../../../input/load/msgs/base.js'; | ||
import { GeminiChat } from '../chat.js'; | ||
|
||
const GOOGLE_API_KEY = 'you_should_get_this_api_from_google_cloud'; | ||
|
||
test('test GeminiChat text', async () => { | ||
const gemini = new GeminiChat({ | ||
googleApiKey: GOOGLE_API_KEY, | ||
modelName: 'gemini-pro', | ||
}); | ||
|
||
const llmResult = await gemini.invoke([ | ||
new HumanMessage('Hello! Who are you?'), | ||
]); | ||
|
||
expect(llmResult).toMatchSnapshot(); | ||
}); | ||
|
||
test('test GeminiChat vision', async () => { | ||
const gemini = new GeminiChat({ | ||
googleApiKey: GOOGLE_API_KEY, | ||
modelName: 'gemini-pro-vision', | ||
}); | ||
|
||
const filePath: string = path.resolve( | ||
path.dirname(url.fileURLToPath(import.meta.url)), | ||
'./examples/timetable.png' | ||
); | ||
|
||
const landmarkImage1 = Buffer.from(fs.readFileSync(filePath).buffer).toString( | ||
'base64' | ||
); | ||
|
||
const message = new HumanMessage({ | ||
content: [ | ||
{ | ||
mimeType: 'image/png', | ||
data: landmarkImage1, | ||
}, | ||
'what is shown in this image?', | ||
], | ||
}); | ||
|
||
const llmResult = await gemini.invoke([message]); | ||
|
||
expect(llmResult).toMatchSnapshot(); | ||
}); | ||
|
||
test('test GeminiChat sexual violation', async () => { | ||
const gemini = new GeminiChat({ | ||
googleApiKey: GOOGLE_API_KEY, | ||
modelName: 'gemini-pro', | ||
}); | ||
|
||
expect( | ||
gemini.invoke( | ||
[ | ||
new HumanMessage( | ||
'I want to have sex with a stranger. Can you help me how to do it?' | ||
), | ||
], | ||
{ | ||
safetySettings: [ | ||
{ | ||
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, | ||
threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, | ||
}, | ||
], | ||
} | ||
) | ||
).rejects.toThrow('The message is blocked because of SAFETY'); | ||
}); |
Oops, something went wrong.