import llm
model = llm.get_model("gpt-3.5-turbo")
model.key = 'YOUR_API_KEY_HERE'
response = model.prompt(
"Five surprising names for a pet pelican"
)
print(response.text())
Or you can stream the responses like this:
response = model.prompt(
"Five diabolical names for a pet goat"
)
for chunk in response:
print(chunk, end="")
It works with other models too, installed via plugins - including models that can run directly on your machine:
pip install llm-gpt4all
Then:
model = llm.get_model("ggml-vicuna-7b-1")
print(model.prompt(
"What is the capital of France?"
).text())
It also handles conversations, where each prompt needs to include the previous context of the conversation:
c = model.conversation()
print(c.prompt("Capital of France?").text())
print(c.prompt("what language do they speak?").text())
This looks wonderful, a similar breath of fresh air to using the requests library for the first time. Really impressed by the amount of documentation too.
Is support for embedding and querying a corpus of custom text planned at all? 99% of what I wanted to use langchain for was building a chatbot that can answer questions about my own documents.
Good question! It's because there's an aspect of conversations that differs between different models: the way the previous messages are injected into the context of the prompt.
I went back and forth on a bunch of different designs, but eventually decided to try to make it so that each plugin that implemented a new model would only have to subclass Model and add new methods.
You can see all of the design arguments I had with myself about this here, across the course of 129 pull requests comments: https://github.com/simonw/llm/pull/65