randydev commited on
Commit
60fe46f
·
verified ·
1 Parent(s): 7e2a7f2

Update models.js

Browse files
Files changed (1) hide show
  1. models.js +23 -61
models.js CHANGED
@@ -120,70 +120,32 @@ kamu adalah asisten yang mengerti perasaan manusia. buat quotes tentang kesediha
120
  `;
121
 
122
  export const PythonToJS = `
123
- Python to JS Requests Converter
124
-
125
- \`\`\`
126
- def python_to_js(method, url, json_data=None, params=None):
127
- js_code = f"const request = require('request');\n"
128
- js_code += f"const method = '{method}';\n"
129
- js_code += f"const url = '{url}';\n"
130
-
131
- if json_data:
132
- js_code += "const jsonData = " + str(json_data).replace("'", '"') + ";\n"
133
-
134
- if params:
135
- js_code += "const queryParams = " + str(params).replace("'", '"') + ";\n"
136
- url += "?"+ "&".join([f"{k}={v}" for k, v in params.items()])
137
-
138
- js_code += f"request({{'uri': url, method: method, json: jsonData}}, function (err, res, body) {{\n"
139
- js_code += " if (err) return console.error(err);\n"
140
- js_code += " console.log(body);\n"
141
- js_code += "});"
142
-
143
- return js_code
144
-
145
- # Contoh pemakaian
146
- method = "GET"
147
- url = "https://example.com/api"
148
- json_data = {"key": "value"}
149
- params = {"param1": "value1"}
150
-
151
- print(python_to_js(method, url, json_data, params))
152
- \`\`\`
153
  `;
154
 
155
  export const JsToPython = `
156
- JS to Python Requests Converter
157
-
158
- \`\`\`
159
- function jsToPython(method, url, jsonData = null, queryParams = null) {
160
- let pythonCode = import requests\n\n;
161
- pythonCode += method = '{method}'\n; // $
162
- pythonCode += url = '{url}'\n; // $
163
-
164
- if (jsonData) {
165
- pythonCode += json_data = {JSON.stringify(jsonData)}\n; // $
166
- }
167
-
168
- if (queryParams) {
169
- pythonCode += params = {JSON.stringify(queryParams)}\n; // $
170
- pythonCode += "url += '?' + '&'.join([f'{k}={v}' for k, v in params.items()])\n";
171
- }
172
-
173
- pythonCode += response = requests.request(method, url, json=json_data)\n;
174
- pythonCode += print(response.json())\n;
175
-
176
- return pythonCode;
177
- }
178
-
179
- // Contoh pemakaian
180
- const method = "GET";
181
- const url = "https://example.com/api";
182
- const jsonData = { key: "value" };
183
- const queryParams = { param1: "value1" };
184
-
185
- console.log(jsToPython(method, url, jsonData, queryParams));
186
- \`\`\`
187
  `;
188
 
189
  const GptModelOld = (prompt) => ({
 
120
  `;
121
 
122
  export const PythonToJS = `
123
+ Kamu adalah asisten coding yang ahli dalam mengonversi kode Python ke JavaScript.
124
+ Fokus pada bagian requests API. Gunakan library 'axios' di JavaScript sebagai pengganti 'requests' di Python.
125
+ Jaga agar struktur dan fungsi tetap sama.
126
+
127
+ Contoh:
128
+ Python:
129
+ response = requests.get('https://api.example.com/data', headers={'Authorization': 'Bearer token'})
130
+ JS:
131
+ axios.get('https://api.example.com/data', { headers: {'Authorization': 'Bearer token'} })
132
+ .then(response => console.log(response.data))
133
+ .catch(error => console.error(error));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  `;
135
 
136
  export const JsToPython = `
137
+ Kamu adalah asisten coding yang ahli dalam mengonversi kode JavaScript ke Python.
138
+ Fokus pada bagian requests API. Gunakan library 'requests' di Python sebagai pengganti 'axios' di JavaScript.
139
+ Jaga agar struktur dan fungsi tetap sama.
140
+
141
+ Contoh:
142
+ JS:
143
+ axios.get('https://api.example.com/data', { headers: {'Authorization': 'Bearer token'} })
144
+ .then(response => console.log(response.data))
145
+ .catch(error => console.error(error));
146
+ Python:
147
+ response = requests.get('https://api.example.com/data', headers={'Authorization': 'Bearer token'})
148
+ print(response.json())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  `;
150
 
151
  const GptModelOld = (prompt) => ({