genosdb 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/AIModule.min.js +11 -11
- package/dist/AIModule.min.js.gz +0 -0
- package/dist/AIQuery.min.js +20 -14
- package/dist/AIQuery.min.js.gz +0 -0
- package/dist/gdb.min.js +1 -1
- package/dist/gdb.min.js.gz +0 -0
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ This project is under active development. Do not use it in production environmen
|
|
|
62
62
|
- **Pending Features**:
|
|
63
63
|
- No major features are currently pending. The project has entered a hardening phase with a focus on rigorous testing and stability improvements.
|
|
64
64
|
|
|
65
|
-
> ⚠️ The API is under active development and may change without notice. Use fixed versions and check the [changelog](
|
|
65
|
+
> ⚠️ The API is under active development and may change without notice. Use fixed versions and check the [changelog](CHANGELOG.md) before upgrading.
|
|
66
66
|
|
|
67
67
|
### ✅ **Role Based Access Control (RBAC)**
|
|
68
68
|
|
|
@@ -174,7 +174,7 @@ This graphical view is especially useful for new contributors or anyone looking
|
|
|
174
174
|
|
|
175
175
|
## Contributing
|
|
176
176
|
|
|
177
|
-
We welcome contributions to improve this project! Please read our [Contribution Guidelines](
|
|
177
|
+
We welcome contributions to improve this project! Please read our [Contribution Guidelines](CONTRIBUTING.md) for details on how to get started.
|
|
178
178
|
|
|
179
179
|
|
|
180
180
|
## Community
|
|
@@ -192,11 +192,11 @@ We value community contributions and discussions! Here's how you can get involve
|
|
|
192
192
|
|
|
193
193
|
Feel free to ask questions, share ideas, or just say hello! 👋
|
|
194
194
|
|
|
195
|
-
For more details on contributing, check out our [Contributing Guidelines](
|
|
195
|
+
For more details on contributing, check out our [Contributing Guidelines](CONTRIBUTING.md).
|
|
196
196
|
|
|
197
197
|
## Licenses
|
|
198
198
|
|
|
199
|
-
This project includes third-party dependencies with their respective licenses. For detailed information, see the [Licenses page](
|
|
199
|
+
This project includes third-party dependencies with their respective licenses. For detailed information, see the [Licenses page](THIRD_PARTY_LICENSES.md).
|
|
200
200
|
|
|
201
201
|
The source code of this project is licensed under the [MIT License](https://opensource.org/licenses/MIT). For more information, see the [LICENSE](LICENSE) file.
|
|
202
202
|
|
package/dist/AIModule.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
function
|
|
2
|
-
${
|
|
1
|
+
function C(c){const O=c.map;return c.map=async function(...A){const L=await O.call(this,...A),h=A.find((j)=>j&&typeof j==="object")||{},{prompt:b}=h;if(b)L.results=await w(L.results,b);return L},c}async function w(c,O){const A=c.map((b)=>b.value),L=`
|
|
2
|
+
${O}
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
4
|
+
Strict rules:
|
|
5
|
+
- Return a JSON array with the SAME structure as the input.
|
|
6
|
+
- Each array element must be a modification of the corresponding input object.
|
|
7
|
+
- Only modify fields INSIDE the \`value\` object.
|
|
8
|
+
- DO NOT add, remove, or restructure external nodes like \`id\`, \`edges\`, or \`timestamp\`.
|
|
9
|
+
- DO NOT include explanations or extra text. Return ONLY the JSON array with modified \`value\` objects.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
${JSON.stringify(
|
|
13
|
-
`,
|
|
11
|
+
Input example:
|
|
12
|
+
${JSON.stringify(A)}
|
|
13
|
+
`,h=await z(L);return console.log(h),c.map((b,j)=>{const k=Array.isArray(h)?h[j]:h;return{...b,value:{...b.value,...k||{}}}})}async function z(c){try{const A=await fetch("https://text.pollinations.ai/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"system",content:"You are an AI assistant specialized in processing structured data objects."},{role:"user",content:c}],model:"openai",seed:Math.floor(Math.random()*1000),jsonMode:!0})});if(!A.ok)throw new Error(`Pollinations API error: ${A.statusText}`);const L=await A.json();return L.data||L}catch(O){throw console.error("Error processing prompt with Pollinations API:",O.message),O}}export{C as withAI};
|
package/dist/AIModule.min.js.gz
CHANGED
|
Binary file
|
package/dist/AIQuery.min.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
function v
|
|
2
|
-
|
|
3
|
-
"${y}"
|
|
4
|
-
|
|
5
|
-
Reglas:
|
|
6
|
-
- Devuelve un JSON con campos "query", "order" y "field"
|
|
7
|
-
- Usa operadores MongoDB como "$between", "$gt", "$lt"
|
|
8
|
-
- Para rangos usa "$between": [min, max]
|
|
9
|
-
- Para ordenamiento usa "order": "asc" o "desc" y especifica "field"
|
|
10
|
-
- Ejemplo:
|
|
11
|
-
Entrada: "Busca personas de 10-20 a\xF1os y ord\xE9nalas por edad descendente"
|
|
12
|
-
Salida: {"query": {"age": {"$between": [10, 20]}}, "order": "desc", "field": "age"}
|
|
1
|
+
function q(v){const E=v.map;return v.map=async function(...j){let I={},N=null;if(j.forEach((h)=>{if(typeof h==="object")I={...I,...h};if(typeof h==="function")N=h}),I.prompt)try{const h=await T(I.prompt);console.log("Query generated from AI:",h),I={...I,...h},delete I.prompt}catch(h){console.error("Error generating query from AI:",h.message),I.query={}}return E.call(this,I,N)},v}async function T(v){const E=`
|
|
2
|
+
You are an assistant that converts natural language instructions into a structured MongoDB query object.
|
|
13
3
|
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
Rules:
|
|
5
|
+
- Output ONLY a valid JSON object with the fields: "query", "order", and "field".
|
|
6
|
+
- Use MongoDB operators such as "\$between", "\$gt", "\$lt".
|
|
7
|
+
- For ranges, use "\$between": [min, max].
|
|
8
|
+
- For sorting, use "order": "asc" or "desc" and specify the "field".
|
|
9
|
+
- "\$edge" operator: allows chaining queries to related/descendant entities.
|
|
10
|
+
- No extra text, no explanations, no formatting besides the JSON.
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
Input: "Find people aged 10 to 20 and sort them by age descending"
|
|
14
|
+
Output: {"query": {"age": {"\$between": [10, 20]}}, "order": "desc", "field": "age"}
|
|
15
|
+
|
|
16
|
+
Input: "Find a Company, then find a Developer descendant, then find that Developer's descendant named Bob."
|
|
17
|
+
Output: {"query": {"type":"Company", "\$edge": {"role":"Developer", "\$edge": {"name":"Bob"}}}}
|
|
18
|
+
|
|
19
|
+
Instruction:
|
|
20
|
+
"${v}"
|
|
21
|
+
`;try{const j=await f(E);if(j&&typeof j==="object"&&j.query)return{query:j.query,order:j.order||"asc",field:j.field||Object.keys(j.query)[0]};throw new Error("Invalid AI response format")}catch(j){return console.warn("Using empty query due to AI error:",j.message),{query:{}}}}async function f(v){try{const j=await fetch("https://text.pollinations.ai/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[{role:"system",content:"You are an assistant specialized in converting natural language to structured queries."},{role:"user",content:v}],model:"openai",seed:Math.floor(Math.random()*1000),jsonMode:!0})});if(!j.ok)throw new Error(`Pollinations API error: ${j.statusText}`);const I=await j.json();try{return typeof I==="string"?JSON.parse(I):I}catch{return I}}catch(E){throw console.error("Error processing prompt with API:",E.message),E}}export{q as withAI};
|
package/dist/AIQuery.min.js.gz
CHANGED
|
Binary file
|