-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add OpenAI provider with structured output support (#28)
* feat: add OpenAI provider with structured output support Co-Authored-By: Han Xiao <[email protected]> * fix: add @ai-sdk/openai dependency and fix modelConfigs access Co-Authored-By: Han Xiao <[email protected]> * fix: correct indentation in agent.ts Co-Authored-By: Han Xiao <[email protected]> * refactor: centralize model initialization in config.ts Co-Authored-By: Han Xiao <[email protected]> * refactor: improve model config access patterns Co-Authored-By: Han Xiao <[email protected]> * fix: remove unused imports Co-Authored-By: Han Xiao <[email protected]> * refactor: clean up --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Han Xiao <[email protected]>
- Loading branch information
1 parent
f1c7ada
commit 50dff08
Showing
15 changed files
with
271 additions
and
100 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
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
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
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 |
---|---|---|
@@ -1,16 +1,37 @@ | ||
import { dedupQueries } from '../dedup'; | ||
import { LLMProvider } from '../../config'; | ||
|
||
describe('dedupQueries', () => { | ||
it('should remove duplicate queries', async () => { | ||
jest.setTimeout(10000); // Increase timeout to 10s | ||
const queries = ['typescript tutorial', 'typescript tutorial', 'javascript basics']; | ||
const { unique_queries } = await dedupQueries(queries, []); | ||
expect(unique_queries).toHaveLength(2); | ||
expect(unique_queries).toContain('javascript basics'); | ||
const providers: Array<LLMProvider> = ['openai', 'gemini']; | ||
const originalEnv = process.env; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
process.env = { ...originalEnv }; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env = originalEnv; | ||
}); | ||
|
||
it('should handle empty input', async () => { | ||
const { unique_queries } = await dedupQueries([], []); | ||
expect(unique_queries).toHaveLength(0); | ||
providers.forEach(provider => { | ||
describe(`with ${provider} provider`, () => { | ||
beforeEach(() => { | ||
process.env.LLM_PROVIDER = provider; | ||
}); | ||
|
||
it('should remove duplicate queries', async () => { | ||
jest.setTimeout(10000); | ||
const queries = ['typescript tutorial', 'typescript tutorial', 'javascript basics']; | ||
const { unique_queries } = await dedupQueries(queries, []); | ||
expect(unique_queries).toHaveLength(2); | ||
expect(unique_queries).toContain('javascript basics'); | ||
}); | ||
|
||
it('should handle empty input', async () => { | ||
const { unique_queries } = await dedupQueries([], []); | ||
expect(unique_queries).toHaveLength(0); | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import { analyzeSteps } from '../error-analyzer'; | ||
import { LLMProvider } from '../../config'; | ||
|
||
describe('analyzeSteps', () => { | ||
it('should analyze error steps', async () => { | ||
const { response } = await analyzeSteps(['Step 1: Search failed', 'Step 2: Invalid query']); | ||
expect(response).toHaveProperty('recap'); | ||
expect(response).toHaveProperty('blame'); | ||
expect(response).toHaveProperty('improvement'); | ||
const providers: Array<LLMProvider> = ['openai', 'gemini']; | ||
const originalEnv = process.env; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
process.env = { ...originalEnv }; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env = originalEnv; | ||
}); | ||
|
||
providers.forEach(provider => { | ||
describe(`with ${provider} provider`, () => { | ||
beforeEach(() => { | ||
process.env.LLM_PROVIDER = provider; | ||
}); | ||
|
||
it('should analyze error steps', async () => { | ||
const { response } = await analyzeSteps(['Step 1: Search failed', 'Step 2: Invalid query']); | ||
expect(response).toHaveProperty('recap'); | ||
expect(response).toHaveProperty('blame'); | ||
expect(response).toHaveProperty('improvement'); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.