Skip to content

Commit

Permalink
Merge pull request #234 from polterguy/workflows
Browse files Browse the repository at this point in the history
Started working on Workflows
  • Loading branch information
polterguy authored Dec 14, 2023
2 parents 02725e7 + d08aa31 commit 673dd14
Show file tree
Hide file tree
Showing 447 changed files with 2,616 additions and 660 deletions.
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Contributon to Magic

In order to contribute to Magic, we need your employer's consent that you are legally allowed to contribute to open source projects.
This implies at the minimum having your closest upwards _"C level executive"_ send you an email confirming that there it's OK for
you to contribute to Magic, allowing us to sub-license your work any ways we see fit, for then to forward that email to info@aista.com.
We also need your explicit consent, implying you are fine with Aista, Ltd sub-licensing your code, any ways we see fit.
This implies at the minimum having your closest upwards _"C level executive"_ send you an email confirming that it's OK for
you to contribute to Magic, allowing us to sub-license your work any ways we see fit, for then to forward that email to thomas@ainiro.io.

Hence, if you want to contribute to Magic, you will need to send two emails to info@aista.com as explained further up. Otherwise
Hence, if you want to contribute to Magic, you will need to send two emails to thomas@ainiro.io as explained further up. Otherwise
we cannot for legal reasons accept your contribution.
683 changes: 671 additions & 12 deletions LICENSE

Large diffs are not rendered by default.

17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,8 @@ In addition to its OpenAI and ChatGPT features, Magic is also a complete Low-Cod

## License

**TL;TR** - You can create closed source applications with Magic, but you can _not_ close Magic itself.

The frontend dashboard is licensed under the terms of the GPL version 3, as published by the Free Software Foundation -
While the backend is licensed under the terms of the MIT license. What this implies, is that you can freely use Magic
as you see fit, also in your own proprietary and closed source applications - However, if you modify any of its plugins,
and or the dashboard frontend, you'll have to publish your changes to anyone requesting your changes.

To sum up each license.

* All NuGet packages are LGPL3
* The `backend` folder is MIT
* The `frontend` folder is GPL3

See the enclosed LICENSE files within each folder, and/or plugin if in doubt.
This project, and all of its satellite project, is licensed under the terms of the GPL license version 3, as published by the Free Software Foundation unless an explicit and signed exception has been provided by Thomas Hansen its copyright owner. See LICENSE file for details. For licensing inquiries you can contact Thomas Hansen thomas@ainiro.io

## Copyright and maintenance

