mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
Is there a way for using chat() function by passing more context ? #20
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @unexpand on GitHub (Jan 31, 2024).
What I am trying to attempt is something like langchain RetrievalQA, making chat request with some context.
I got the documents from pgvector postgres using search and I want to use prompt like "Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer." and pass the documents as context so mistral llm can use the context to respond.
my code currently looks like this and it works, but I am not sure if this is a valid approach.
@mxyng commented on GitHub (Jan 31, 2024):
chatis intended to be used with ollama's model templates with messages representing one side of a chat exchange. To better illustrate this here's an example equivalent to your code:The input
messagescan be construct anyway you want however the only valid roles aresystem,user, andassistant.