Skip to content

Commit

Permalink
Added search API
Browse files Browse the repository at this point in the history
  • Loading branch information
FloomAI committed Nov 13, 2024
1 parent 2d8da53 commit 528d09d
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 143 deletions.
11 changes: 1 addition & 10 deletions Floom.Core/Controllers/FunctionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public async Task<IActionResult> DeployFunction([FromForm] IFormFile file)
}
}


[HttpPost("run")]
public async Task<IActionResult> RunFunction([FromBody] RunFunctionRequest request)
{
Expand All @@ -72,15 +71,7 @@ public async Task<IActionResult> ListPublicFeaturedFunctions()
var publicFeaturedFunctions = await _functionsService.ListPublicFeaturedFunctionsAsync();
return Ok(publicFeaturedFunctions);
}

[HttpPost("featured/run")]
[AllowAnonymous]
public async Task<IActionResult> RunFeaturedFunction([FromBody] RunFunctionRequest request)
{
var result = await _functionsService.RunFeaturedFunctionAsync(request.function, request.prompt, request.parameters);
return Ok(result);
}


[HttpPost("search")]
[AllowAnonymous]
public async Task<IActionResult> SearchPublicFunctions([FromBody] SearchRequest request)
Expand Down
55 changes: 13 additions & 42 deletions Floom.Core/Functions/FunctionDto.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,30 @@
using Floom.Functions;
namespace Floom.Functions;

public class FunctionDto
public class BaseFunctionDto
{
/**
packageName = unique = function url
*/
public string name { get; set; }
public string description { get; set; }
public string runtimeLanguage { get; set; }
public string runtimeFramework { get; set; }
public string author { get; set; }
public string username { get; set; }
public string version { get; set; }
public double rating { get; set; }
public List<int> downloads { get; set; }
public List<ParameterDto> parameters { get; set; } = new();
}
public List<int> downloads { get; set; } = new();

public class SearchResultFunctionDto
{
public string id { get; set; }
public string slug { get; set; }
public TranslatedField title { get; set; } // Translated titles
public TranslatedField description { get; set; } // Translated descriptions
public string author { get; set; }
public double rating { get; set; }
}

public class FeaturedFunctionDto
{
public string id { get; set; }
public string name { get; set; }
public string slug { get; set; }
public TranslatedField title { get; set; } // Translated titles
public TranslatedField description { get; set; } // Translated descriptions
public TranslatedField promptPlaceholder { get; set; } // Translated descriptions
public string runtimeLanguage { get; set; }
public string runtimeFramework { get; set; }
public string author { get; set; }
public string version { get; set; }
public double rating { get; set; }
public List<int> downloads { get; set; }
public List<FeaturedFunctionParameterDto> parameters { get; set; } = new();
}
public List<ParameterDto> parameters { get; set; } = new();

public class ParameterDto
{
public string name { get; set; }
public string? description { get; set; }
public bool required { get; set; }
public object? defaultValue { get; set; }
public TranslatedField title { get; set; }
public TranslatedField description { get; set; }

public TranslatedField promptPlaceholder { get; set; }
}

public class FeaturedFunctionParameterDto
public class ParameterDto
{
public string name { get; set; }
public TranslatedField? description { get; set; }
public bool required { get; set; }
public object? defaultValue { get; set; }
}

}
Loading

0 comments on commit 528d09d

Please sign in to comment.