Skip to content
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

add insert support to generate endpoint #113

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ollama.generate(request)
- `request` `<Object>`: The request object containing generate parameters.
- `model` `<string>` The name of the model to use for the chat.
- `prompt` `<string>`: The prompt to send to the model.
- `suffix` `<string>`: (Optional) Suffix is the text that comes after the inserted text.
- `system` `<string>`: (Optional) Override the model system prompt.
- `template` `<string>`: (Optional) Override the model template.
- `raw` `<boolean>`: (Optional) Bypass the prompt template and pass the prompt directly to the model.
Expand Down
18 changes: 3 additions & 15 deletions examples/fill-in-middle/fill.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import ollama from 'ollama'

const prefix = `def remove_non_ascii(s: str) -> str:
"""
`
const suffix = `
return result
`
const response = await ollama.generate({
model: 'codellama:7b-code',
prompt: `<PRE> ${prefix} <SUF>${suffix} <MID>`,
options: {
num_predict: 128,
temperature: 0,
top_p: 0.9,
presence_penalty: 0,
stop: ['<EOT>'],
},
model: 'deepseek-coder-v2',
prompt: `def add(`,
suffix: `return c`,
})
console.log(response.response)
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
export interface GenerateRequest {
model: string
prompt: string
suffix?: string
system?: string
template?: string
context?: number[]
Expand Down Expand Up @@ -202,8 +203,8 @@
details: ModelDetails
messages: Message[]
modified_at: Date
model_info: Map<string, any>

Check warning on line 206 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected any. Specify a different type

Check warning on line 206 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected any. Specify a different type

Check warning on line 206 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected any. Specify a different type
projector_info?: Map<string, any>

Check warning on line 207 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected any. Specify a different type

Check warning on line 207 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected any. Specify a different type

Check warning on line 207 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected any. Specify a different type
}

export interface ListResponse {
Expand Down
Loading