Skip to content

Commit 1611e73

Browse files
committed
Updated Docs
1 parent fc913c8 commit 1611e73

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,17 @@ from locallab_client import SyncLocalLabClient
8686
client = SyncLocalLabClient("http://localhost:8000")
8787

8888
try:
89+
print("Generating text...")
8990
# Generate text
9091
response = client.generate("Write a story")
9192
print(response)
9293

94+
print("Streaming responses...")
95+
# Stream responses
96+
for token in client.stream_generate("Tell me a story"):
97+
print(token, end="", flush=True)
98+
99+
print("Chat responses...")
93100
# Chat with AI
94101
response = client.chat([
95102
{"role": "system", "content": "You are helpful."},
@@ -113,21 +120,25 @@ async def main():
113120
client = LocalLabClient("http://localhost:8000")
114121

115122
try:
123+
print("Generating text...")
116124
# Generate text
117125
response = await client.generate("Write a story")
118126
print(response)
119127

128+
print("Streaming responses...")
120129
# Stream responses
121130
async for token in client.stream_generate("Tell me a story"):
122131
print(token, end="", flush=True)
123132

133+
print("\nChatting with AI...")
124134
# Chat with AI
125135
response = await client.chat([
126136
{"role": "system", "content": "You are helpful."},
127137
{"role": "user", "content": "Hello!"}
128138
])
129-
print(response.choices[0]["message"]["content"])
130-
139+
# Extracting Content
140+
content = response['choices'][0]['message']['content']
141+
print(content)
131142
finally:
132143
# Always close the client
133144
await client.close()

0 commit comments

Comments
 (0)