👨‍💻 feat: example code in playground

This commit is contained in:
Florian Hönicke
2023-04-20 13:40:05 +02:00
parent 78a4580e00
commit f19cce0eca

View File

@@ -297,6 +297,19 @@ The playground must look like it was made by a professional designer.
All the ui elements are well thought out to make them visually appealing and easy to use.
The playground contains many emojis that fit the theme of the playground and has an emoji as favicon.
The playground encourages the user to deploy their own microservice by clicking on this link: https://github.com/jina-ai/gptdeploy
The playground provides a javascript code snippet that can be used to send requests to the executor. It looks like this:
```javascript
(async () => {
const deploymentId = '<your_deployment_id>';
const url = `https://gptdeploy-${deploymentId}.wolf.jina.ai/`;
const docArray = [{ text: '...' }];
const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(docArray) });
console.log((await res.json())[0].text);
})();
```
Make sure you put the right example data into the text attribute of the document.
This is an example how you can connect to the executor assuming the document (d) is already defined:
```
from jina import Client, Document, DocumentArray