Open diecasfranco opened 1 week ago
Thanks for your question, I should put this in the README, let's keep this issue open until then.
First you should make sure the model you want to use is installed: install the ollama app ( https://ollama.com/download ) then pull the model you need from the terminal, for instance ollama pull llama3.1
(this needs to be done once only)
All ask*()
functions have a model
argument that you can set for instance to "llama3.1"
or "llama3.2"
. I believe I only tested it with llama3.1. Rather than providing the model each time you might prefer to set it through options, for instance options(ask.model = "llama3.1")
.
Please tell me if these instructions work for you.
This works for me. Is it possible to include arbitrary files in context? For example pdf files.
Now it is working. Thank you
There is no context_pdf()
yet in the package, but I will add it, this seems to work (only tested with example below, which you should be able to reproduce):
# ... forwarded to pdftools::pdf_text(), pdftools::pdf_ocr_text(), or/and pdftools::pdf_ocr_data()
context_pdf <- function(
file,
pages = NULL,
opw = "",
upw = "",
dpi = 600,
language = "eng",
options = NULL,
type = "text") {
rlang::check_installed("pdftools")
type = rlang::arg_match(type, c("text", "ocr_text", "ocr_data"), multiple = TRUE)
contexts <- list()
for (i in seq_along(type)) {
contexts[[i]] <- switch(
type[[i]],
text = context('Pdf file OCRed text content: {file}' := pdftools::pdf_text(
pdf = file,
opw = opw,
upw = upw
)),
ocr_text = context('Pdf file OCRed text content: {file}' := pdftools::pdf_ocr_text(
pdf = file,
opw = opw,
upw = upw,
dpi = dpi,
language = language,
options = options
)),
ocr_data = context('Pdf file OCRed data content: {file}' := pdftools::pdf_ocr_data(
pdf = file,
opw = opw,
upw = upw,
dpi = dpi,
language = language,
options = options
)),
)
}
context(!!!contexts)
}
ask("what is this about?", context_pdf("http://arxiv.org/pdf/1403.2805.pdf"))
To feed images from the pdf to the model we need something else we need a bit more work but it is possible too.
btw @MislavSag you mentioned arbitrary files, if you need support for other file types, please open new tickets, these are easy to implement so I should be able to ship them quite fast.
Thanks @moodymudskipper . I have tried your function and it works. The answers are pretty bad, but this due to pdf parsing I suppose.
Hi all, by default, Ask is using OpenAI. How to use it with Ollama?