-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: port generate() and ollama integration from PR #73 #154
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
29ffa95
6fce59d
96cf24c
e70fd07
47309c1
6fd6ac3
697c298
61c8b4d
8a24fe4
63a3458
67ac3eb
7f165ed
9f2a96b
ab4e577
d9c56c7
6b8bee8
92818cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Code Quality Reviewer Prompt Template | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Implementer Prompt Template | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Spec Reviewer Prompt Template | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| - [ ] Implement `src/ai.ts` and `test/ai.test.ts` | ||
| - [ ] Create `test/ai.test.ts` with content from `.opencode/pr_content/test/ai.test.ts` (but corrected paths) | ||
| - [ ] Create `src/ai.ts` with basic scaffolding | ||
| - [ ] Implement `detectProvider` logic | ||
| - [ ] Implement `generate` logic | ||
| - [ ] Implement `generateWithSchemaValidation` logic | ||
| - [ ] Implement helpers (`simplifySchemaForOllama`, `fileToImagePart`, etc.) | ||
| - [ ] Verify with tests | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { z } from "zod"; | ||
| export declare const DEFAULT_MODEL = "ollama/qwen3:4b"; | ||
| export declare const MAX_SCHEMA_VALIDATION_RETRIES = 3; | ||
| /** | ||
| * Maps our supported model enums to the model identifiers that platforms expect. | ||
| */ | ||
| export declare const modelMap: Record<string, string>; | ||
| interface DetectedProvider { | ||
| provider: "openai" | "anthropic" | "google" | "ollama" | null; | ||
| model: string | null; | ||
| apiKey?: string | null; | ||
| baseURL?: string; | ||
| } | ||
| /** | ||
| * Detects the provider, model, and API from a model string and environment variables. | ||
| */ | ||
| export declare const detectProvider: (config: any, model: string) => Promise<DetectedProvider>; | ||
| /** | ||
| * Simplifies a JSON schema for providers with limited schema support (e.g., Ollama). | ||
| * - Dereferences $ref pointers | ||
| * - Merges allOf schemas | ||
| * - Converts top-level anyOf (discriminated unions) into a single object with all options as optional properties | ||
| * - Simplifies nested anyOf by preferring object types | ||
| * - Removes unsupported keywords like pattern, components, etc. | ||
| */ | ||
| export declare const simplifySchemaForOllama: (schema: any) => any; | ||
| /** | ||
| * Extracts the API key for a provider from a Doc Detective config object. | ||
| */ | ||
| export declare const getApiKey: (config: any, provider: "openai" | "anthropic" | "google") => any; | ||
| export interface GenerateOptions { | ||
| prompt?: string; | ||
| messages?: any[]; | ||
| files?: any[]; | ||
| model?: string; | ||
| system?: string; | ||
| schema?: z.ZodSchema | any; | ||
| schemaName?: string; | ||
| schemaDescription?: string; | ||
| provider?: "openai" | "anthropic" | "ollama" | "google"; | ||
| config?: any; | ||
| apiKey?: string; | ||
| baseURL?: string; | ||
| temperature?: number; | ||
| maxTokens?: number; | ||
| } | ||
| /** | ||
| * Generates text or structured output using an AI model. | ||
| */ | ||
| export declare const generate: ({ prompt, messages, files, model, system, schema, schemaName, schemaDescription, provider, config, apiKey, baseURL, temperature, maxTokens, }: GenerateOptions) => Promise<{ | ||
| object: any; | ||
| usage: import("ai").LanguageModelUsage; | ||
| finishReason: import("ai").FinishReason; | ||
| } | { | ||
| text: string; | ||
| usage: import("ai").LanguageModelUsage; | ||
| finishReason: import("ai").FinishReason; | ||
| }>; | ||
| export {}; | ||
| //# sourceMappingURL=ai.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder file with no actual content.
This file contains only a title with no actual prompt template content. If this is intentional scaffolding for future work, consider adding a TODO comment or removing until the actual content is ready. If the content was meant to be included, please add the complete prompt template.
🤖 Prompt for AI Agents