-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fixes dev-ui-gallery sample (#1051)
- Loading branch information
1 parent
565404f
commit 8c5d2dd
Showing
8 changed files
with
149 additions
and
124 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,132 @@ | ||
/** | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { devLocalVectorstore } from '@genkit-ai/dev-local-vectorstore'; | ||
import { genkitEval, GenkitMetric } from '@genkit-ai/evaluator'; | ||
import { geminiPro, googleAI } from '@genkit-ai/googleai'; | ||
import { | ||
claude3Haiku, | ||
claude3Opus, | ||
claude3Sonnet, | ||
textEmbeddingGecko, | ||
vertexAI, | ||
VertexAIEvaluationMetricType, | ||
} from '@genkit-ai/vertexai'; | ||
import { dotprompt, genkit } from 'genkit'; | ||
import { chroma } from 'genkitx-chromadb'; | ||
import { ollama } from 'genkitx-ollama'; | ||
import { pinecone } from 'genkitx-pinecone'; | ||
|
||
// Turn off safety checks for evaluation so that the LLM as an evaluator can | ||
// respond appropriately to potentially harmful content without error. | ||
export const PERMISSIVE_SAFETY_SETTINGS: any = { | ||
safetySettings: [ | ||
{ | ||
category: 'HARM_CATEGORY_HATE_SPEECH', | ||
threshold: 'BLOCK_NONE', | ||
}, | ||
{ | ||
category: 'HARM_CATEGORY_DANGEROUS_CONTENT', | ||
threshold: 'BLOCK_NONE', | ||
}, | ||
{ | ||
category: 'HARM_CATEGORY_HARASSMENT', | ||
threshold: 'BLOCK_NONE', | ||
}, | ||
{ | ||
category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT', | ||
threshold: 'BLOCK_NONE', | ||
}, | ||
], | ||
}; | ||
|
||
export const ai = genkit({ | ||
// load at least one plugin representing each action type | ||
plugins: [ | ||
// model providers | ||
googleAI({ | ||
apiVersion: ['v1', 'v1beta'], | ||
}), | ||
ollama({ | ||
models: [ | ||
{ name: 'llama2' }, | ||
{ name: 'llama3' }, | ||
{ | ||
name: 'gemma', | ||
type: 'generate', | ||
}, | ||
], | ||
serverAddress: 'http://127.0.0.1:11434', // default local address | ||
}), | ||
vertexAI({ | ||
location: 'us-central1', | ||
modelGardenModels: [claude3Haiku, claude3Sonnet, claude3Opus], | ||
evaluation: { | ||
metrics: [ | ||
VertexAIEvaluationMetricType.BLEU, | ||
VertexAIEvaluationMetricType.GROUNDEDNESS, | ||
VertexAIEvaluationMetricType.SAFETY, | ||
{ | ||
type: VertexAIEvaluationMetricType.ROUGE, | ||
metricSpec: { | ||
rougeType: 'rougeLsum', | ||
useStemmer: true, | ||
splitSummaries: 'true', | ||
}, | ||
}, | ||
], | ||
}, | ||
}), | ||
|
||
// vector stores | ||
chroma([ | ||
{ | ||
collectionName: 'chroma-collection', | ||
embedder: textEmbeddingGecko, | ||
embedderOptions: { taskType: 'RETRIEVAL_DOCUMENT' }, | ||
}, | ||
]), | ||
devLocalVectorstore([ | ||
{ | ||
indexName: 'naive-index', | ||
embedder: textEmbeddingGecko, | ||
embedderOptions: { taskType: 'RETRIEVAL_DOCUMENT' }, | ||
}, | ||
]), | ||
pinecone([ | ||
{ | ||
indexId: 'pinecone-index', | ||
embedder: textEmbeddingGecko, | ||
embedderOptions: { taskType: 'RETRIEVAL_DOCUMENT' }, | ||
}, | ||
]), | ||
|
||
// evaluation | ||
genkitEval({ | ||
judge: geminiPro, | ||
judgeConfig: PERMISSIVE_SAFETY_SETTINGS, | ||
embedder: textEmbeddingGecko, | ||
metrics: [ | ||
GenkitMetric.ANSWER_RELEVANCY, | ||
GenkitMetric.FAITHFULNESS, | ||
GenkitMetric.MALICIOUSNESS, | ||
], | ||
}), | ||
|
||
// prompt files | ||
dotprompt({ dir: './prompts' }), | ||
], | ||
}); |
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
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
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
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
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