Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 1_python/1_getting-started/project-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ SERVER_API_HOST = "localhost:1234"
if lms.Client.is_valid_api_host(SERVER_API_HOST):
print(f"An LM Studio API server instance is available at {SERVER_API_HOST}")
else:
print("No LM Studio API server instance found at {SERVER_API_HOST}")
print(f"No LM Studio API server instance found at {SERVER_API_HOST}")
```

```python tab="Python (asynchronous API)"
Expand All @@ -106,7 +106,7 @@ SERVER_API_HOST = "localhost:1234"
if await lms.AsyncClient.is_valid_api_host(SERVER_API_HOST):
print(f"An LM Studio API server instance is available at {SERVER_API_HOST}")
else:
print("No LM Studio API server instance found at {SERVER_API_HOST}")
print(f"No LM Studio API server instance found at {SERVER_API_HOST}")
```

### Determining the default local API server port
Expand All @@ -124,7 +124,7 @@ import lmstudio as lms
api_host = lms.Client.find_default_local_api_host()
if api_host is not None:
print(f"An LM Studio API server instance is available at {api_host}")
else:
else:
print("No LM Studio API server instance found on any of the default local ports")
```

Expand All @@ -136,6 +136,6 @@ import lmstudio as lms
api_host = await lms.AsyncClient.find_default_local_api_host()
if api_host is not None:
print(f"An LM Studio API server instance is available at {api_host}")
else:
else:
print("No LM Studio API server instance found on any of the default local ports")
```
3 changes: 1 addition & 2 deletions 1_python/1_getting-started/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ which use `with` statements to ensure deterministic cleanup of network communica
resources).

The convenience API allows the standard Python REPL, or more flexible alternatives like
Juypter Notebooks, to be used to interact with AI models loaded into LM Studio. For
Jupyter Notebooks, to be used to interact with AI models loaded into LM Studio. For
example:

```python title="Python REPL"
Expand All @@ -27,7 +27,6 @@ example:
0 LLM(identifier='qwen2.5-7b-instruct')
>>> model = loaded_models[0]
>>> chat = lms.Chat("You answer questions concisely")
>>> chat = lms.Chat("You answer questions concisely")
>>> chat.add_user_message("Tell me three fruits")
UserMessage(content=[TextData(text='Tell me three fruits')])
>>> print(model.respond(chat, on_message=chat.append))
Expand Down
4 changes: 2 additions & 2 deletions 1_python/2_agent/act.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def is_prime(n: int) -> bool:
if n < 2:
return False
sqrt = int(math.sqrt(n))
for i in range(2, sqrt):
for i in range(2, sqrt + 1):
if n % i == 0:
return False
return True
Expand Down Expand Up @@ -116,7 +116,7 @@ def create_file(name: str, content: str):
try:
dest_path.write_text(content, encoding="utf-8")
except Exception as exc:
return "Error: {exc!r}"
return f"Error: {exc!r}"
return "File created."

def print_fragment(fragment, round_index=0):
Expand Down
6 changes: 3 additions & 3 deletions 1_python/2_agent/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_file(name: str, content: str):
try:
dest_path.write_text(content, encoding="utf-8")
except Exception as exc:
return "Error: {exc!r}"
return f"Error: {exc!r}"
return "File created."
```

Expand Down Expand Up @@ -124,7 +124,7 @@ def divide(numerator: float, denominator: float) -> float:
return numerator / denominator

model = lms.llm("qwen2.5-7b-instruct")
chat = Chat()
chat = lms.Chat()
chat.add_user_message(
"Attempt to divide 1 by 0 using the tool. Explain the result."
)
Expand All @@ -134,7 +134,7 @@ def _raise_exc_in_client(
) -> None:
raise exc

act_result = llm.act(
act_result = model.act(
chat,
[divide],
handle_invalid_tool_request=_raise_exc_in_client,
Expand Down
Loading