-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef6d060
commit 3725ba1
Showing
11 changed files
with
1,310 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>OpenAI_for_Grasshopper</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Betalgo.OpenAI.GPT3" Version="6.6.6" /> | ||
<PackageReference Include="Grasshopper" Version="8.0.22347.14305-wip" /> | ||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" /> | ||
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> | ||
<Exec Command="copy /Y "$(TargetDir)$(ProjectName).dll" "$(USERPROFILE)\AppData\Roaming\Grasshopper\Libraries\OpenAI for Grasshopper\$(ProjectName).gha"" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.4.33205.214 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenAI for Grasshopper", "OpenAI for Grasshopper.csproj", "{06488F20-9638-4F94-A48A-808946CB8505}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{06488F20-9638-4F94-A48A-808946CB8505}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{06488F20-9638-4F94-A48A-808946CB8505}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{06488F20-9638-4F94-A48A-808946CB8505}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{06488F20-9638-4F94-A48A-808946CB8505}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4827BB93-1169-44A2-9483-450CA823DF11} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Grasshopper.Kernel.Types; | ||
using Grasshopper.Kernel; | ||
using OpenAI.GPT3.Managers; | ||
using OpenAI.GPT3.ObjectModels.ResponseModels; | ||
|
||
namespace OpenAI_for_Grasshopper | ||
{ | ||
public class Goo_OpenAIService : Goo_Base<OpenAIService> | ||
{ | ||
public Goo_OpenAIService() : base() { } | ||
public Goo_OpenAIService(OpenAIService value) : base(value) { } | ||
public Goo_OpenAIService(Goo_OpenAIService other) : this(other.Value) { } | ||
|
||
public override IGH_Goo Duplicate() | ||
{ | ||
return new Goo_OpenAIService(this); | ||
} | ||
|
||
} | ||
|
||
public class Param_OpenAIService : GH_Param<Goo_OpenAIService> | ||
{ | ||
public override Guid ComponentGuid => new Guid("57a1127f-91ce-4ea4-82a2-21b871fd268a"); | ||
public override GH_Exposure Exposure => GH_Exposure.hidden; | ||
|
||
public Param_OpenAIService() : base("Open AI Service", "OS", "The Open AI client service", "Extra", "OpenAI", GH_ParamAccess.item) { } | ||
} | ||
|
||
public class Goo_BaseResponse : Goo_Base<BaseResponse> | ||
{ | ||
public Goo_BaseResponse() : base() { } | ||
public Goo_BaseResponse(BaseResponse value) : base(value) { } | ||
public Goo_BaseResponse(Goo_BaseResponse other) : this(other.Value) { } | ||
|
||
public override IGH_Goo Duplicate() | ||
{ | ||
return new Goo_BaseResponse(this); | ||
} | ||
} | ||
|
||
public class Param_BaseResponse : GH_Param<Goo_BaseResponse> | ||
{ | ||
public override Guid ComponentGuid => new Guid("4a0b09e3-81e3-47e1-872c-51cdc0fd4913"); | ||
public override GH_Exposure Exposure => GH_Exposure.hidden; | ||
|
||
public Param_BaseResponse() : base("Open AI Response", "R", "The resulting response", "Extra", "OpenAI", GH_ParamAccess.item) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Grasshopper.Kernel; | ||
using System.Drawing; | ||
|
||
namespace OpenAI_for_Grasshopper | ||
{ | ||
public class Plugin : GH_AssemblyInfo | ||
{ | ||
public override string Name => "OpenAI for Grasshopper"; | ||
public override string Description => "OpenAI API interface for Grasshopper, using https://github.com/betalgo/openai"; | ||
public override Bitmap Icon => Properties.Resources.OpenAI_logo_24x24; | ||
public override string AuthorName => "Daniel Gonzalez Abalde"; | ||
public override string AuthorContact => "DaniGA#9856"; | ||
public override string Version => "1.0.0"; | ||
public override Guid Id => new Guid("0f8cbae1-bf53-4163-a828-edf4d16a1113"); | ||
public override GH_LibraryLicense License => GH_LibraryLicense.opensource; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||
<data name="OpenAI logo 24x24" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||
<value>..\Resources\OpenAI logo 24x24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||
</data> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"profiles": { | ||
"OpenAI for Grasshopper": { | ||
"commandName": "Project" | ||
}, | ||
"Profile 1": { | ||
"commandName": "Executable", | ||
"executablePath": "C:\\Program Files\\Rhino 8 WIP\\System\\Rhino.exe" | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
| ||
using System.Drawing; | ||
|
||
namespace OpenAI_for_Grasshopper | ||
{ | ||
public static class Utils | ||
{ | ||
public static Image Base64ToImage(string base64String) | ||
{ | ||
if (base64String == null) | ||
return null; | ||
byte[] imageBytes = Convert.FromBase64String(base64String); | ||
using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length)) { | ||
Image image = Image.FromStream(ms, true); | ||
return image; | ||
} | ||
} | ||
public static string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format) | ||
{ | ||
using (MemoryStream ms = new MemoryStream()) { | ||
// Convert Image to byte[] | ||
image.Save(ms, format); | ||
byte[] imageBytes = ms.ToArray(); | ||
|
||
// Convert byte[] to base 64 string | ||
string base64String = Convert.ToBase64String(imageBytes); | ||
return base64String; | ||
} | ||
} | ||
} | ||
} |