from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
Is there a way that I can send files in the same request to tell ChatGPT what do I need? or is there a way that I can back and tell it watch the past files?
Sometime back I wrote a simple code base to read and ask questions from PDF file using Open AI and Langchain and that may help you.
Have a look it at here.
from langchain.document_loaders import PyPDFLoader
from langchain.llms import OpenAI
from langchain.chains.question_answering import load_qa_chain
#Locate your PDF here.
pdf="<YOUR_PDF_GOES_HERE>"
#Load the PDF
loader = PyPDFLoader(pdf)
documents = loader.load()
api_key = "sk-?????"
llm = OpenAI(openai_api_key=api_key)
chain = load_qa_chain(llm,verbose=True)
question = input("Enter your question here : ")
response = chain.run(input_documents=documents, question=question)
print(response)
I only need to know something, if I have more files and I want to get a summary about all of them, what is the best way to upload them?, or what can I do to if I need that my chatbot remember the information in the future?.
Your best bet would be to look into using the Assistants API, you can create the assistant and add as many files as you need. Then enable the retrieval tool and you should be able to then chat with the assistant about any info in any of those documents.