The projects is copyright of Aista, Ltd 2021 - 2023, and professionally maintained by [AINIRO your friendly ChatGPT website chatbot vendor](https://ainiro.io).
The projects is copyright of Thomas Hansen, Ltd 2021 - 2023, and professionally maintained by [AINIRO your friendly ChatGPT website chatbot vendor](https://ainiro.io).
2 changes: 1 addition & 1 deletion backend/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2020-2021 Thomas Hansen, thomas@servergardens.com
Copyright 2020-2023 Thomas Hansen, thomas@ainiro.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down
2 changes: 1 addition & 1 deletion backend/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Aista Ltd, 2021 - 2023 team@ainiro.io.
* Copyright (c) Thomas Hansen, 2021 - 2023 thomas@ainiro.io.
*/

using Microsoft.AspNetCore;
Expand Down
2 changes: 1 addition & 1 deletion backend/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Aista Ltd, 2021 - 2023 team@ainiro.io.
* Copyright (c) Thomas Hansen, 2021 - 2023 thomas@ainiro.io.
*/

using Microsoft.AspNetCore.Builder;
Expand Down
4 changes: 2 additions & 2 deletions backend/backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="magic.lambda.system" Version="16.11.5" />
<PackageReference Include="magic.library" Version="16.11.6" />
<PackageReference Include="magic.lambda.system" Version="17.0.0" />
<PackageReference Include="magic.library" Version="17.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
</ItemGroup>

Expand Down
24 changes: 24 additions & 0 deletions backend/files/etc/snippets/eurovision.hl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
signal:magic.http.duckduckgo-and-scrape
query:Who won Eurovision 2023
max:int:5


signal:magic.http.duckduckgo-search
query:Who won Eurovision 2023
max:int:5

signal:magic.http.scrape-url
url:"https://www.cnn.com/2023/05/13/europe/eurovision-song-contest-2023-winner-intl/index.html"

signal:magic.http.scrape-url
url:"https://eurovisionworld.com/eurovision/2023"

signal:magic.http.scrape-url
url:"https://www.nytimes.com/2023/05/13/arts/music/eurovision-2023-final-sweden.html"

signal:magic.http.scrape-url
url:"https://www.npr.org/2023/05/13/1176049673/loreen-of-sweden-wins-eurovision-song-contest"

signal:magic.http.scrape-url
url:"https://www.nytimes.com/live/2023/05/13/arts/eurovision-final"

63 changes: 63 additions & 0 deletions backend/files/etc/snippets/find-dead-images.hl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

/*
* Finds all images that are not referenced in any HTML, JS, CSS or
* Markdown file, and returns in [.result].
*/
.not-used
.html
.images
io.file.list-recursively:/etc/www/
for-each:x:-/*
strings.split:x:@.dp/#
.:.
switch:x:-/0/-
case:html
case:md
.html
set-value:x:@.html
io.file.load:x:@.dp/#
if
eq
get-value:x:@strings.split/0/-
.:md
.lambda
markdown2html:x:@.html
set-value:x:@.html
get-value:x:@markdown2html
if
exists:x:@markdown2html/*/image
.lambda
strings.concat
.:/etc/www
get-value:x:@markdown2html/*/image
unwrap:x:+/*/*
add:x:@.html/@.html
.
.:x:@strings.concat
html2lambda:x:@.html
for-each:x:@html2lambda/**/img/*/\@src
if
strings.starts-with:x:@.dp/#
.:/assets/
.lambda
strings.concat
.:/etc/www
get-value:x:@.dp/#
unwrap:x:+/*/*
add:x:@.html/@.html
.
.:x:@strings.concat
add:x:@.images
io.file.list-recursively:/etc/www/assets/images/
for-each:x:@.images/*

if
not
exists:x:@.html/*/={@.dp/#}
.lambda
unwrap:x:+/*/*
add:x:@.not-used
.
.:x:@.dp/#
for-each:x:@.not-used/*
io.file.delete:x:@.dp/#
4 changes: 4 additions & 0 deletions backend/files/etc/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Hyperlambda workflows

This folder contains your custom Hyperlambda workflows.
16 changes: 16 additions & 0 deletions backend/files/etc/workflows/example.hl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

/*
* Example workflow executing sql-select action, for then
* to return result of invocation.
*/

/*
* Execute some select SQL statement specified as [sql].
* Optionally provide [connection-string], [database-type] and [database].
*/
execute:magic.workflows.functions.execute
name:sql-select
filename:/misc/workflows/functions/sql-select.hl
arguments
sql:select name from roles where name like @arg1 limit 2
@arg1:a%
5 changes: 4 additions & 1 deletion backend/files/exceptions.hl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ log.error:x:@.arguments/*/message
if
and
exists:x:@.arguments/*/public
get-value:x:@.arguments/*/public
or
get-value:x:@.arguments/*/public
convert:x:@.arguments/*/public
type:bool
.lambda

// Exception message is supposed to propagate to client.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) Aista Ltd, 2021 - 2023 team@ainiro.io.
* Copyright (c) Thomas Hansen, 2021 - 2023 thomas@ainiro.io.
*/

import { Pipe, PipeTransform } from '@angular/core';
Expand Down
4 changes: 4 additions & 0 deletions backend/files/misc/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Workflow Hyperlambda files

Supporting Hyperlambda files your workflows.
4 changes: 4 additions & 0 deletions backend/files/misc/workflows/functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Hyperlambda functions for workflows

This folder contains Hyperlambda system functions for your workflows.
94 changes: 94 additions & 0 deletions backend/files/misc/workflows/functions/compile-csharp.hl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

/*
* Compiles the specified C# code and loads into the AppDomain.
*
* Notice, will not compile the specified code if assembly already exists in
* AppDomain, unless [recompile] is true.
*/
.arguments
code:string
file:string
references:*
assembly-name:string
recompile:bool
.example
code:@"
using System;
using magic.node;
using magic.node.extensions;
using magic.signals.contracts;

[Slot(Name = ""get-employee-details"")]
public class Foo : ISlot
{
public void Signal(ISignaler signaler, Node input)
{
switch (input.GetEx<string>().ToLower())
{
case ""john"":
input.Add(new Node(""title"", ""cmo""));
input.Add(new Node(""phone"", ""92929292""));
input.Add(new Node(""email"", ""john@doe.come""));
break;
}
input.Value = null;
}
}"
references
.:netstandard
.:System.Runtime
.:System.ComponentModel
.:System.Private.CoreLib
.:magic.node
.:magic.node.extensions
.:magic.signals.contracts
assembly-name:employees.dll
recompile:bool:false
.icon:rocket_launch

// Sanity checking invocation.
validators.mandatory:x:@.arguments/*/code
validators.mandatory:x:@.arguments/*/references
validators.mandatory:x:@.arguments/*/assembly-name

/*
* We only compile C# code if it does not already exist in AppDomain,
* unless caller explicitly specifies [recompile] as true.
*/
system.plugin.list
if
or
get-value:x:@.arguments/*/recompile
not-exists:x:@system.plugin.list/*/={@.arguments/*/assembly-name}
.lambda

// Parametrizing [system.compile] invocation.
add:x:./*/system.compile
get-nodes:x:@.arguments/*/references
get-nodes:x:@.arguments/*/assembly-name

// Checking if caller provided a [file] argument instead of a [code] argument.
if
and
not-exists:x:@.arguments/*/code
exists:x:@.arguments/*/file
not-null:x:@.arguments/*/file
.lambda

// We've got a [file] argument instead of a [code] argument.
load-file:x:@.arguments/*/file
add:x:@.lambda/@.lambda/*/system.compile
.
code:x:@load-file

else

// Caller provided a [code] argument.
add:x:@.lambda/*/system.compile
get-nodes:x:@.arguments/*/code

// Compiling C# code.
system.compile

// Loading assembly into AppDomain.
system.plugin.load:x:@system.compile
41 changes: 41 additions & 0 deletions backend/files/misc/workflows/functions/context-from-database.hl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

/*
* Returns context for the specified [query] from the specified [type],
* and returns to caller.
*
* Optionally add [threshold] and [max_tokens] to specify similarity and maximum
* tokens to return.
*/
.arguments
type:string
query:string
threshold:decimal
max_tokens:int
.example
type:x:@.arguments/*/type
query:x:@.arguments/*/query
threshold:decimal:0.3
max_tokens:int:2000
.icon:extension

// Sanity checking invocation.
validators.mandatory:x:@.arguments/*/type
validators.mandatory:x:@.arguments/*/query

// Applying default values for optional arguments.
validators.default:x:@.arguments
threshold:decimal:0.3
max_tokens:int:4000

// Retrieving context.
execute:magic.ai.get-context
type:x:@.arguments/*/type
vector_model:text-embedding-ada-002
prompt:x:@.arguments/*/query
threshold:x:@.arguments/*/threshold
max_tokens:x:@.arguments/*/max_tokens

// Returning result of invocation to caller.
unwrap:x:./*/return/*
return
result:x:@execute/*/context
Loading

0 comments on commit 673dd14

Please sign in to comment.