@@ -37,6 +37,27 @@ We think so. Open-source models have made remarkable strides, not only catching
37
37
The Switch Kit is an open-source AI SDK that provides a drop in replacement for OpenAI’s chat completion endpoint.
38
38
39
39
{% tabs %}
40
+ {% tab title="JavaScript" %}
41
+ ``` javascript
42
+ const pgml = require (" pgml" );
43
+ const client = pgml .newOpenSourceAI ();
44
+ const results = client .chat_completions_create (
45
+ " HuggingFaceH4/zephyr-7b-beta" ,
46
+ [
47
+ {
48
+ role: " system" ,
49
+ content: " You are a friendly chatbot who always responds in the style of a pirate" ,
50
+ },
51
+ {
52
+ role: " user" ,
53
+ content: " How many helicopters can a human eat in one sitting?" ,
54
+ },
55
+ ],
56
+ );
57
+ console .log (results);
58
+ ```
59
+ {% endtab %}
60
+
40
61
{% tab title="Python" %}
41
62
``` python
42
63
import pgml
@@ -58,27 +79,6 @@ results = client.chat_completions_create(
58
79
print (results)
59
80
```
60
81
{% endtab %}
61
-
62
- {% tab title="JavaScript" %}
63
- ``` javascript
64
- const pgml = require (" pgml" );
65
- const client = pgml .newOpenSourceAI ();
66
- const results = client .chat_completions_create (
67
- " HuggingFaceH4/zephyr-7b-beta" ,
68
- [
69
- {
70
- role: " system" ,
71
- content: " You are a friendly chatbot who always responds in the style of a pirate" ,
72
- },
73
- {
74
- role: " user" ,
75
- content: " How many helicopters can a human eat in one sitting?" ,
76
- },
77
- ],
78
- );
79
- console .log (results);
80
- ```
81
- {% endtab %}
82
82
{% endtabs %}
83
83
84
84
``` json
@@ -120,29 +120,6 @@ The best part of using open-source AI is the flexibility with models. Unlike Ope
120
120
Here is an example of streaming with the popular Mythalion model, an uncensored MythoMax variant designed for chatting.
121
121
122
122
{% tabs %}
123
- {% tab title="Python" %}
124
- ``` python
125
- import pgml
126
- client = pgml.OpenSourceAI()
127
- results = client.chat_completions_create_stream(
128
- " PygmalionAI/mythalion-13b" ,
129
- [
130
- {
131
- " role" : " system" ,
132
- " content" : " You are a friendly chatbot who always responds in the style of a pirate" ,
133
- },
134
- {
135
- " role" : " user" ,
136
- " content" : " How many helicopters can a human eat in one sitting?" ,
137
- },
138
- ],
139
- temperature = 0.85 ,
140
- )
141
- for c in results:
142
- print (c)
143
- ```
144
- {% endtab %}
145
-
146
123
{% tab title="JavaScript" %}
147
124
``` javascript
148
125
const pgml = require (" pgml" );
@@ -167,6 +144,29 @@ while (!result.done) {
167
144
}
168
145
```
169
146
{% endtab %}
147
+
148
+ {% tab title="Python" %}
149
+ ``` python
150
+ import pgml
151
+ client = pgml.OpenSourceAI()
152
+ results = client.chat_completions_create_stream(
153
+ " PygmalionAI/mythalion-13b" ,
154
+ [
155
+ {
156
+ " role" : " system" ,
157
+ " content" : " You are a friendly chatbot who always responds in the style of a pirate" ,
158
+ },
159
+ {
160
+ " role" : " user" ,
161
+ " content" : " How many helicopters can a human eat in one sitting?" ,
162
+ },
163
+ ],
164
+ temperature = 0.85 ,
165
+ )
166
+ for c in results:
167
+ print (c)
168
+ ```
169
+ {% endtab %}
170
170
{% endtabs %}
171
171
172
172
``` json
0 commit comments