-
Notifications
You must be signed in to change notification settings - Fork 0
[QUO-2017] Polling for detections, cleanup artificats, readme, lint #14
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
Merged
freddiev4
merged 11 commits into
main
from
mike-goitia/feature/quo-2017-parity-with-python-sdk
May 16, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00c7783
add polling, cleanup
mike-goitia 48eac40
readme
mike-goitia cb1cccb
lint and pre commit
mike-goitia f154390
update readme
mike-goitia 4aa1179
feedback
mike-goitia 952300d
cleanup
mike-goitia 6b4df84
update readme
mike-goitia 3567c29
readme
mike-goitia 50c6d12
readme
mike-goitia 27f9f7b
Update logger.ts
freddiev4 5f5e41e
Update README.md
freddiev4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,4 @@ | ||
| #!/usr/bin/env sh | ||
| . "$(dirname -- "$0")/_/husky.sh" | ||
|
|
||
| npx lint-staged |
This file contains hidden or 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,5 @@ | ||
| dist | ||
| node_modules | ||
| build | ||
| coverage | ||
| package-lock.json |
This file contains hidden or 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,8 @@ | ||
| { | ||
| "semi": true, | ||
| "trailingComma": "es5", | ||
| "singleQuote": true, | ||
| "printWidth": 100, | ||
| "tabWidth": 2, | ||
| "endOfLine": "auto" | ||
| } |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,49 +1,54 @@ | ||
| import { QuotientAI } from '../quotientai'; | ||
| import { QuotientAI } from 'quotientai'; | ||
|
|
||
| async function main() { | ||
| const quotient = new QuotientAI(); | ||
| console.log("QuotientAI client initialized") | ||
| const quotient = new QuotientAI(); | ||
| console.log('QuotientAI client initialized'); | ||
|
|
||
| // configure the logger | ||
| const quotient_logger = quotient.logger.init({ | ||
| app_name: "my-app", | ||
| environment: "dev", | ||
| sample_rate: 1.0, | ||
| tags: { model: "gpt-4o", feature: "customer-support" }, | ||
| hallucination_detection: true, | ||
| }) | ||
| // configure the logger | ||
| const quotientLogger = quotient.logger.init({ | ||
| appName: 'my-app', | ||
| environment: 'dev', | ||
| sampleRate: 1.0, | ||
| tags: { model: 'gpt-4o', feature: 'customer-support' }, | ||
| hallucinationDetection: true, | ||
| hallucinationDetectionSampleRate: 1.0, | ||
| }); | ||
|
|
||
| console.log("Logger initialized") | ||
| console.log('Logger initialized'); | ||
|
|
||
| // mock retrieved documents | ||
| const retrieved_documents = [ | ||
| "Sample document 1", | ||
| {"page_content": "Sample document 2", "metadata": {"source": "website.com"}}, | ||
| {"page_content": "Sample document 3"} | ||
| ] | ||
| // mock retrieved documents | ||
| const retrievedDocuments = [ | ||
| 'Sample document 1', | ||
| { pageContent: 'Sample document 2', metadata: { source: 'website.com' } }, | ||
| { pageContent: 'Sample document 3' }, | ||
| ]; | ||
|
|
||
| console.log("Preparing to log with quotient_logger") | ||
| try { | ||
| const response = await quotient_logger.log({ | ||
| user_query: "How do I cook a goose?", | ||
| model_output: "The capital of France is Paris", | ||
| documents: retrieved_documents, | ||
| message_history: [ | ||
| {"role": "system", "content": "You are an expert on geography."}, | ||
| {"role": "user", "content": "What is the capital of France?"}, | ||
| {"role": "assistant", "content": "The capital of France is Paris"}, | ||
| ], | ||
| instructions: [ | ||
| "You are a helpful assistant that answers questions about the world.", | ||
| "Answer the question in a concise manner. If you are not sure, say 'I don't know'.", | ||
| ], | ||
| hallucination_detection: true, | ||
| inconsistency_detection: true, | ||
| }); | ||
| console.log(response.message) | ||
| } catch (error) { | ||
| console.error(error) | ||
| } | ||
| console.log('Preparing to log with quotient_logger'); | ||
| try { | ||
| const logId = await quotientLogger.log({ | ||
| userQuery: 'How do I cook a test?', | ||
| modelOutput: 'The capital of France is Paris', | ||
| documents: retrievedDocuments, | ||
| messageHistory: [ | ||
| { role: 'system', content: 'You are an expert on geography.' }, | ||
| { role: 'user', content: 'What is the capital of France?' }, | ||
| { role: 'assistant', content: 'The capital of France is Paris' }, | ||
| ], | ||
| instructions: [ | ||
| 'You are a helpful assistant that answers questions about the world.', | ||
| "Answer the question in a concise manner. If you are not sure, say 'I don't know'.", | ||
| ], | ||
| hallucinationDetection: true, | ||
| inconsistencyDetection: true, | ||
| }); | ||
| console.log('pollForDetections with logId: ', logId); | ||
|
|
||
| // poll for the detection results | ||
| const detectionResults = await quotientLogger.pollForDetections(logId); | ||
| console.log('detectionResults', detectionResults); | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| } | ||
|
|
||
| main().catch(console.error); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.