-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
38 lines (30 loc) · 1.17 KB
/
example.py
File metadata and controls
38 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Example usage of the llms2 package.
This example demonstrates how to use the LLMS class to interact with LLM APIs.
"""
from llms2 import LLMS
# Initialize LLMS with a configuration file
# Default is 'llms.yml' in the current directory
llms = LLMS()
# Prepare a simple message
messages = llms.prepare_messages(
prompt="Hello, how are you?",
system_msg="When user asks how are you, say hello world."
)
# Query the LLM (requires API keys to be set in environment)
# response = llms.query("deepseek-v3.2", messages)
# print(response)
# Example with image (for vision models)
# messages = llms.prepare_messages(
# prompt="What do you see in this image?",
# image_paths=["test_img.png"]
# )
# response = llms.query("qwen3vl-plus", messages)
# print(response)
# Save and load conversation history
# messages.append({"role": "assistant", "content": response})
# llms.save_messages("deepseek-v3.2", messages, "conversation.yml")
# loaded_messages = llms.load_messages("conversation.yml")
# assert messages == loaded_messages, "! Loaded messages do not match saved messages."
print("Example script loaded successfully!")
print("Uncomment the lines above to test with real API calls.")