Skip to content

Commit

Permalink
Update code snippets in README (#19)
Browse files Browse the repository at this point in the history
* Update code snippets in README

* Rename llm variable to model
  • Loading branch information
neilmehta24 authored Feb 27, 2025
1 parent 2bbad8f commit 4d88ea2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ Using this convenience API, requesting text completion from an already
loaded LLM is as straightforward as:

```python
import lmstudio as lm
import lmstudio as lms

llm = lm.llm()
llm.complete("Once upon a time,")
model = lms.llm()
model.complete("Once upon a time,")
```

Requesting a chat response instead only requires the extra step of
setting up a `Chat` helper to manage the chat history and include
it in response prediction requests:

```python
import lmstudio as lm
import lmstudio as lms

EXAMPLE_MESSAGES = (
"My hovercraft is full of eels!",
"I will not buy this record, it is scratched."
)

llm = lm.llm()
chat = lm.Chat("You are a helpful shopkeeper assisting a foreign traveller")
model = lms.llm()
chat = lms.Chat("You are a helpful shopkeeper assisting a foreign traveller")
for message in EXAMPLE_MESSAGES:
chat.add_user_message(message)
print(f"Customer: {message}")
response = llm.respond(chat)
response = model.respond(chat)
chat.add_assistant_response(response)
print(f"Shopkeeper: {response}")
```
Expand Down

0 comments on commit 4d88ea2

Please sign in to comment.