@@ -56,28 +56,46 @@ When you use LocalLab:
56
56
```
57
57
58
58
3 . ** AI Interaction**
59
+
59
60
``` python
60
61
# Your code sends requests through the client
62
+ # Async usage
61
63
response = await client.generate(" Write a story" )
62
64
print (response) # Server processes and returns AI response
65
+
66
+ # Or sync usage (New!)
67
+ response = client.generate(" Write a story" )
68
+ print (response) # Same result, no async/await needed!
63
69
```
64
70
65
71
## 💡 Quick Examples
66
72
67
73
``` python
68
- # Generate text
69
- response = await client.generate(" Hello!" )
74
+ # Generate text (async or sync)
75
+ response = await client.generate(" Hello!" ) # Async
76
+ response = client.generate(" Hello!" ) # Sync (New!)
70
77
71
- # Chat with AI
72
- response = await client.chat([
78
+ # Chat with AI (async or sync)
79
+ response = await client.chat([ # Async
80
+ {" role" : " user" , " content" : " Hi!" }
81
+ ])
82
+ response = client.chat([ # Sync (New!)
73
83
{" role" : " user" , " content" : " Hi!" }
74
84
])
75
85
76
- # Process multiple prompts
77
- responses = await client.batch_generate([
86
+ # Process multiple prompts (async or sync)
87
+ responses = await client.batch_generate([ # Async
78
88
" Write a joke" ,
79
89
" Tell a story"
80
90
])
91
+ responses = client.batch_generate([ # Sync (New!)
92
+ " Write a joke" ,
93
+ " Tell a story"
94
+ ])
95
+
96
+ # Context manager support (New!)
97
+ with LocalLabClient(" http://localhost:8000" ) as client:
98
+ response = client.generate(" Hello!" ) # Auto-closes when done
81
99
```
82
100
83
101
[ ➡️ See More Examples] ( ./docs/guides/examples.md )
@@ -127,6 +145,8 @@ Our [Documentation Guide](./docs/README.md) will help you:
127
145
- ** Resource Efficient** : Automatic optimization
128
146
- ** Privacy First** : All local, no data sent to cloud
129
147
- ** Free GPU** : Google Colab integration
148
+ - ** Unified Client API** : Works with or without async/await (New!)
149
+ - ** Automatic Resource Management** : Sessions close automatically (New!)
130
150
131
151
[ ➡️ See All Features] ( ./docs/features/README.md )
132
152
@@ -144,5 +164,5 @@ Our [Documentation Guide](./docs/README.md) will help you:
144
164
145
165
---
146
166
147
- Made with ❤️ by Utkarsh Tiwari
167
+ Made with ❤️ by Utkarsh Tiwari
148
168
[ GitHub] ( https://github.com/UtkarshTheDev ) • [ Twitter] ( https://twitter.com/UtkarshTheDev ) • [ LinkedIn] ( https://linkedin.com/in/utkarshthedev )
0 commit comments